Electronics > Beginners
Isolating switch lines
Muffins:
okay so I've tried to adapt the circuit for outputs as well. Please see attached diagram. In this case the servo motor has built in optocouplers other hardware might be used in its place.
The power supply and dc-dc converter is just based on what's available with a local supplier. 5W is overkill.
I'll do some reading up on ferrite beads today, I've never used them before.
max_torque:
Wow, that's a lot of effort, cost and complexity for a switch input....
(and sitill hasn't got any low pass filtering or debouncing in it)
The reason an optocoupler often "fixes" a noise problem is the fact that is has a relatively low input impedance. Unless you need to isolate ground potentials, then you gain nothing by using one, nothing that couldn't be gained cheaper and simpler anyway.
A typical microcontroller GPIO port has an input impedance to ground of substantially larger than 100,000 ohms (and it can be WAY more). That means that any current, even a tiny amount, that is pushed down into that port generates a large voltage (V = I x R ) Say you need 2v to trip into logic level high, at 100kohm, that's just 20 micro amps! So, if you don't put any circuitry in front of your input port, and the wiring to the switch picks up differential noise, then that noise only has to generate a tiny amount of current to falsly flag a high level at that port. And assuming we haven't got a wiring fault that actually allows a DC voltage offset onto the wiring harness, then the noise that is coupled in will be AC, and so without any low pass filtering, you will get a number of "high" triggers on the port.
Assuming you are using micoswitches, then your current system also does nt in anyway protect against contact bounce. Now sure, you can do that in software only if you want, but given that the circuit to help block bounce is a low pass filter, and you also want that to block AC noise, why not put in place some hardware to achieve both those aims!
What you need to consider is what frequency you want to be able to pass? For a limit switch, the actual "trigger" position will depend on lots of factors, the mounting of the switch, the precise tollerance of the switch and it's levers and arms themselves, and of course, how fast the carriage is moving itself. ie how far does it travel before the "switch tripped" signal registers. Now luckily, mostly for limit switches you don't actually care precisely when/where they trip, as they are just used to prevent the carriage running into the hard mechanical end stops. If you are however using those switches to set up or "zero" the system, then you need to ensure that the position at which the switch trips is repeatable. You probably still don't care exactly where it is, just that it happens in the same place each time. You will see many machines (3d printers, CNC mills etc) doing a rapid carriage traverse till they hit the end stops, and then moving back a short distance, and re-hitting that stop switch at a much lower speed in order to try to precisely and repeatibly estimate that end stop position
With this in mind, i'd personally use a 24v (or 12v) voltage to my switch, i'd then pass that voltage through a relatively low impedance voltage divider to ground to get a signal into the voltage range of the input port of my micro, and i'd include a suitable capacitor to form a low pass with the voltage division resistors, and a zenner or diode clamp to the rails, and then another higher value series resistor to protect the micro's own internal diodes. If i were really paranoid, you could include a zener in the switch input as well to push the voltage threshold upwards.
At 24v to avoid excessive power loss in the voltage divider, you'd want that resistance to be greater than about 2.4 kOhm, so assuming a 5v micro, i'd suggest a 2k input resistor, with a 470 ohm resistor to ground. Thats a nice low impedance for the switch to drive (and gives 10 mA through the switch contacts) and 24v input results in 4.7v at the output of the divider. For a typical TTL GPIO port, that means "high" occurs at inout voltages above about 13v, and "low" below about 4v.
If you put a 1uF capacitor after that divider, that's a low pass with a cut off (-3dB) at around 80Hz. You may need to experiment with this capacitor value to find the sweet spot in terms of blocking AC noise, but allowing a quick enough response for the real signal.
I'd also put a 4.7v zenner to gnd or use two diodes to clamp that point in the circuit to Vcc and Gnd
Between there and the micro pin i'd finish by adding a 10k series resistor to protect the micros port protection diodes.
So, that's 3 resistors, a capacitor, and a zenner (or two diodes) for a total cost of about, well, nothing really. No need for isolated supplied, optos or any of that stuff! :-+
Jeroen3:
People often use the shotgun method and go opto isolated while the majority of the problems are caused by high-impendant inputs! Those are easily fooled by the smallest amout of inductive or capacitive coupling due to interference from un-snubbed relays turning off or VFD's operating nearby.
Follow the standards. Get that current flowing before detecting a high!
Also reference material, although this does add input group isolation. Silabs AN970
Ian.M:
If you still need optoisolation on the inputs (and it does provide useful protection against damage from idiots shorting input ground to a high current AC or DC supply, which without isolation can easily blow the sh!t out of your controller as it burns the ground tracks off your PCB!), I suggest:
Put a polyfuse on the DC-DC converter output, after the shunt Zener where it can do some good if sensor Vout+ gets shorted to the motor supply. You probably don't need one on its input if the SMPSU feeding it is short circuit protected at a low enough limit not to burn any tracks off your board.
N.B. the shunt Zener on the DC-DC converter output should *NEVER* normally conduct, so check datasheets carefully and make sure that there is an adequate margin between its minimum breakdown voltage and the converter's abs. max. output voltage, allowing for tolerances of both. Its got to be beefy enough to trip the polyfuse without blowing, and once you are past a few tens of mA, you may need to use a unidirectional TVS diode instead of a Zener to get a high enough surge rating.
No comments yet on your output side optocoupling to the motors. Please link any applicable motor or driver datasheets!
Navigation
[0] Message Index
[*] Previous page
Go to full version