Solid-State limit switch experiment


Page 1 of 3 123 LastLast
Results 1 to 20 of 45

Thread: Solid-State limit switch experiment

  1. #1
    Registered Swede's Avatar
    Join Date
    Dec 2003
    Location
    United States
    Posts
    383
    Downloads
    0
    Uploads
    0

    Default Solid-State limit switch experiment

    For everyone interested: I did a quick experiment today using a hall-effect device to replace the mechanical microswitch currently in use in my bench mill. The test objectives were to see first if a simple circuit would actually work, and second, to see how repeatable the action of the device would be. This latter is important, as a consistent home function on your mill will help with batch operations and fixturing.

    My mill uses 1000-line servos, Flashcut control, ground ballscrews (2mm pitch C3 grade), THK rails. For the test, I increased the resolution of the system to its best, which was 0.00005". The Flashcut system uses digital servo drivers (Logosol) so I am able to jog and move about by "step" which equates to a single line on the encoder wheel.

    When homing in Flashcut, the software is designed to report any deviation from the previous home operation. This allowed me to run a few dozen home ops in succession and check the results.

    The quick/dirty circuit: The system uses a hall sensor (several were tried) which acts as an open drain to a cheap logic-level N-MOSFET like a BS170. The entire test setup uses an external 5V supply, and behaves like a NORMALLY CLOSED microswitch.

    On the left is the hall chip, with built-in digital logic and hysteresis. It behaves like a simple NPN transistor. When the South pole of a magnet is in range, the transistor is "on", which dumps the charge on the MOSFET gate to ground, shutting off the MOSFET. This opens the line from the controller, and the controller senses an open circuit ("switch is tripped"). With no magnet, the MOSFET gate is pulled high with the 10K pullup resistor; the MOSFET conducts, and the controller "sees" a closed switch.

    Inside probably 95% of modern digital CNC controllers is a setup like that shown. Everything to the right of the vertical dashed line is part of the controller. One of the paired switch lines has a small potential... it is likely pulled high internally, and that line is tied to a uProcessor chip. The other switch wire is simply ground. When the two wires are continuous, like an NC microswitch, the wire to the uProcessor is near ground potential, and the uProcessor determines that the circuit is in its normal closed state.

    With this circuit, the CNC controller switch line that is pulled high is wired to the MOSFET drain, and the grounded line to the MOSFET source. The 470 ohm resistance is a safeguard against excess current if a component fails.

    On the Hall chip, pin 1 is Vcc, pin 2 is ground, and pin 3 is the "output" (open drain). Current through the hall cannot exceed typically 25 to 50 mA; this setup will draw ~ 1 mA.

    Similar Threads:
    Attached Thumbnails Attached Thumbnails Solid-State limit switch experiment-hallsw-jpg  


  2. #2
    Registered Swede's Avatar
    Join Date
    Dec 2003
    Location
    United States
    Posts
    383
    Downloads
    0
    Uploads
    0

    Default

    Part II:

    The circuit works very well! In the pic below, you can see the breadboard riding on my X-axis. A wafer neodymium magnet is mounted in a TDI mount.

    Experiments were run with three different sensors, a Micronas HAL506UA, a DN6852A, and a neat Motorola 2ss52M magnetoresistive sensor, very sensitive. Of the three, the 6852 was least sensitive, the HAL506 in the middle. All three showed excellent repeatability, with the 2SS52M the best, consistently re-homing to 0.0005" or better, MUCH better than a microswitch. A combination including a more sensitive hall device (2SS52M) and a weaker magnet showed the best accuracy and repeatability. The air gap when the hall triggered ranged from 0.2" to 1" or more. Further improvement came when I turned a steel round into a point (like a pencil), stuck the magnet on the fat end, and lined up the point with the device.

    The benefits of this circuit are many. I wouldn't use a mill with other than Normally Closed (NC) switches, either mechanical or like this, solid state. Any failure of a component will typically open the loop, causing the system to stop. No moving parts = better reliability. It is also more accurate than a microswitch. With a good setup, it should be VERY easy to adjust by simply moving some tiny magnets on a slim steel bracket.

    Drawbacks are that the setup must be powered, but most controllers have 5V available for external digital logic. This circuit is very crude at this point, and I'll need to brainstorm failure modes a bit to ensure that the circuit does, in fact, open with ANY component failure.

    Anyway, this was fun to mess with today. Maybe someone wants to do a bit more with it. I'm going to make an axis with this when the circuit is refined and quadruple checked. These components are very cheap. There's no reason why one couldn't have dual switches in seriesat either end of an axis, virtually guaranteeing a correct stop of an axis when a limit has been breached.

    Swede

    Attached Thumbnails Attached Thumbnails Solid-State limit switch experiment-hall01-jpg  


  3. #3
    Member
    Join Date
    Apr 2003
    Location
    Ohio, USA
    Posts
    1873
    Downloads
    1
    Uploads
    0

    Default Don't quit now!

    Very interesting Swede, keep up the post as you progress.

    When you first posted I suspected that accuracy would be very tight as similar switches are used on ABS brakes, ignition switches ets.

    Your good, real good

    Ken



  4. #4
    Registered Swede's Avatar
    Join Date
    Dec 2003
    Location
    United States
    Posts
    383
    Downloads
    0
    Uploads
    0

    Default

    Thank you Ken. I was thinking about the project today, and maybe I'll write a little PIC uProcessor code to manage limit switch functionality. An 8 pin PIC12C would do 2 axes, while a 14 or 118 pin larger flash memory PIC could do all three or more axes. A PIC processor would replace the MOSFET, you'd still need the hall chips and magnets, and would have an advantage in response and flexibility of function.

    One final option would be to have a super-minimal setup consisting ONLY of a hall chip. The magnet would be fixed right next to the hall, and the axis would interpose a sheet steel vane between the magnet and PIC. It would transition from NC to NO when the vane is blocking the flux.



  5. #5
    Gold Member Bloy2004's Avatar
    Join Date
    Oct 2003
    Location
    Sturgeon Bay, WI
    Posts
    927
    Downloads
    0
    Uploads
    0

    Default

    Hi Swede,
    I am in the very early stages of installing limit switches(I have none) and your super minimal setup option interests me....
    Does this mean the only moving part is the steel intercepter plate attached to the moving axis? If so, what exact hall chip is needed using gecko g320's and Mach2, and how would the circuit look?
    Since I have servos, and want to prevent runaway should communication be lost with the computer, I am also interested in "safety switches" where the switch is separate from the controller and wired directly through the power to the servo motors so any axis movement beyond a point will cut power and save a crash. This seems very important especially if the axis is moving toward a spinning lathe chuck. Are these setups you speak of related?
    Thanks so much for your output!
    John(bloy2004)

    Last edited by Bloy2004; 01-05-2004 at 10:44 AM.


  6. #6
    Registered Swede's Avatar
    Join Date
    Dec 2003
    Location
    United States
    Posts
    383
    Downloads
    0
    Uploads
    0

    Default

    Hi John!

    Each controller will be different. I am assuming your setup is a normally closed loop. Also remember I know just enough electronics to do some stupid things like this, but happily most of them work. Maybe someone smarter than me has more to say.

    The first thing I'd do is put a digital ammeter (Radio Shack) in line with the two limit switch wires on your controller and measure the current that your system generates. Mine has a current of 7.4mA.

    If the current is, say, 20mA or less (it should be) you are in luck, as any hall effect or cheap transistor can "sink" that much current, and can be used as a switch.

    Look at the minimal circuit. It has done away with the MOSFET; the hall chip is responsible for switching the current from your limit wires. Again this will only work for 20 mA or less.

    The system is wired using any handy +5V source, although most hall chips work in a range of 3 to 28V or so. If your controller has a spare I/O +5V line (many do) you can wire it directly. With the magnet positioned next to the chip (air gap of ~ 1/2") the hall is ON and the circuit is complete. Only the south pole works, and the HIGH line from the controller must connect to pin3 of the hall. The controller thus sees "closed", and the servos operate.

    A steel vane (anything which can block the mag flux path, say .75" wide, any thickness) is what moves, and when it is between the magnet and the hall chip, the hall is OFF, the circuit opens, and the controller says WHOA.

    Suitable Hall chips www.digikey.com would be the DN6852A, cheap and effective.

    Conditions which would cause the circuit to open: Loss of mag flux, or power failure to the hall chip. You could always mount a big panic switch in series, from points C to D, A to B, or both. The A to B line is the power supply to the hall chip itself. C to D is of course the limit switch line, and opening that will stop motion as well.

    I'd toss in a couple of resistors for safety, say a 220 ohm between A and B, which will limit the current if the hall fails internally to ground, and it wouldn't hurt to add another between C and D, as long as its addition doesn't cause the circuit to not work. Whenever you work with circuits, you always need to assume that something will fail internally and cause a direct short to ground. the 220 ohm R with a 5V supply would keep the current to 23 mA. If your supply is 24V, use a 1K resistor. Make the R's 1/4 watt. Ohm's law I = E/R where I = current (amps), E = voltage, R = resistance in ohms.

    The interesting phenomenon I saw with the hall setup is that normally when you seek home, the table moves until the switch is struck. It then moves opposite to clear the switch, then another, often software programmed distance further. With the hall switch, since there is an air gap, all you need to have your controller do is trip the switch, then back off until the switch closes again. Since these digital hall chips have hysteresis, you won't get nuisance trips in this case, and an additional movement away from the switch may not be needed.

    I am going to try making a PIC processor chip which can handle all limit switch activities for a 3 axis machine. It will be able to do a number of "smart" monitoring services, maybe have a line for a second panic stop, possibly some other I/O functions as well. A "kit" would consist of a single chip, 5 or 6 hall chips, some neodymium magnets, maybe a mushroom panic switch. Would anyone be interested in such a device?

    I hope this helps. Any electronic gurus PLEASE chime in. I don't want to steer anyone wrong with this stuff.


    Swede

    Attached Thumbnails Attached Thumbnails Solid-State limit switch experiment-hall2-jpg  


  7. #7
    Gold Member Bloy2004's Avatar
    Join Date
    Oct 2003
    Location
    Sturgeon Bay, WI
    Posts
    927
    Downloads
    0
    Uploads
    0

    Default

    Swede!

    Thanks LOADS! I just turned on this wireless computer after moving it down to the basement near the machine and saw your response. What a nice way to verify its wireless internet capabilities.
    Again! Your info is above and beyond what I was expecting..
    Let the experiments commence!
    John



  8. #8
    Registered abasir's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    361
    Downloads
    0
    Uploads
    0

    Default

    John,
    The feature you wanted (emergency limit switch?) could be handled by the PIC easily by monitoring the enable signal from PC (if any) and the limit switches. Trigger on either one can be used to turn off a relay controlling the servo power (without needing PC intervention).

    Swede,
    I've done some work with PIC (but not a guru, yet) I think you may need some caps and pull-down/up resistor on the IO line to prevent induced spike/noise from falsely triggering the PIC.

    Regards,

    Stupid questions make me smarter...
    See how smart I've become at www.9w2bsr.com ;-P


  9. #9
    Registered balsaman's Avatar
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    2139
    Downloads
    0
    Uploads
    0

    Default

    What I need is a wirelsess parallel port. Then I can run my cnc from the living room...

    Cool experiments. You must be retired..

    Eric

    I wish it wouldn't crash.


  10. #10
    Registered
    Join Date
    Jan 2004
    Location
    GTA CANADA
    Posts
    122
    Downloads
    0
    Uploads
    0

    Default

    I think you may need some caps and pull-down/up resistor on the IO line to prevent induced spike/noise from falsely triggering the PIC.
    IMHO
    one would probably also use standard debounce strategy in the pic code - multiple samples to confirm validity etc
    Dave

    maybe...


  11. #11
    Registered Swede's Avatar
    Join Date
    Dec 2003
    Location
    United States
    Posts
    383
    Downloads
    0
    Uploads
    0

    Default

    While my circuit engineering is not really strong, I feel pretty good with PIC code...I love working with PIC's, there is so much you can do. A single 16F876 (my favorite) can deliver PWM (DC spindle driver?), have multiple I/O lines, do ADC (analog/digital sampling and conversion), serial communication, tons of cool stuff. One chip can handle limit switches, drive multiple external AC devices using a SS relay, measure spindle temps, execute safety logic, basically limitless functionality.

    The posted circuits are very raw for sure. Abasir you are correct, a ceramic cap would help, and the second schematic fails to show the I/O line being pulled up internally (inside the CNC controller) like the first schematic. Both of these circuits are predicated upon the limit switch lines being digital logic, if they are not, it probably wouldn't work.

    Dave, your observation is very valid, but I suspect debounce logic it won't be needed, as the hall chips are in fact complex little suckers with their own internal logic, filtering and hysteresis. The schematics shown I simplified by making them look like a simple NPN drain for clarity. There shouldn't be any bounce at all, unlike a mechanical switch, but if there is a PIC can handle it.

    Anyway I'll keep plugging on this concept. Lots to think about. I did a lot of work with hall chips both as electronic breakers for model IC engine distributors, and as a sensitive tach on a 160,000 RPM model turbine. A single magnet disk inside the compressor nut would trigger a static hall chip, and a count of the pulses over a short period of time would deliver the rotor RPM. The max frequency capability of the hall wasn't even approached even at over 2600 pulses/sec. They're amazing devices.

    Swede



  12. #12
    Registered anoel's Avatar
    Join Date
    Apr 2003
    Posts
    470
    Downloads
    0
    Uploads
    0

    Default

    There shouldn't be any bounce at all, unlike a mechanical switch, but if there is a PIC can handle it.
    Even simpler... If there was any debouncing needed a simple 555 circuit can clean it up for a a buck or two... But there'd be no need in this application. because the hall effect switch is either open or closed. There is no variance in a Hall Effect switch like there is in a Hall Effect Sensor.

    When I built my coil winder I started out using a reed switch to trigger my counter. Nasty ugly pulses from the reed (Looking at it on a scope). I was able to clean it up to a fair degree with a 555 timer. But then I tried the Hall effect switch and the pluses coming straight out to the Hall were as clean on the scope as they were when I added the 555 to it at over 3,000 rpm. Even the puny kit built counter that I assembled could count very rapidly with hall device and it has no trigger debouncing like the Omron counter that I'm using now.

    Nathan


  13. #13
    Gold Member Bloy2004's Avatar
    Join Date
    Oct 2003
    Location
    Sturgeon Bay, WI
    Posts
    927
    Downloads
    0
    Uploads
    0

    Default Eric (Balsaman)

    Eric said:
    -What I need is a wireless parallel port. Then I can run my cnc from the living room...-
    ....off subject a bit....
    Yah! ...and a little cam to monitor visually the machine if so desired.
    When I had a 1961 used Piper Colt airplane, I wanted to install an LCD monitor on the instrument panel with a cam under the fuselage to get photos of the ground. But, I found out the costs to get permission from piper to make changes were high. Also converting the registration to "experimental" was costly too!

    ...back to subject...

    Abasir...
    This seems to be the answer to my "safety switch" dilemma as I know I will be leaving the machine to do something else and won't be there all the time to "hit" the emergency button.
    I've gotten so concerned about this "runaway" issue regarding servo motors. ....at least until I get some solid connectors between the motors and driver box.



  14. #14
    Registered abasir's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    361
    Downloads
    0
    Uploads
    0

    Default

    John,
    Why not do the following
    S1 & S2 would be your safety switches wired in series.
    M1 would be power connection to your servos (or controller?).

    Attached Thumbnails Attached Thumbnails Solid-State limit switch experiment-emsw-jpg  
    Stupid questions make me smarter...
    See how smart I've become at www.9w2bsr.com ;-P


  15. #15
    Member
    Join Date
    Dec 2003
    Location
    Dallas Texas
    Posts
    673
    Downloads
    0
    Uploads
    0

    Default

    Cool.

    Is there anything you can't do?



  16. #16
    Registered abasir's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    361
    Downloads
    0
    Uploads
    0

    Default

    I can't sign-up with PayPal
    I can't buy from e-Bay
    I can't get ultra-cheap slides like Balsaman :rainfro:

    Stupid questions make me smarter...
    See how smart I've become at www.9w2bsr.com ;-P


  17. #17
    Registered balsaman's Avatar
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    2139
    Downloads
    0
    Uploads
    0

    Default

    The above drawing is OK but NEVER isolate the motor from a powered drive in any circumstance. This is a great way to blow a drive. Cut the power to the Drive(s), not to the motors. Usually cutting the AC power before the power supply is the best bet.

    Having said that, I don't use the limit switches to do that. My limits are wired thru a breakout board to notify the software that something is wrong. The software stops the pulse stream to the drives. 99.99% of the time you will hit a limit because you goofed on the jogging or the gcode. The other .01% of the time it's due to a motor running away due to bad encoder etc. I guess if a motor ever "runs away" the axis will hit it's dead stop and the fuse will blow.

    Having limit switches cut power to everything makes it hard to jog "off" the limit switch so you can carry on with what you are doing.

    My e-stop button cuts off all power to the machine via the AC supply.

    Maybe the very best bet is double limits switches. One to stop the motors, another a little further down to shut the power off. Overkill IMHO.

    Anyways, we are off topic. Carry on Swede.

    Eric

    I wish it wouldn't crash.


  18. #18
    Registered abasir's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    361
    Downloads
    0
    Uploads
    0

    Default

    Points about cutting power noted. S1 & S2 are _safety_ switches which are separate from limit switches. S1 & S2 (placed at the axis extremes) can be in series with the e-stop.

    Yes, my apology to Swede too

    Last edited by abasir; 01-06-2004 at 10:38 PM.
    Stupid questions make me smarter...
    See how smart I've become at www.9w2bsr.com ;-P


  19. #19
    Gold Member Bloy2004's Avatar
    Join Date
    Oct 2003
    Location
    Sturgeon Bay, WI
    Posts
    927
    Downloads
    0
    Uploads
    0

    Default

    yes! This all started with Swede's TYPE of switch to use and how it configures. But, between Balsaman's warning about isolation of motorpower, Abasir's circuit, and Swede's hall switches, I'm sure the solution to my problem lies above!
    Carry on....!

    Last edited by Bloy2004; 01-06-2004 at 09:57 PM.


  20. #20
    Member
    Join Date
    Apr 2003
    Location
    Ohio, USA
    Posts
    1873
    Downloads
    1
    Uploads
    0

    Default

    You guys mostly lost me about 7 or 8 post ago, but I am enjoying the thread a great deal so don't stop now.



Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Solid-State limit switch experiment

Solid-State limit switch experiment