High power loads and modular designDr Nathan Scott & Dr Hiroyuki Kagawa · July 2002 As your confidence with the AVR increases, you may wish to start controlling large electrical loads such as big motors, or even electrical appliances that run on mains power. Mains power safety and responsiblityLet me say up front that only a licensed electrician can build and turn on any circuit that runs on mains power. There are good reasons for this law, which exists in every civilised country. Up till now we have worked only with low voltages such as 5 or 15V DC. These voltages are very safe to work with (I won't say harmless because, believe it or not, injuries are still possible). Mains voltages, on the other hand, can cause instant death if you touch them. All it takes is one wrong connection or one loose wire, and death, fire, or serious injury could result. We have to distinguish here between the process of design and the process of construction. Anyone can design a mains electric circuit, after all, a plan by itself can do no harm. However only licensed electricians can build the design and plug it in. I want to tell you how to control mains power, but you must not try to breadboard or build the circuits that do so. If you need such circuits you will have to draw the circuit diagram and then pay a licensed electrician to build them for you. He or she will give you a result which is sealed in an insulated box and offers the same level of safety as commercial electrical devices such as televisions, washing machines etc. |
|
Figure 1: A typical relay. This one has a 24V DC coil (although it would probably work on less) and can switch mains power at about 15A.
|
The AVR can only deliver about 40mA to a load directly. This might be enough to energise the coil of a small relay. However it is probably a good idea to use a single bipolar or FET transistor to drive the relay as shown in Figure 2. |
Figure 2: Using a relay for low speed, high power switching
|
The resistor protects the AVR from high voltages which
could happen if the transistor fails. It also protects the
base of the transistor from damage if the signal input is
accidentally driven too high. The input
impedance of the base of the transistor is quite high
and very little current will flow into the base, so there
will be only a small voltage drop across the 10k When the signal input is driven high by the AVR, the transistor B "turns on" and the resistance from C to E becomes quite low. It isn't quite a short-circuit, it will have a resistance of a few hundred ohms. The resistance is low enough that a large current flows from the coil supply, through the coil, to GND. This energises the electromagnet and switches the relay on. A mechanical spring (not shown in the figure) opens the relay switch when the coil current is switched off again. Relays are quite complex electro-mechanical devices (see Figure 2) but because they are mass-produced in huge numbers, the cost is very reasonable. The one shown in Figure 1 was worth about $USD3 in 2002. Relays can switch a large machine on or off at a frequency of perhaps once or twice per second. They are not intended for high speed switching use, so they can't be used for PWM style speed control. If you wish to control a large motor using PWM, a powerful version of the H-bridge circuit is needed.
|
|
|
Figure 3: A small transistor driving a large one (sometimes called a cascade).
|
You might like to breadboard the circuit of Figure 3 and check that you understand how it works. The signal at A turns on transistor B, so its resistance becomes low. This pulls point D LOW, which in turn switches on the power PNP transistor (remember, PNP transistors need a LOW signal to switch on). When the PNP power transitor switches on, it pulls its collector C HIGH very strongly. This is effectively the same as switching on power to the load. By looking at the data sheet for the power transistor 2SB834 we see that it can deliver a current of up to 3A and it can survive a supply voltage of 60V. That means it could (in theory) deliver 60 X 3 = 180 Watts of power to the load! However the data sheet for the 2SB834 suggests that if we try to drive it at the maximum current and maximum voltage, the transistor itself will need to dissipate 30W of heat. So in fact we could only ever drive a 150W load.
|
|
Figure 4: 50V, 3A half H-bridge circuit with dual logic inputs.
You might like to build the circuit of Figure 4. If you do, be sure to check each of the transistors as you go so that you are sure that they are working, that you have the correct type (PNP or NPN) and that you know what the three legs are (E, C or B). I use the tests in Figure 5 on all transistors before putting them into a circuit like Figure 4: |
Figure 5: Tests for bipolar transistors. VCC should be 5 to 10 Volts.
Testing an NPN transistorWhen switch A is connected to GND, the base B is driven
LOW. This means that the transistor is OFF and the
resistance from C to E is HIGH. If the resistance from C to
E is much higher than 1k When switch A is connected to VCC, base B is driven HIGH. This turns the transistor ON and the resistance from C to E becomes LOW. Test point A should be pulled to a low voltage near GND. We say
Testing a PNP transistorWhen switch B is connected to VCC, the transistor is switched OFF and the resistance from E to C is HIGH. Therefore test point B should be near GND voltage. When switch B is connected to GND, this turns the transistor ON and the resistance from E to C becomes LOW. Test point B will be pulled to near VCC i.e. a HIGH voltage. We say
|
Figure 6: Schematic circuit diagram for a full H-bridge made out of two circuits like Figure 4.
WarningThe circuit of Figure 6 is driven by two logic level input signals. This means that there are four possible combinations of input:
Because of the seriousness of the problem of incorrect drive signals, we must implement several protective mechanisms:
Have a look at the circuit of Figure 7. Don't panic, it's not as bad as it looks. |
Figure 7: NAND interlock
|
First of all, note that the wire labelled "Signal GND" in Figure 4 has been replaced with something called "Signal Common". This wire is now at VCC. Because the NAND inverts its output signals, we must now drive the optocouplers in a new way: |
Figure 8: Explanation of "Signal Common" in Figure 7.
|
Now consider the functions of the 74LS00 Quad NAND gate. NAND is a boolean logic operation. If we have two logic values A and B, then the NAND gate will compute NOT (A and B), which in C language notation would be !(A && B) for booleans and ~(A & B) for bits. The 74LS00 Quad NAND gate has four independant NAND circuits inside it. The NOT function of the gate can be used by itself, this is illustrated in Figure 7(D) where one of the pins of the gate is fixed to logic high. That NAND circuit has become a NOT circuit. Pin 8 of the chip is now always the logical opposite of pin 9. If we follow the green line back to the AVR we see that it is called the direction signal. This will be a signal sent by the AVR when it wants the motor to run clockwise. The two NAND gates A and B have a common input which is the PWM signal from the AVR. The other input to each gate is determined by the direction signal as explained above. The result of this arrangement is like a distribution system for the PWM signal. If the direction signal is HIGH, the PWM signal is directed to half bridge 2; if it is LOW, the PWM signal goes to half bridge 1. Remember, "signal" now has a new meaning, refer to Figure 8! The safe (off) input condition for the full bridge is now "BOTH INPUTS HIGH". The forbidden condition is now "BOTH INPUTS LOW". The way the NAND gate is wired ensures that the new forbidden condition can't happen. The NAND gates are being used as an interlock, which means a connecting link that prevents forbidden system states.
|
Figure 9: Schematic view of the circuit of Figure 7
|
Suppose that we wish to make money by selling system components rather than complete systems. The chips we have been using, such as the AVR and 74LS00, are examples of system components, and it is clear that someone has been making money by selling them. Each component that is for sale must have an interface, a connection to the outside world. The interface of an electronic device is the main topic of its data sheet. Our Power Module might make a good component for sale. But what would we write in its data sheet? At the moment we would have to write a big warning! Because at the moment it is still possible to damage the Power Module by putting the forbidden signal combination (both LOW) on the input terminals! I think that the user of the module would not like to see such a warning, they would think that we (the designers) had not been very thoughtful. We can improve the modularity of our design by rearranging the system components like this: |
Figure 10: Improved modularity: the interlock is now part of the power module
|
The NAND interlock is now an integral part of the Power Module. In practice it would be installed on the same circuit board as the transistors. This design improvement protects the Power Module from incorrect input. Whatever signals are put in (at the plugs on the interface, the dotted line in Figure 10), the Power Module will function correctly. The design of Figure 10 does have the disadvantage that we must now generate a regulated 5V signal for the NAND chip on the Power Module circuit board. But, you say, "why not run another wire from the Logic Module and give the Power Module a small amount of regulated 5VDC?". If electrical isolation is not important then this would be an acceptable approach. However I am trying to train you in good practices. Trust me, we must try to get complete electrical isolation between the Logic Module and the Power Module, this will improve safety, reliability, modularity, customer relations and marketability. Isolation means we cannot have any direct electrical connections that bypass the optocouplers between the modules. It is easy and inexpensive to generate a small amount of regulated 5V power within the power module, this can be done with a LM317L minuature voltage regulator worth only a few cents. You may have noticed that I have swapped the function of the input pins on the Power Module again. If we are going to redesign the circuit to match Figure 10, we may as well also make it so that the input to the power module is GND rather than some obscure thing like "Signal common". Everyone understands what GND is! |
|