This is a second chapter from my proto-book. I chose this article as it relates to a question the other day from Anonymous-532400 about designing circuits. While what I have done in this piece isn't exactly circuit design it is circuit modification and there are some parallels.
From Nothing to Something
Adapting a Chinese Kit to a Useful Application
This is a kit from a Chinese source that was advertised as a temperature alarm. For $1.88, including shipping, it caught my attention and a small quantity, of the kits, was ordered.
The components frame the schematic that was supplied by the vendor. The instructions for assembly are simply the screen printing on the small blue colored circuit board in the upper left hand corner. Assembly of the kit took about 20 minutes and the functional results were very disappointing. So there you have it $1.88 worth of worthless, ………… or maybe not.
If a little challenge is enjoyable these cheap little kits can provide quite a bit of enjoyment. The first step from “Nothing” to “Something” was to verify that no mistakes had been made in the assembly. Using the schematic for a guide each component and connection was checked and rechecked. While the unit, under power, was showing some signs of life it was very difficult to get the unit to switch from standby status to alarm status. Extreme temperatures were necessary at power up to induce one state or the other. Once the alarm or standby state was set it was impossible to get the circuit to flip back to the other regardless of the temperature of the thermistor sensor.
Before proceeding it is necessary to understand the concept of “Hysteresis”. Hysteresis is the name that is given to the manner of change in a system as it moves back and forth between two different states.
A good example of hysteresis is the manner in which a heating system in a home works. The thermostat on the wall is set for a specific temperature say 22 degrees C. As the temperature in the room drops to 22 C the furnace begins to run. If there were no hysteresis in the system the furnace would then shut off again immediately as the set temperature of 22 C would have already been met. Once the furnace stopped running it would immediately start again and then stop again. This process of start and stop would continue since the start temperature and the stop temperature are the same. This doesn’t work very well and is impractical and annoying to say the least.
To make the furnace work properly hysteresis is engineered into the thermostat. With hysteresis the furnace may turn on at 22 C and run until the temperature in the room is measured to be 23.5 C, at which point it shuts off. The room temperature then drifts until it once again drops to the level of 22 C and the furnace once again powers up. The 1.5 degrees C between the 22 C turn on and the 23.5 C turn off is the hysteresis of the system.
The previous picture is a graph of the hysteresis that we described for the furnace example. At 22 degrees C the furnace turns on and the red line jumps to the ON level. Once the temperature reaches 23.5 C the blue line drops to the Off level, the furnace turns off and the temperature drifts back towards 22 C where the cycle will be repeated.
One of the problems in the original design of this temperature alarm circuit is that the hysteresis is way too large. If the circuit is in the off state the temperature has to be raised above the temperature range that the thermistor can properly sense to get it to flip to the on state and once it is on the thermistor can’t be cooled down enough to get it to turn off again.
Here is the original schematic that was supplied by the vendor of the kit. The resistor that has been circled in red is what is known as a feedback resistor and in this case it is what controls the hysteresis of the circuit. When the state of the circuit moves from OFF to ON this resistor sends some voltage back from the output of the circuit to push the input further into the ON state. Likewise when the circuit moves from ON to the OFF state this resistor pulls some voltage from the input to push it further into the OFF state. This Push – Pull action of the output voltage on the input voltage creates the hysteresis. The designer of the original circuit chose a 39K resistor for this job but a 39K resistor transfers way too much voltage and makes the circuit stick in one state or the other.
The solution to this problem is to raise the resistance of R2 until the hysteresis comes down to the desired level. If we go too high though we will lose hysteresis and the alarm will flip from on to off too easily and it will oscillate. After a little experimentation it was determined that changing R2 to 100K ohms brought the hysteresis into a 2 degree C range. This meant that if the alarm turned on at 20 C it would turn off at 18 C.
The process for determining the value of R2 is interesting. An engineer may choose to take out a piece of paper and do the math and calculate the value of R2 or he may use a circuit simulator like LT Spice to do a computer simulation so that different values can be tested. An old technician like me however, pulls one value of resistor out of the circuit and substitutes another until the circuit does what is expected of it.
Now we have the circuit one step closer to being useful but there are still a couple of problems remaining with the original design.
The first problem is that Q1 is directly coupled to Q2 and at some values of the variable resistor RP1 the base current of Q2 becomes too high and it may be damaged. We will ameliorate this problem with a resistor at “B”.
We can have the same problem with the PNP transistor Q1 if the variable resistor gets turned close to zero ohms as this puts 3.3 volts across the emitter base junction. The solution will be to insert a limiting resistor at “C” so that no matter how low RP1 is turned the new resistor will limit how close the base of Q1 can be brought to ground.
The final problem is that there is no current limitation on the LED D1. When it is turned on by the saturation of Q3 the current is only limited by the internal resistance of Q3. This problem will be solved with a current limiting resistor inserted at “A”.
We will use an engineer’s approach to calculate the value for the resistor to be place in series with the LED at “A”. Our power supply for this circuit is 3 volts and the LED will have a junction voltage of about 2 volts. This leaves one volt across the transistor Q1 and our resistor at “A”. Most LEDs are quite happy to operate at 10 mA so we are going to use Ohm’s Law to calculate a good value for “A”. If we take the one volt across it and divide by 10 mA we get a value of 100 ohms. Resistor RA = 100 ohms.
To determine the values for the resistors at “B” and “C” we will revert to a little trial and error. To make the experiments necessary the circuit is bread boarded.
Electronics is thankfully an art. This allows non-engineers, like me, to miss perfection and still get it right. While the Q2 transistor will operate on less than 3 mA I wanted to be sure that Q1 will be able to pull it into saturation. This means that I want Q2 to act like a switch and be fully turned on when Q1 is turned on and fully off when Q1 is turned off. I have decided to use a 1K resistor for Resistor “B”. Unless there is trouble getting the circuit to work properly RB has been chosen to be 1K ohms. This may not be the optimal value for this resistor but as long as it works it is a good place to start.
The resistor at “C” will be determined empirically. This means experiments will be run to get the correct value. We begin by putting a mA meter in series with the Emitter of Q1. This test is run with the thermistor Rt at room temperature. Next, with the power applied to the circuit, the variable resistor is slowly turned down towards 0 ohms until we see the maximum current that is tolerable for the emitter base junction of Q1. The power is then removed from the circuit and an ohmmeter is used to measure the value of RP1. This is our absolute lowest value that we want for resistor Rc. To be on the safe side we chose a value that is greater than this measured value. After some experiments a value of 2.2K has been chosen for Rc.
The bread board has been modified to include the resistors at “Ra”, “Rb”, and “Rc” and a revised schematic has been drawn.
Testing with the bread board confirms that we now have a hysteresis of about 2 degrees C. We can adjust the alarm point of the circuit using RP1 from well below room temperature up to approximately 50 degrees C.
Do we have something yet? The circuit is at least back to the point where it operates as advertised by the Chinese vendor that sold it to us but we are going to take this circuit one step further and give it a practical application. The plan is to use the basic design of this circuit to sense a temperature rise on the heat sink of a Bench Power Supply and to turn on a cooling fan when the temperature of the heat sink gets above the point that we have chosen using RP1.
Here are the design challenges that we face in this next step. It is unlikely that we will find a fan with adequate power for this job that runs on 3 volts. A 12 volt fan is a much more likely choice. This alarm circuit that we have worked on to this point does a good job of turning on an LED and a small buzzer but it is inadequate to handle the current demands of a 12 volt fan motor so an additional circuit will need to be designed to drive (handle the power) for the fan.
We will have to have a 12 volt power supply for the fan itself. This power source will be designed to tap into the primary voltage supply of the Bench Power Supply itself. In addition we will still need a 3 volt power supply for the temperature alarm circuit. Finally, an interface circuit will be needed to tie the fan driver circuit to the temperature alarm circuit.
When we are finished the thermistor RT will be put on an extension wire and attached to the heat sink of the power supply. Three volts will be supplied to the alarm circuit and 12 volts will be supplied to the fan driver circuit. When the temperature of the heat sink exceeds the temperature we have chosen by adjusting RP1 the alarm circuit will change state to “ON”. This “ON” state will no longer make the buzzer sound as it will have been removed and replaced with an interface. The interface will turn on the fan driver and cause it to apply power to the fan. The fan will start to blow cool air on the heat sink which will cool the heat sink below the temperature where the alarm circuit returns to the “OFF” state.
In preparation for designing the fan driver and interface we are going to remove the buzzer that came with the original Chinese circuit and substitute a resistor. The fan will probably make enough noise when it runs and the if the buzzer were left in the circuit it would be annoying. The purpose of the resistor is to simulate the presence of the buzzer in the circuit. The buzzer affects the voltage on the collector output of Q3 and this voltage in turn affects the hysteresis. After a couple experiments a 33K ohm resistor is selected. The circuit is again tested to make certain that it is still functioning properly.
There are many ways to proceed at this point and the choices are up to the designer. A classic approach would be to drive a small reed relay with the output of Q3 and use the switched contacts in the relay to turn the fan on and off.
A small reed relay such as this one can be actuated by as little as 3 volts and draws about 5 milliamperes. It consists of a coil wrapped around a magnetic reed switch. When current is applied and a magnetic field in induced the reed switch closes and, in our case, connects the 12 volt power supply to the fan to turn it on.
This time however, the approach that we are going to take with this project does not involve the use of a relay. Instead we are going to interface the alarm circuit to the fan driver circuit using a device called an Optocoupler. There are many varieties of optocouplers but the one that is going to be used in this project is an H11A1 Phototransistor optocoupler. This IC device has a built in (internal) LED that isn’t visible. The internal LED, when lit, shines on a phototransistor which has very high resistance when there is no light and quite low resistance when the LED is shining on it. The Temperature alarm circuit will turn on and off the internal LED of the H11A1 just as it turns on and off the LED on the bread board. By using the change in conductivity of the internal phototransistor we will be able to control the fan driver. As always a data sheet on the H11A1 has been down loaded so we can see its specifications and identify the purpose of each of its six pins.
Here is a portion of the first page of the data sheet. From the information in the data sheet we have learned that there is a 1.2 volt drop across the LED of the Optocoupler and that it will work well with 10 mA current. Since the voltage output of the temperature alarm circuit is 3 volts we will have to put a resistor in series with the opticoupler that will limit the current to 10 mA. Doing the math we find that there is 3V – 1.2V = 1.8V across this resistor. From Ohms Law we know that this resistance R = 1.8V / 10 mA. This works out to 180 ohms. While a 180 ohm resistor exists it isn’t common so we will use a more common 220 ohm resistor for the series resistor. This optocoupler has its LED between pins 1 and 2 on the IC. From the diagram we see that pin one has to be more positive than pin two so that the LED is forward biased and will light.
The H11A1 optocoupler has been installed on the bread board and the LED tied into the original Temperature Alarm circuit in place of the buzzer. On the top right corner of the optocoupler there is a small divot that marks pin position one. The numbering of the pins starts at pin one and proceeds around the IC in a
counter clockwise direction. Pin one has been tied to the positive 3 volt rail with the orange jumper at “A”. Pin number 2 at the “B” position is connected to position “C” through the series 220 ohm resistor. Position “C” is jumpered by an orange jumper to the collector of Q3 just like the buzzer was in the previous circuit configuration. Notice the 33K resistor (Orange, Orange, Orange) just to the left of the Red LED which is the one now substituting for the buzzer.
In order to test the optocoupler an ohmmeter has been hooked to pins 4 and 5 in the proper polarity. If the optocoupler is working properly the ohmmeter will read very high when the circuit is in standby and change to a much lower ohm reading when the alarm circuit is activated by heating the thermistor.
We have decided to use an extremely useful device called an N channel MOSFET to drive the fan. In this case it will be an IRLZ34. Once again a data sheet has been consulted to see what the pin outs are and if the specifications will cover our needs.
The MOSFET is going to be used in our case as a switch. N Channel MOSFETs have the unique characteristic that they can be turned on and off with voltage. If we hook the plus wire of the 12 volt fan up to 12 volts plus and the fans negative wire to the “D” drain of the MOSFET and then hook the “S” source of the MOSFET to the negative (ground) of our power supply we will be all set to use the MOSFET as a switch. As long as the voltage on the gate stays below 2 volts plus relative to the “S” source pin of the MOSFET the MOSFET will remain off and no current will flow. However as soon as the voltage on the gate rises much above 2 volts the MOSFET will go into saturation and make a very low resistance connection between the “D” drain and the “S” source effectively closing the switch and applying 12 volts to the wires going to the fan. Below you can see a schematic of the MOSFET and the fan as they will be hooked up. Our next step will be to construct a circuit using the phototransistor in the optocoupler and a resistor so that when the Alarm is in standby the voltage on the Gate of the MOSFET will be close to zero volts and when the alarm is activated the gate voltage of the MOSFET will be pulled well above the minimum 2 volt saturation point.
You will notice in the schematic that there is a diode called a flyback diode across the fan. This diode is reverse biased so that the power supplied to the circuit can’t flow through it. Its purpose is to protect the MOSFET and the circuit from voltage spikes that may be generated by the fan motor. Anytime a relay, motor or other inductive (having a coil of wire) device is used in a circuit a flyback diode is needed. Any spikes of voltage that the inductive load may create are safely shunted and not allowed to damage delicate electronic components.
The MOSFET in the preceding picture has been marked as have its leads with a G for Gate, D for Drain, and S for Source. The red + lead from the fan plugs into the 12 volt supply rail and goes to the fan and returns from the fan as the black negative lead. If the black lead were attached to the negative ground rail the fan would run. We however are going to attach it to the “D” Drain of the MOSFET and then tie the “S” Source of the MOSFET to the negative ground rail through the orange jumper next to the flyback diode. Now the MOSFET is in the circuit and able to control the fan when the proper voltage is applied to its Gate.
Now it is time to tie the MOSFET to the output of the optocoupler. The leads of the optocoupler have been labeled and if we refer back to the optocoupler data sheet we will find that the Pin 5 is the collector of the phototransistor. Pin 5 is connected to the 12 volt + rail through the yellow vertical jumper. Pin 4 is the emitter of the phototransistor inside the optocoupler and it is tied to the ground rail through a series 10K (Brown - Black – Orange) resistor. The node (connection point) between pin 4 of the optocoupler and the 10K resistor is also connected to the Gate of the MOSFET by the horizontal yellow jumper. When the LED in the optocoupler is off the phototransistor will be very high resistance and the 10K resistor will pull the gate down to the ground rail and the MOSFET will also be off. When the LED in the optocoupler is turned on by the Alarm Circuit it will cause the phototransistor to go to low resistance and this will pull the gate of the MOSFET high towards the 12 volt rail and subsequently the MOSFET will saturate and make a low resistance connection between “D” and “S” which will turn on the fan.
This is a completed schematic of our build which is now fully constructed on the Bread Board. Note that in the schematic there are only 4 leads showing on the optocoupler. This is because the correct symbol wasn’t available in the computer program. The leads of the optocoupler are properly numbered and the pin 3 and 6 are not used on the H11A1 in this application.
The bread boarded circuit should be thoroughly tested to verify that it is working in all ways. If there is going to be more experimentation or adjustment to the circuit now is the time to do it. Once we move the components from the bread board to the proto board where they will be soldered together it is much more difficult to make adjustments.
The bread board circuit has been tested and a video has been taken.
Now that we have an operational proof of concept (POC) the next step is to move the design to a more stable board with soldered connections. For most engineers this would be the time to use the circuit board CAD software and design a commercially fabricated board for the circuit.
My plan is to take a more hands on approach. To begin with the schematic and the bread board will be studied and plans will be made to compress the components into a smaller area. Some of this can be done on the bread board itself now that we know the totality of the build. Another approach that has been used many times is to take a sheet of plain graph paper and draw the layout of the board using the cross points of the graph as potential connection points.
The components are drawn on the graph paper using schematic symbols and their leads are terminated where the graph lines cross. Lines are drawn on a rectangular grid just like circuit board traces would be routed. The actual assembly of the components will be made on what is called Proto Board which is just a board with drilled solder pads laid out on a 1/10 of an inch grid. The graph paper is a larger scale than the proto board so it is important to keep the size of the symbols drawn on the graph paper to scale. If a resistor requires 3 spaces between nodes to physically fit it is necessary to reflect this on the drawing on the graph paper.
Here is a side by side example of a graph paper drawing and the actual construction on the proto board. The connections between the components that are drawn on the graph paper are actually made on the back side of the proto board where there are small solder pads for each hole. Since there are no traces on the proto board the wire leads on the components are bent over and soldered down to bridge the gaps and make the connections. Here is a front and back picture of the proto board.
Each hole has an assigned grid coordinate to make it easier to move from board side to side and from graph drawing to proto board while doing the assembly. Just a note of caution at this point regarding soldering to a proto board and creating traces using component leads. Experience has shown that it is very easy to get poor solder joints using this procedure. All soldering should be inspected under magnification and components need to be wiggled to ensure their leads are actually soldered properly.
Here is the graph paper layout for the circuit that we will build on the proto board. Note that it very closely follows the layout that we used on the bread board. We may have sacrificed some compression doing it this way but the maintenance of clarity is more important in this project than getting the circuit into a smaller box. Note how the resistors have been drawn as funny little “Vs”. This is to denote that we are going to stand them up on their ends to conserve space. The resistor R2 is drawn in Red and in the traditional way. This is my notation for a component that will be mounted on the reverse side of the board. Since this resistor has to cross traces and components to bridge the proper connections it will be able to do this without interference on the reverse side of the board. The row and column coordinates have been written in to match the layout on the actual proto board. We are going to leave one row of unused holes around the periphery of the board.
This means that we need a board that is 21 holes by 12 holes to accommodate the build. The proto board which comes with dimensions of 25 by 18 holes will be cut down by putting it in a vise and carefully cutting it with a fine tooth hack saw. Here is a picture of the board that will be used in this build all ready to be populated with components.
Using the layout diagram that was made on the graph paper and the schematic, the board has been populated with components. During the process a few adjustment were made to move the components slightly closer together which made room for two jacks on the board. The small 2 position JST mini jack on the left side of the board is where the Thermistor Sensor plugs in. The larger 3 position JST mini jack on the right is where the fan plugs in.
The red wire goes to the 3 volt power source and the yellow wire goes to the 12 volt power source. The black wire is the common ground between the two supplies. Here is a look at the reverse side of the board.
Can you see the 100K resistor that was drawn in red on the graph paper layout diagram?
Now after the unit was constructed and inspected power was applied to it and guess what? It didn’t work properly. Frankly, it is a cause for celebration when new builds work on first try. Four pages ago it was mentioned how easy it is to have a bad solder joint when creating traces like those above. Unfortunately the connection at B9 was not good and had to be resoldered. With this connection repaired the unit was again powered up and while it worked it did not work well. After a half an hour of measuring voltages and running further inspections the individual resistors were checked to see if their values were correct.
The resistor identified as R1 on the schematic, a 15 K, was found to be way out of specifications and had to be replaced. If you compare the picture of the front side of the board above and subsequent pictures you will see that the resistor is a different one. It is very unusual for resistors to be enough out of specification to cause a problem in the circuit. This was a very unlikely anomaly.
Once the resistor was replaced the circuit worked just as it had on the bread board. Here are pictures of the unit in standby and in the on mode.
There is a white wire attached to the thermistor sensor and plugged into the sensor jack. Notice the resistor next to the blue RP1 trimmer as it is the new one that replaced the one that was out of specification. In the picture below you can contrast the layout and size of the circuit on the bread board compared to the proto board.
It was important to point out that the process of doing electronics and building things does not always go smoothly. The mistakes and the time spent troubleshooting things that don’t work is part of the adventure. It is the challenge that makes the triumph when things do finally work such a sweet victory.
Now that the unit is functioning properly and ready to be installed into a bench power supply we can finally say that the “Nothing” that we began with has become “Something”.
Top Comments