Monday, July 29, 2013

Dual limit switch... LM393 based.... designed by Fritzing

Dual limit switch... LM393 based....  
designed by using an application from Fritzing.org
Part number DN2013m07d28i001
( this article is being edited as of 2013m07d29... I may have taken a short break today  99guspuppet )

The following is circuit is very versatile and was designed using the application available at Fritzing.org  Comments are invited as long as they forward the learning process and don't attack my fragile ego.  Be a sophont.

Fritzing.org
Fritzing is a service based on a FLOSS ( open source ) application developed by a group based out of Germany.   A circuit is first designed and tested using a breadboard.  Then the design can be documented via schematic and a PCB can be designed.  Lastly the PCB can be made by a service provided by the Fritzing group.  When a circuit is shared  (as I have done here ) , other individuals can have PCBs made , or use the schematic or modify the circuit design.

I have no relationship with Fritzing.org other than as a user.


Overview of the dual Limit Switch
 The dual switch is based on an LM393.  This limit switch can be adapted to be a light sensor based switch ,  a temperature based switch , a voltage level switch or a dual combination of the previous sensing devices.

Theory of Operation
The schematic shown here was developed using the application at Fritzing.com.

There are two identical circuits in this design. Section #1 will be discussed and everything described about section #1 will apply to section #2.

Setpoint voltage
Two resistors ( R4p & RR5p ) form a voltage divider network.   The voltage created by the divider network is presented to pin 3 of the LM393.  Pin 3 is the plus input of the comparator.  If pin 3 is more positive than pin 2 of the LM393 , the output ( pin 1 ) will attempt to go high.  Since the LM393 has an output that is open collector , what happens is that the output driver goes *high* by turning off.  If pin 3 is less positive than pin 2 , the output goes low.  Adjusting the resistors allows one to create different setpoints.

Sensor network
Two resistors determine the sensor network.  They  are R6s & R7s.  A sensor can replace either resistor.  For example...  R7s can be a 10K resistor. We can put a 10K ohm thermistor in place of R6s.  A typical 10K ohm thermistor has a value of 10K ohms at 25 degrees Centigrade.  A typical thermistor has a negative temperature coefficient ( NTC ).  This means that as the temperature rises , the resistance of the thermistor goes down.  If the value of R6s is going down, then the voltage presented to pin 2 of the LM393 goes up.  We would expect 6V at pin 2 if the temperature was 25 degrees C.  This is because both R6s & R7s would be 10k and would divide the 12V supply voltage evenly.  As the temperature goes up , R6s goes down in value.  The voltage at pin 2 rises.  As the temperature goes down , R6s goes up in value.  The voltage at pin 2 drops.   At some point the voltage at pin 2 moves by the voltage at pin 3 and the LM393 output switches state.

Sensors you can use ( an incomplete list )
Diode as a temperature sensor     NTC  linear
      http://www.ti.com/lit/an/sboa019/sboa019.pdf
Thermistor as a temperature sensor    NTC or PTC ( $$$ )  available   non-linear
Copper wire as temperature sensor     PTC   linear
CdS device as light intensity sensor   NRC  ( negative resistance coefficient )
Photodiode as light intensity sensor   PCC  (positive current coefficient )

Sensors can be powered by current through a resistor , a constant voltage or a constant current.  Other possibilities exist as well.

Determining Hysteresis
Hysteresis is pretty handy because you can use it to stabilize a signal that might be otherwise jittery and noisy.  Hysteresis is used extensively in high speed and long distance signaling.  I include hysteresis on this circuit so that if a sensor is hovering near the trip point , the output will not flip on-off-on-off-on-off in a rapid and annoying fashion.  If you were using this circuit to turn a refrigerator on and off, it would be bad for the compressor motor to be turned on and off every few seconds.  Another way to deal with rapid cycling is to use a time delay.  I will discuss time delays briefly at the end of this section.   ( Some phenomena naturally have hysteresis... A magnetic transformer can have hysteresis.  Readers can feel to free to add examples in the comments section )

