Welcome to Our Community

Some features disabled for guests. Register Today.

Limit switches / noise filtering necessary?

Discussion in 'General Electronics' started by Rosenwasser Benny, May 1, 2017.

  1. Rosenwasser Benny

    Rosenwasser Benny Well-Known
    Builder

    Joined:
    Mar 21, 2017
    Messages:
    21
    Likes Received:
    2
    Hello,


    I’m going to build a cnc machine like the Sphinx XL version, most parts are ordered and I’m waiting for the delivery’s.

    In the meantime I am busy to draw the electrical drawings, see attachment.

    On the internet I saw several posts that saying that the NO limit switches on the X, Y, Z axis can bring noise problems.


    My questions:

    1. Is it always necessary to install the 4,7K resistor and 100nF capacitors or just in case of noise problems.

    2. Should the motor cables have a connected shield to the ground?

    3. Should the switch cables have a connected shield to the ground?


    For the interface, I will try to use my Arduino Uno board and screw shield that is laying around.



    Regards, Benny
     

    Attached Files:

  2. Carl W. Livingston

    Carl W. Livingston Well-Known
    Builder

    Joined:
    Dec 12, 2016
    Messages:
    15
    Likes Received:
    8
    The thing about NORMALLY OPEN limit switches is this...

    In the old days, Transistor-Transistor Logic (TTL) naturally pulled toward +5 VDC due to it's internal construction. In fact, a disconnected TTL levels off at about 2VDC, right in the middle of the indecision zone. TTL operates at a valid logic low between GND and 0.8 volts. A valid logic high is about 3 VDC to 5VDC. Also, TTL is a current operated device. That is, the inputs to the logic gates are current sourcing. In the old TTL days, it was common to install a 4.7K Ohm pull-up resistor and use a switch contact to pull the input to GND.

    Today, pretty much all logic, while still having compatible TTL logic levels, are all constructed from some Metal Oxide flavor technology - VMOS, NMOS, PMOS, etc. As well, MOS type devices are voltage operated. That is, MOS inputs require extremely small levels of current (on the order of Nano to Micro Amperes) to drive that input from one logic level extreme to the other.

    Have you ever heard the story about why Mom cuts the ends of the roast off before she puts in into the pan? Well, Mom doesn't know! And so, Mom asks Grandma and, Grandma doesn't know. And so, Grandma asks Great-grandma. Well, Great-grandma replies "That's simple!" I cut the ends of the roast off because the whole roast would not fit into the particular pan the owned. This trend carried from one generation to the next, simply because the previous generation had done it. This type thing seems to be very common in the nature of human beings.

    So here we have a similat tridition carried from generation to generation, simply because "That's the way it's always been done!" We use regularly apply techniques that apply to old school technology to today's technology - without even knowing why. And for today's technology, "Old-School" is not the correct approach. Here is why.

    With the "Old-School" method, the TTL input was still susceptible to noise - hence, the need for an RC filter at the input. The reason being, with the NORMALLY OPEN switch contact, noise could still swamp and overcome the pull-up resistor.

    So, let me ask... Which is more noise immune, a logic input that is pulled up with a 4.7K Ohm resistor or a logic input that is pulled to GND with a contact resistance of 0.1 Ohm?

    The idea is this, that NORMALLY OPEN axis limit stitch is sitting there and (hopefully) never gets bumped. But, depending on wire length, noise on the power supply and magnetic influence from adjacent wiring, noise can still cause false triggering. That is, that input is perpetually at risk of being influenced by noise and could ruin a part if the input triggers at the wrong time.

    On the other hand, if a NORMALLY CLOSED switch contact is employed, the axis limit switch contact holds that critical input at a low logic level, at a very low impedance circuit path to GND. This method is, by far, superior to the "Old-School" practice!

    And to be sure, best practice would dictate that, even when employing NORMALLY CLOSED switch contacts, a pull-up resistor between the input and +5VDC, and a series resistor and parallel filter capacitor be employed.

    The idea is that, you always want to look at a safety circuitry from a reliability and "Fail-safe" point of view.

    Incidentally, driving an axis head-on into a limit switch is NOT "Fail-safe!" It's a recipe for a broken switch! The limit and home switch should always be placed to the side, where, if the axis over-travels, the switch is not in the direct path of the axis mechanics. My personal preference is an opposing LED light source and light activated Photo-transistor where, a flag attached at the end of the table or linear bearing (the moving part of the axis) interrupts the light beam - before the mechanical end of travel is reached. This is far more reliable and repeatable that a mechanical switch, or even a Hall-effect sensor.

    These ideas should be trivial to implement as, Mach3/4, LinuxCNC and GRBL, all provide a means to invert the logic of these inputs, so as to accomplish the methods I have just described.

    I hope this helps and, if further clarification is needed, I'll be happy to try to re-word what I've described.

    Happy CNC'ing!!!
     
    Rick 2.0 likes this.
  3. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder

    Joined:
    Aug 6, 2013
    Messages:
    784
    Likes Received:
    362
  4. Rosenwasser Benny

    Rosenwasser Benny Well-Known
    Builder

    Joined:
    Mar 21, 2017
    Messages:
    21
    Likes Received:
    2
    Thank you very much for the explanation, it is clearly written and understandable, also the grandma story is something I will remember me.

    So this means that the 'old school' NO limit switches circuit as I thought to install is certainly not the best way to proceed.

    I will start without the limit switches and later go for the optocoupler version like described on Wiring Limit Switches · gnea/grbl Wiki · GitHub

    Big thanks to Carl W. Livingston and David the swarfer !

    Regards, Benny
     
  5. Carl W. Livingston

    Carl W. Livingston Well-Known
    Builder

    Joined:
    Dec 12, 2016
    Messages:
    15
    Likes Received:
    8
    I'd still recommend the RC filter

    I tried drawing something using the text method I used previously but, I can't seem to find a "CODE" tab so I can better format everything. As such, the schematic is crude, but it is a functional circuit.

    Filtering can be simple, such as that shown above. Also, filtering can be very complex, involving all sorts of complex schemes.

    But even with highly complex filtering, fore-thought and planning the circuit layout goes a long way to electrical noise reduction.

    Some pre-planning concepts are:

    Use a good quality power supply with good internal filtering - especially if using a switching type power supply.

    In the following, Cap-Case is for emphasis.

    EACH STEPPER DRIVE UNIT MUST HAVE A DIRECT CONNECTION BETWEEN IT'S GND AND THE POWER SUPPLY.
    That is:
    DO NOT DAISY-CHAIN YOUR GND CONNECTIONS FROM ONE STEPPER DRIVE TO THE NEXT, TO THE NEXT, TO THE NEXT, etc.

    DO NOT SHARE LOGIC LEVEL GNDs WITH DEVICE GNDs THAT DRAW LARGE VALUES OF OPERATING CURRENT.

    KEEP ALL LOGIC LEVEL WIRING SEPARATE FROM DEVICE WIRING THAT DRAWS LARGE AMOUNTS OF OPERATING CURRENT.

    MAKE EVERY EFFORT POSSIBLE, AVOIDING PARALLEL CABLE RUNS COMPRISING LOW LOGIC LEVELS AND WIRING CARRYING LARGE CURRENT LEVELS.

    Additionally:
    USE SHIELDED CABLING WHERE THE ELECTRICAL NOISE IS HIGH. YOU CAN SHIELD THE STEPPER MOTOR WIRING BUT... IT IS MORE PRUDENT TO SHIELD THE LOW-LEVEL LOGIC WIRING.

    WHEN SHIELDING ANY CABLING, ALWAYS CONNECT THE SHIELD AT THE DRIVING SIDE. SO IF, SAY, YOU ARE CONNECTING A STEPPER MOTOR WITH 4-WIRE SHIELDED CABLE, CONNECT THE SHIELD AT THE STEPPER MOTOR DRIVE SIDE - NOT THE MOTOR SIDE. THE SAME APPLIES FOR LOGIC LEVEL SIGNALS.

    WHERE POSSIBLE, PROVIDE A SIGNAL/RETURN PAIR IN THE SHIELDED CABLE. CONNECT THE RETURN WIRE TO THE SIGNAL COMMON. THIS IMPLIES A SEPARATE SIGNAL/RETURN SHIELDED CABLE FOR EACH SIGNAL

    IF COST ISN'T THAT BIG OF A FACTOR, USE TWISTED-PAIR SHIELDED CABLE FOR FOR INDIVIDUAL LOW-LEVEL LOGIC SIGNALS. THIS WILL PROVIDE SUPERIOR COMMON-MODE NOISE IMMUNITY.

    While some of this stuff may sound like "Over-kill", if you want maximum reliability against electrical noise, these things will put you ahead of the curve.
     
    #5 Carl W. Livingston, May 2, 2017
    Last edited: May 2, 2017
    David the swarfer likes this.
  6. Carl W. Livingston

    Carl W. Livingston Well-Known
    Builder

    Joined:
    Dec 12, 2016
    Messages:
    15
    Likes Received:
    8
    So, I could not create a satisfactory schematic using crude text so, I created one with Fritzing.

    NC-Contact.jpg

    The Left-most 1N4148 diode (D1) provides quick discharge of the 0.1uF capacitor when the NC contact makes.

    The 100K Ohm resistor and 0.1uF capacitor form the filter.

    The 10K Ohm resistor and two Right-most 1N4148 diodes (D2 & D3) provide a measure of "OVER" and "REVERSE" voltage protection.
     
    #6 Carl W. Livingston, May 2, 2017
    Last edited: May 2, 2017
    David the swarfer and Rick 2.0 like this.
  7. Rick 2.0

    Rick 2.0 OpenBuilds Team
    Staff Member Moderator Builder

    Joined:
    Dec 20, 2013
    Messages:
    1,464
    Likes Received:
    603
  8. Carl W. Livingston

    Carl W. Livingston Well-Known
    Builder

    Joined:
    Dec 12, 2016
    Messages:
    15
    Likes Received:
    8
    Looking at the schematic for the newest x-Pro v2 controller, X_LIM, Y_LIM and Z_LIM go directly from the terminal block of each respective axis, directly to the Mega328P inputs, save the solder selection jumpers for Z-LIM.

    There is +5VDC available at the terminal block that provides the STOP, PAUSE, ABORT, etc. Each axis terminal block has a GND screw terminal, right beside the associated axis limit input.

    So, all of the connections - +5VDC, GND and the respective axis limit input, are all easily accessible.

    It would be a simple matter to to get a piece of perf-board and build three identical circuits with point-to-point wiring.

    I do plan on laying out a PCB, at some point but, right now, other projects are more pressing because they involve someone else's money.

    Now that I have checked that part of the x-Pro circuitry out, the fact that I see absolutely no input protection or filtering on the x-Pro PCB, users of the x-Pro need to provide some form of protection and noise filtering.

    Incidently, the command for inverting the X_LIM, Y_LIM & Z_LIM inputs with GRBL v0.9 is:
    $5=0 (limit pins invert, bool).

    Oddly, I found no such command that facilitates axis limit switch inversion in the GRBL v0.8 setup structure .

    It should be noted that, a CNC control system running stepper motors really isn't much better than a current day automobile, CNC's using stepper motors for axis positioning are saturated with electrical noise because of switching the high inductive loads of the stepper motor windings.

    And, it should be understood that automotive manufacturers go to great lengths, suppressing electrical noise - especially since a typical automobile could have a couple dozen embedded microcontrollers handling both, critically important and mundane tasks.

    There is nothing special about the circuit I have provided above. It's textbook stuff - at least in the areas of electronics where I work. You are free to use it, at your pleasure.
     
    #8 Carl W. Livingston, May 3, 2017
    Last edited: May 3, 2017

Share This Page

  • About Us

    The OpenBuilds Team is dedicated helping you to Dream it - Build it - Share it! Collaborate on our forums and be sure to visit the Part Store for all your Maker needs.


    [email protected]

  • Like us on Facebook

  • Support Open Source FairShare Program!

    OpenBuilds FairShare Give Back Program provides resources to Open Source projects, developers and schools around the world. Invest in your future by helping others develop their future.

    Donate to Open Source