Tuesday, March 23, 2010

LCB #4, PART 2. SWITCHES, and high-level interfaces.

More on switches, and how to use high-level interfaces for reliable performance.                                                                                                                                                                             

In LCB#4, Part 1, I discussed "dry circuit" switches and how they can be easily and directly interfaced to  low-voltage logic.  "Dry circuit" switches are acceptable in this application because they do not require high contact voltage and current for reliable operation.

Unfortunately, there are many cases when a heavy-duty switch must be used.  Examples include oil- tight industrial switches, key switches, automotive switches, high-current relays, etc.  In this case it is necessary to switch high voltage and high current to keep the contacts clean.  In many systems there is a 24V DC supply available for driving loads and operating other devices, and this auxiliary supply can be conveniently used to provide the switching current.  Of course, the 24 Volts must be translated down to the logic voltage, which we will assume is 5V.  Please see Figure 1.



An almost OK circuit:
This circuit is acceptable for casual, non-critical applications.  The use of a relatively low-value pullup resister R1, connected to +24V, insures that the contacts will stay clean.  When the switch is open, the voltage at point A will be close to 24V, and the voltage at point B will be clamped to about 5.6V by the internal diode at the gate.  The value of R2 is not critical; high values may cause problems with leakage, and low values will not limit the internal diode current to a safe value.  20K-50K is usually OK.

The internal input diodes are usually rated at 10MA, and with the values shown the current will only be about 0.8MA.  This is OK when reliability requirements are not extreme.  Noise immunity is particularly good when the switch is open because of the low impedance at B provided by the forward-biased input diode.  When the switch is closed, the capacitor provides a low impedance at B.

If you are concerned about the internal-diode current, you may add a resistor in parallel with C.  Select the resistor to reduce the voltage at B, with the switch open, to equal the logic voltage.  The divider action will  improve, somewhat, the noise immunity when the switch is closed.

Although you can usually get by with this simple circuit, let's see what happens when when point A is hit with a static discharge.  This can easily happen because many switches are simply not provided with much insulation.  Since your circuit represents a ground, an arc can penetrate the switch and strike the contacts.  Assuming the "Human Body Model" (100 pfd charged to 5KV to 10KV or more), a discharge will raise point A to a high positive or negative voltage.   This will produce a high current (1/4A or more) through R2.  Most of the energy will be absorbed by C, but the input protection diode may still be briefly stressed with high current.

The above discussion is based on the fact that R2 will limit the current.  Unfortunately, this may not always be the case;  a high-voltage static discharge can merrily arc across R2 and produce a dangerously high current in the gate protection diode.  This can readily happen if a small SMT part is used for R2.

One solution is to use several resisters in series for R2, as shown in Figure 2A.  If you are using 1/4W resistors, use 3-4 in series; with SMT resistors, it is a good idea to use 5-6 in series.


A pretty good circuit:
                                                                                    
If this is a little clumsy, or if you are paranoid about static, you can use a transient protection element from point A to ground; this will clamp the discharge.  This could be an MOV, a transient-rated Zener, or even a neon lamp.  Just to add to your worries, remember that if you clamp the discharge you will be producing a fast, high-current transient (the spark), which can radiate RF and produce nasty transients in nearby circuits.  For this reason, you are often better off without clamping the transient and just carefully limiting the current via R2 (no spark).

There are other circuits which use additional diodes to prevent the gate's protection diodes from conducting any current at all.  An example is shown in Figure 3.


A really good circuit:



In this circuit, a large transient voltage at pt. A will be safely clamped, at pt. C, to about 0.7V above the 5Vsupply, or to 0.7V below ground.  The current will be limited by R2.  Resistor R3 is very important:  since the voltage at pt. C is likely to exceed the turn-on voltage of the internal diodes (if only by tenths of a volt), it is necessary to include R3 to provide current limiting for the internal diodes.  This is a very rugged circuit, as long as you use several resistors in series for R2.

Concluding, the circuits shown here are good for driving logic with big, ugly switches or contacts.  They also provide some noise immunity and conditioning for applications where the switches are located far away (up to tens of feet, depending on the environment; shielded cable may help).  However, they are not a substitute for opto-isolated circuits or line receivers that can reject high levels of noise.  More on this sometime in the future.

Don't forget contact bounce!!!!!!!

Friday, February 26, 2010

LCB #4, PART 1. SWITCHES, and how to interface them with logic.

More on switches, and how to build switch-logic interfaces that work reliably.                                                                                                                                                                             

In my last blog, LCB#3, I discussed switches and how contact material affects reliability.  A "dry" circuit is one where you are switching logic voltage levels at low current.  In these applications, a switch with gold-plated contacts is necessary, since there is not enough energy to burn through the oxide coating that will form on other contact materials.  At higher energies, however, gold plating will burn off and  you should use silver contacts.  See Figure A. 



Broadly speaking:

1. With low voltages and currents (for example, 5V and 20 MA) always use a switch with gold-plated contacts ("dry circuit" rated).  Most magnetic reed switches will also be OK, since their contacts are sealed in an inert atmosphere.
 
2.  With voltages greater than about 12 V and with currents greater then 40mA or so, there is enough energy to burn through the silver oxide coating. Therefore, silver contacts will provide reliable operation while gold plating would be destroyed.

3.  If your application is switching low voltages and very high currents (such as an automotive application), you are on your own because I don't know what to suggest.  This is, actually, a real problem: when was the last time you turned on a flashlight and it didn't flicker until you banged it on a table and cleaned the contacts?  The best solution in this case is often to use copper contacts with extremely high contact pressure and/or a lot of "wiping" action to keep the contacts clean.


Now, finally, we get to the circuits.  I'm going to discuss how to interface logic, or other electronic circuits, with different switch types.  Assume that CMOS gates are used, and I strongly suggest the use of a gate with a Schmitt-trigger input.

Case 1:  Switching a logic level with a "dry circuit" (gold) switch.  An example would be a miniature, on-board, tactile pushbutton of the type that is commonly used as a "reset" button.  In this case it is usually OK to use a relatively high-value pull-up resistor (1K to 22K or so) and wire the switch directly to the logic input.   See Figure 1.


 

Remember, however, that you may still have to contend with contact bounce (see LCB #1).

What is insidious about this circuit, however, is the fact that you no longer have a circuit with good noise immunity; this is because, when the switch is open, you have a relatively high impedance at the logic input-  equal to the pullup resistor.  As a result, fast transients (such as caused by a static discharge) can be easily coupled into the node. One solution is to simply add a capacitor across the switch contacts.  But...... ouch.......lousy idea; see Figure 2

When the switch in Figure 2 is closed, its poor little contacts will short the capacitor, producing a very high-current pulse.  These switches are often only rated for 10-20mA, and the gold plating can be quickly destroyed.  The solution is to add a resistor before the cap to limit the current.  See Figure 2A. 

 

 The added resistance also helps noise immunity by increasing the time constant and forming a low-pass filter.  This is of great value if the switch is located some distance from the gate, such as off the board on a front panel. A gate with a Schmitt-trigger input should definitely be used in this circuit, since the slow transitions should be squared up.  As a plus, you will then have a circuit which is immune to contact bounce; see LCB#1.

CAUTION:  THIS CIRCUIT WILL NOT PROTECT AGAINST STATIC DISCHARGE.  More on that in future blogs.


Case 2:  Switching a logic level with a general-purpose (silver or copper) switch. There are many instances where you have to generate a logic input from a switch that is not designed for "dry circuit" operation.  Examples would include rocker or slide switches, 120V wall switches, "micro switches", heavy-duty toggle switches, or even door-bell buttons.  In these cases, we have to configure the circuit so the switch is switching high voltage and current, yet level-shift down to the necessary logic level.

However, it is a beautiful day with fresh powder, so I am going skiing now.  I'm sorry, but you'll have to wait until next time for the solution to Case 2.  I hope you can stand the suspense. Until then.......


Sunday, January 17, 2010

LCB #3. SWITCHES, that's right, switches !

 A switch?  Pretty simple, right?  Make two wires touch, right?  Sorry, read on....
                                                                                                                                                                             


Many years ago I was called by a company that was experiencing problems with an industrial packaging machine.  It was a fairly simple product, with several motors, heaters, indicators, etc.  It was controlled by 5-volt CMOS logic configured as a simple state machine.  The inputs were sensors and a few front-panel "oil-tight" industrial switches.

The company's engineer showed me the product, gave me a schematic, and left for a few minutes.  When he returned, I said "I know what the problem is."   He replied, "What? I haven't even told you what the symptoms are".  Arrogantly, I said, "You don't have to; I know what they are."

He probably mumbled something under his breath, but he told me to continue.  I replied, "I bet that sometimes the front-panel switches work, and sometimes they don't."

He said, "That's exactly right; how did you know?"  I should have said that I was ordained with special powers by the spirit of Nikola Tesla.  Instead, I opened the schematic and pointed to the circuit that interfaced to the front-panel switches.  I have drawn this circuit below, in Figure 1.



                                                     Figure 1
 

It was immediately clear that the problem was that the big, gross, front-panel switches were not making and breaking enough current for reliable operation. Yes, "Use it or Lose it" applies to switches, -or at least "Use it with Lots of VA (volts x amps) or Lose it.

The problem is that switches have contacts.  Being metal, they are subject to formation of oxide films.  Naturally, switch designers try to select a contact material or plating which is optimum for their application.  For example, the oil-tight switches in my story were rated at something dainty like "10A, 600V."  To switch at levels like this, they use copper contacts plated with silver.  This is a great choice for big, hairy, high-power contacts.  Even though the silver will oxidize to produce a thin insulating film of silver oxide, the film is easily blasted away when the switch opens or closes in a high voltage, high current application.  Unfortunately, the designer of this circuit used low voltage and an extremely large pull-up resistor; therefore there was not enough energy to break down and burn off the oxide layer. Incompetence reigns again. 

During my lectures, I try to demonstrate this problem as part of my famous repertoire of exciting pedagogical moments.  However, in the past I usually embarrassed myself in front of the class because a high-power switch will sometimes work on a low -energy circuit.  Then, at a garage sale I found a box of very old microswitches.  Eureka! These old switches are rated at 10A, 220V, and when I wire them up in a circuit like Figure 1, the contacts do not electrically close. since the switches have not been actuated for a long time.  If I raise Vcc and decrease the pull-up resister, the switch will eventually operate reliably.  Note that if a switch is repeatedly actuated, the "wiping" action may eventually clean the contacts, even at low voltages and currents.

So, what do you do with circuits and switches?  Well, if you have a "dry" circuit (less than a few volts and a few milliamps), you MUST use a switch with gold contacts; gold will not form oxide layers.  These switches can usually be identified because they have very low VA ratings, such as "0.4 A, 30V.  Keyboard or tiny board-mounted push-buttons are usually rated for dry-circuit operation.

If you must interface with a "standard" push-button, toggle, or microswitch with silver contacts, you will have to present high voltage and current to the switch.  However, since your circuit is probably 5 or even 3 volts, you will require a special interface circuit.

The exciting conclusion will follow in an upcoming blog.



Followers