Now look at the schematic.  ( located later in this posting )
( This section has some minor math errors that I will correct 2013m07d30 )
Consider R3h , R4p and R5p.  I will call these Rh ( hysteresis ) , Rt ( top resistor ) and Rb ( bottom resistor ).  Rt and Rb are a voltage divider ( RbRt ) that feeds the positive input of a comparator.  If V+ is stable ( this is not always true ) , then the voltage will be ( [V+] - [VGND] ) * ( Rb / ( Rb + Rt ))I am ignoring the effect of Rh for the moment.  Since VGND is zero , presuming V+ is 12 VDC , Rb =10K ohm , Rt = 10K ohm, then the equation is ( 12 - zero ) * 10K / ( 10K + 10K )  ==> 6V.  ( This equation is a form of Kirchoff's law ).  If the voltage provided by the sensor voltage divider ( R6s and R7s ) were also 6V , then minor perturbations of the circuit would cause the LM393 output to switch back and forth between on and off.  By adding Rh , the voltage presented to pin 3 is the following:  
(( [V+] - [V3 ] ) / 10K ) - ( V3/10K ) + ( ( VOUT -V3) / Rh ) = zero      <== Kirchoff's law of currents into a node.   I am ignoring the small effect that the LED has on the feedback voltage.
 I will fill in the math in the next few days ...
After much dithering ...the result when Rh is 1000K ohms and V+ is 12V  ==> V3 is approximately   6  + VOUT * 0.005 .   Since  VOUT  can be 12V or zero , the set point is 6 ( 1+.01 ) volts going upward and it is 6 (1+ 0 ) volts going downward.  The comparator switches at 6.01V as the signal goes upwards and at 6.00V as the signal goes downward.  Making Rh 100K ohms would change this to 6.1V in the rising direction.  Making Rh 10K would make this 7 volts in the rising direction.

Skip the math
Another way of looking at this is that the output of the LM393 *injects* a feedback into the RbRt divider network.  This feedback is positive since the RbRt diver is connected to the plus input of the LM393.

Time Delay
 We can choose to say the following.... when the trip point is passed in either direction , the comparator output will flip but only after the trip point has been passed for a certain amount of time.  One way to accomplish this is to take the output of the LM393 and pass it through a delay circuit.  One could construct such a delay circuit with one of my favorite chips , the CD40106 / 74C14 hex Schmitt trigger inverter.   I will create a separate page with some of my favourite circuits based on this chip.  One can also put a capacitor from pin 3 to ground.  This will reduce the response time of the limit switch and smooth out the response.

References:
Hysteresis
https://en.wikipedia.org/wiki/Hysteresis  
Kirchoff's Law
http://en.wikipedia.org/wiki/Kirchhoff%27s_circuit_laws

As you can see , I like to use Wikipedia references , since they are under constant public review.

Determining Set Point
Using resistors

Introducing a current source  ....... and why
   http://www.ti.com/lit/ds/sbvs020/sbvs020.pdf  <==  precison current source  0.5%    ~ $4
   100ua means 1 volt through a 10K resistor   100 x 10**-6     times     10 x 10**3

How to connect a Driver   why are there LEDs ?
The LEDs are optional... you can toss them and put a jumper wire in their place.  I find LEDs to be a great option for debugging and monitoring a circuit.  The LEDs are part of the output function for this circuit.  They can help or hinder the attachment of driver circuitry to this board.

Connecting an SCR

Connecting a Triac

Connecting a FET

Connecting an opto-isolator



Why two connectors ?
Ease of connections....

Why install two capacitors ?
A low capacitance cap usually has better high frequency response.  A high capacitance cap has better low frequency response. 

Connectors
Some of the connectors in the Fritzing collection are seemly goofed up.  Sometimes the pads don't seem to be aligned properly.  Use them with care.  Also, I found that the connectors had artifacts that would interfere with the DRC ( Design Rule Checker ).  I don't what is going on exactly , I just know they are there.  

Fritzing Techniques   Colored wires ,  Symmetry , visibility
I use colored wired wires to show important circuit details.  In this circuit , most of the wires are colored.  Orange is used to indicate V+.  *Hot* colors such as Red , Orange , Yellow are often used to indicate positive voltages.  Green or Black are often used to indicate ground.  I used green.  Negative voltages ( there are none in this circuit ) are often *cool colors* such as  Blue , Purple.

Since there were dual circuits that were identical , I kept  Section one largely on the lower portion of the breadboard.  I think it is really cool that Fritzing allows the use of more than one breadboard and that wires can be run outside the breadboard outlines.

The easiest way to get a new *part* ( for me ) was to pick a generic part and use the editor to modify the text descriptions on the part.  For example, the generic 8 pin DIP is easy enough to make a copy of and then change the descriptions to make it into an LM393 dual comparator.  Take time to make sure the generic part seems to work correctly before using it as a basis for a new part.  Modifying graphics on a part is a little bit tricky ( I can't do it correctly yet ) , so start out with something simple to get some practice.

I had trouble throwing away ( deleting ) a part that I had made that was flawed.  It is still hanging around.

IMAGES
Below .... pinout of LM393


Below .....  Breadboard layout




Below   .... Schematic




Part Numbering
Some of the coolest things you can do on a project is design and order T-shirts.   Also come up with whacky names for your product.  Still, it is nice to have a model number that is unique ( no duplicates ) and easy to come up with.  I create a identifier as follows:  Start with a prefix of DN ( In my case this stands for Document Number ).  Not too many words have the sequence *DN* in them.  Next add the date...
2013m07d06 ( July 6th , 2013 .... my birthday ... yes I accept cards ).  This date format sorts correctly and no one is confused about interchanging month and day.  Lastly I add an item code such as *i001*.  It is easy to remember how many items you have created in any given day.  Putting it all together results in *DN2013m07d06i001*.   This a string that is easy to search for as it is very unique.  Even on the internet, there are not likely to be duplicates especially if your prefix is unique.  You can choose a prefix such as the initials of your name or your company.   Please don't use *DN* or *777*

NEXT UP
The next circuits I will add will be power supplies for the limit switch and driver circuits for switching AC and DC loads up to 240VAC and 600V DC.   These circuits will be available at Fritzing.org



keywords    99guspuppet   777LimitSwitch  777fritzing   777lm393comparator

No comments: