ELEC499 Design Project Report ChargeGuard 8 April 2010 Group 10: Brett Nelson Colter McQuay Geoff Costin Michelle Stephenson Supervisor: Dr. Amirali Baniasadi Table of Contents Abstract 1.0 Introduction Page 4 Page 4 Page 4 Page 5 Page 5 Page 5 Page 6 Page 6 Page 7 Page 7 Page 7 Page 8 Page 8 Page 8 Page 9 Page 9 Page 10 Page 10 Page 11 Page 12 1.1 Problem 1.2 Solution 2.0 Hardware 2.1 Overview 2.2 Power Supply 2.2.1 Design 2.2.2 Implementation 2.3 Relay 2.3.1 Design 2.3.2 Implementation 2.3.3 Improvement 2.4 TRIAC 2.4.1 Design 2.4.2 Implementation 2.5 Current Sensing 2.5.1 Design 2.5.2 Implementation 3.0 Microprocessor 3.1 Overview Page 12 3.2 Firmware Page 12 4.0 Future Expansion Page 14 Page14 Page 14 Page 14 4.1 Multiple Outlets 4.2 Integrated in Adapters 5.0 Conclusion 2 List of Tables and Figures Figure 1: Sony Charge Adapter Page 4 Figure 2: Canon Camera Charge Adapter Page 4 Figure 3: Motorola Charge Adapter Page 4 Figure 4: ChargeGuard Circuitry Page 5 Figure 5: Power supply by Microchip Page 6 Figure 6: Cosel Power Supply Page 7 Figure 7: Relay Page 8 Figure 8: TRIAC Page 9 Figure 9: TRIAC Circuitry Page 9 Figure 10: Hall Effect Sensor Page 10 Figure 11: Current Transformer Page 11 Figure 12: RMS to DC Circuit Page 11 Figure 13: RMS to DC Converter Page 11 Figure 14: Microprocessor Page 12 Table 1: States and Descriptions Page 13 3 Abstract When charge adapters for devices like mobile phones, camera batteries, and mp3 players are plugged into the wall, they waste power even without any devices plugged into them. ChargeGuard is an energy saving charging station for rechargeable devices; the finished product could be realized as a multiple outlet device, similar to a power bar. The final prototype for the project was a single-outlet version this product. The circuitry prevents leakage current by having a microprocessor monitor the current being drawn through the outlet. When there is only a small amount of current being drawn, the leakage current, the processor signals a latching relay to open and prevent the current from leaking. When a device is plugged into the adapter to be charged, the processor senses a larger current being drawn and closes the relay, allowing the device to charge normally. 1.0 Introduction 1.1 Problem Charge adapters are commonly used to charge mobile phones, digital camera batteries, and most rechargeable devices. The problem addressed by this project is that current is leaked through these charge adapters while they are not in use. Small leakage currents can accumulate to a significant amount of wasted energy. The purpose of this project was to develop a product to minimize the energy losses attributed to leakage current of devices. Some common charge adapters are seen in Figures 1-3. Figure 15: Sony Charge Adapter Adapter Figure 16: Canon Camera Charge Adapter 4 Figure 17: Motorola Charge 1.2 Solution To prevent current from being leaked through charge adapters, an intelligent charging station was designed and constructed. The device was designed to dynamically configure itself for any charge adapter. Using this data, it is able to sense when a device is drawing current from the adapter, in which case it allows the device to charge as it would normally. It can also sense when there is no device plugged in and reacts to prevent current from being drawn. The circuit itself was required to have very low power consumption, so as not to contribute to the wasted power. 2.0 Hardware 2.1 Overview To prevent leakage current in idle charge adapters, the device required some specific hardware components. A current sensing transformer was used to measure the amount of current being drawn from the wall at any point in time. This waveform then needed to be conditioned so it could be read by the microprocessor. An RMS-to-DC converter was used to condition the measured current to a DC signal appropriate for the microprocessor. The microprocessor uses a TRIAC to close the circuit every second in order to sample the current. This would theoretically allow the processor to sleep in between readings, rather than constantly measuring the current. When the system senses that current above the leakage threshold is being drawn, a latching relay is closed to allow the current to charge the device normally. A detailed circuit diagram of ChargeGuard is shown in Figure 4. Figure 18: ChargeGuard Circuitry 5 2.2 Power Supply The processor required 3.3 VDC, so a power supply was chosen which could convert 120 VAC to 3.3 VDC at a maximum of 2 A. The goal was to design a power supply which could provide the necessary voltage without the use of a transformer in order to minimize the overhead power required by the supply. 2.2.1 Design The first power supply chosen for the project was designed by Microchip for use with a light dimmer circuit. This power supply unit (PSU) was appealing because it involved no transformers and no switching, and it was composed entirely of passive components. As a result, it would have very low losses and would be fairly simple and inexpensive to construct. The circuit was designed using a full-wave rectifier followed by a Zener regulator to generate 5 VDC. The next stage was a pair of filters to clean the signal and smooth the voltage ripple. Since the circuit has no electrical isolation between the AC and DC sides, the circuit is protected through the use of a varistor which acts as a surge absorber. The supply was designed to convert 120VAC to 5VDC, so an additional 3.3V regulator was used to achieve the desired final DC voltage. This design can be seen here in Figure 5. Figure 19: Power supply by Microchip Upon construction, it was discovered that the current sourcing capabilities of the PSU (1.5mA) were extremely low compared to what was required (>300mA). Attempts were made to modify the design by changing the values of the RC current limiter in the circuit. The efforts yielded only marginal improvements in current source capability (3.4mA). Although the Microchip PSU offered appealing efficiency and low losses, it could not be used since it could not provide enough current. 6 2.2.2 Implementation In the interest of time, a pre-fabricated power supply was used which could convert 120VAC to 5VDC at 2A. The Cosel VAF1005 power supply, which was used, can be seen in Figure 6. This PSU was then connected to the 3.3V regulator to achieve the final desired voltage. This supply was found to be very stable and reliable, with a more-than-adequate current capacity. Unfortunately, it did exhibit undesirable losses with an efficiency Figure 20: Cosel Power Supply of about 74% and a current overhead of about 15mA. Despite the losses, this supply was still chosen due to time constraints of the project, in addition to the fact that the prototype was meant as proof-of-concept. Given more design time, a more efficient supply could have been developed which would meet current sourcing needs. In future revisions of ChargeGuard, a power supply similar to the one by Microchip would be designed. 2.3 Relay A latching relay was to be used as part of the switch circuit since it would be ideal for the charging cycle of the devices. This was because it would only need to be switched on at the beginning of the charge cycle and switched off at the end. The latching capability would allow the processor to switch the relay by applying a DC signal for an instant and then deasserting it; this would save power, and allow the possibility for the processor to sleep. 2.3.1 Design The Panasonic DK1A-3V-F relay was chosen because it is compact, inexpensive, and can handle 10A on the AC side; additionally, its coil is activated by a 3VDC signal at 66mA. It can been seen in Figure 7. Since the digital outputs of the processor could not handle more than 25mA, the relay was to be used in conjunction with a generic 2N3904 npn BJT in order to source the 66mA from the power supply. The processor could control the relay indirectly by switching on the BJT instead. 7 2.3.2 Implementation Upon receipt of the part, it was realized that the relay required a reversal of polarity of the DC voltage applied to the coil in order to alternate between switching it on and off. In order to accommodate this, the single BJT circuit was changed to an H-Bridge containing four BJTs. One pair could be controlled by one digital output, and the other could be controlled by a second output. Typically, a protection diode is placed across the coil of a relay in order to protect transistors and ICs from a brief high voltage that occurs when the coil is Figure 21: Relay switched off. With the implementation of the H-Bridge, a protection diode could not be used since current could flow through the coil in either direction. The relay and H-Bridge circuit was tested under the expected conditions without the use of protection diodes, and it was found that no damage was incurred in any of the components. Thus, this circuit was considered acceptable for use in ChargeGuard. 2.3.3 Improvement The design could be improved by changing the single-coil relay to a two-coil model, which uses one coil for switching on and one for switching off. This would allow for a reduction in components since the H-Bridge circuit would no longer be necessary. Furthermore, a protection diode could be placed across each coil since current flows through the coils in only one direction. 2.4 TRIAC For the duration of time in which ChargeGuard is not charging a device, the line needs to be sampled frequently to determine if a device has been connected. For this purpose, it was decided that using a low-power TRIAC circuit would be best since it could be switched quickly and quietly using very little current. Using a relay would have been undesirable since it would make a clicking noise every time it was switched, and it would consume more power during switching. Additionally, TRIAC circuits have very small switching times on the order of microseconds, whereas relays take milliseconds, effectively minimizing the sampling time. 8 2.4.1 Design The TRIAC circuit was designed using an opto-coupler TRIAC driver and a power TRIAC, which can handle 15A at 120VAC. The opto-coupler was used since it could be controlled using a small DC signal to active the internal LED, which also provides isolation between the AC and DC sides. The opto-coupler IC also contains a zero crossing circuit which serves to drive the power TRIAC. With TRIAC switches, it is typical to also use a series RC snubber circuit in parallel with the power TRIAC; this is done to protect against large voltage transients across the TRIAC, as well as to compensate for forward biasing problems caused by inductive loads. Several different snubber circuits were designed, but some issues arose which could not be corrected. The snubber tended to allow a small current to leak even when the switch was off; although small, it was still significant enough to invalidate the intent of ChargeGuard. Additionally, some snubbers caused loss of controllability in the sense that the TRIAC was always on and could not be deactivated by the DC signal to the opto-coupler. Figure 22: TRIAC 2.4.2 Implementation Overall, it was decided that a snubber would not be used with the TRIAC for the prototype since a suitable solution to the above issues could not be found and the TRIAC could still function without one. Given sufficient time, an acceptable snubber circuit could be designed. Figure 23: TRIAC Circuitry 9 2.5 Current Sensing Another important component of ChargeGuard is the current sensing circuitry. In order to determine whether the relay should be opened or closed, the microprocessor must be able to read the current being drawn through the outlet at any point in time. The current sensor needs to be able to measure low levels of AC current and condition the measurements for acquisition by the analog to digital converter. The required range of AC currents to be measured was between 0 and 200mA; furthermore, the analog to digital converter in the microcontroller required a 0 to 3.3 V input signal. 2.5.1 Design In order to measure the current, several options were considered. One method of current measurement explored was to insert a low valued series resistance in the line and measure the corresponding voltage drop across the resistor. The advantages of this method are three-fold: there is no lower limit for current measurement, the output voltage varies linearly with the current, and it is very simple and inexpensive to implement. This method, however, has disadvantages in that it continuously dissipates power proportional to the square of the current and does not provide any form of isolation to the interface circuitry or microcontroller. For this application, isolation and low power consumption are critical. Although only small voltages appear over the sense resistor, the potential at the input of the resister can be up to 120 V with respect to ground. This creates an indirect 120 V potential from the analog input of the microcontroller to the ground, which would destroy the chip Another option which was considered was the use of a Hall effect sensor, which would measure the magnetic field associated with a given current. For this specific application a suitable Hall effect sensor could not be found because all sensors either operated in a different frequency or current range. Figure 24: Hall Effect Sensor 10 Electrical isolation can be effectively achieved through the use of a current transformer. A transformer used for current measurement also steps down the current, reducing the wasted energy by a factor proportional to the turns ratio. The stepped down current is fed through a resistor and the resulting voltage (0 – 3.3V) is sampled by the microcontroller through a RMS-DC converter. 2.5.2 Implementation Overall, the most suitable current sensing solution was to use a current transformer in conjunction with a RMS-to-DC converter. The converter is required to take the AC signal and convert it to a DC signal that the microprocessor can then sample. These components were used primarily because of their low power consumption and electrical isolation. Some drawbacks of the design include the physical size Figure 25: Current Transformer of the transformer as well as the lack of measurability below a certain lower limit. The use of a Hall Effect sensor in later models could potentially Figure 27: RMS to DC Converter eliminate or mitigate these problems. Figure 26: RMS to DC Circuit 11 3.0 Microprocessor 3.1 Overview The Nanocore12CS32TS was chosen as a suitable microprocessor for the project because of its low power consumption, its ability to sleep, its small size, and its suitable number of analog and digital I/O pins. The microprocessor uses the TRIAC to periodically activate the line in order to measure the current draw; this is achieved through the use of the current transformer and the RMS-to-DC converter. It switches the TRIAC every second so that when a user plugs a device into the charge adapter, charging begins seamlessly. This 1 second cycle was important because it would allow the processor to sleep in between samplings. When the processor is asleep, it only consumes 2µA of current, whereas it consumes 15mA when it is awake and running. Figure 28: Microprocessor 3.2 Firmware The hardware discussed in previous sections, together with the microprocessor, merely comprises the platform on which the firmware runs. A very specific algorithm had to be carefully designed in order to correctly control this hardware. There were several requirements that the firmware algorithm had to fulfill: it must accurately determine the leakage current of the connected charge adapter it must be able to dynamically reconfigure itself for a newly connected adapter and it must correctly identify a sub- or super-threshold condition based on the leakage current value and take the appropriate action. It was decided that this could be best achieved by implementing a configuration mode for ChargeGuard. During this mode, the algorithm gathers information about the currently-connected adapter as current is observed to change over time. When sufficient data is collected, the algorithm can robustly and accurately determine the value of the leakage current. Once configuration is complete, the algorithm 12 alternates between charging and sampling states, depending on whether or not there is a device connected to the adapter. The firmware code was developed using a proprietary extension of BASIC called NQBASIC. The code designed actually runs a finite state machine (FSM) that has the states represented in Table 1. Table 2: States and Descriptions State CONFIGURE_NONE Description Relay Triac The default state when the processor ON OFF is powered up. All of the min and max current variables are set to zero and all values are initialized. CONFIGURE_FIRST_MIN The state when the processor ON OFF reaches its first minimum, virtually happens after the first sample is taken. CONFIGURE_FIRST_MAX The state when the processor finds ON OFF its first maximum. The maximum value has to be larger than the maxCurrent variable value by a certain relative threshold. CONFIGURE_SECOND_MIN The state when the sampled current ON OFF is within the relative threshold of the minCurrent variable. CONFIGURE_SECOND_MAX The state when the sampled current ON OFF is within the relative threshold of the maxCurrent variable. CONFIGURATION COMPLETE After the system is configured it will not enter configuration mode until it is either unplugged or it senses basically zero current. RUN_CHARGING This state represents the charging ON OFF state and will only change to the leakage state when the current falls within the relative threshold of the minCurrent variable. RUN_LEAKING This state represents the leakage OFF Using to state and will only change to the sample charging state when the current current sampled is above the relative every 1s threshold of the maxCurrent. 13 4.0 Future Expansion 4.1 Multiple Outlets The current prototype has one outlet for an adapter to be plugged into. The possible future expansion for ChargeGuard could be to develop a device similar to a power bar, which could accommodate multiple adapters. In this expansion some changes would need to be made to the existing circuitry. Each outlet would need its own TRIAC, relay, current transformer, and rms-to-dc converter. Also, the power supply would be required to handle a larger current and must be designed accordingly. If the number of inputs and outputs on the processor becomes a factor, a serial to parallel converter could be used for the outputs. This way a serial bit stream could be sent to the converter which would then send out the bits in parallel to activate or deactivate the corresponding switches. A similar method could be used for the inputs as well. 4.2 Integrated in Adapters Another option for the development of ChargeGuard would be to create a very small circuit which could be integrated inside the charge adapters themselves. Then the adapters could be plugged into any wall socket and not be at risk for leaking current. In this situation the components required would be the same as the prototype which was actually designed and built. 5.0 Conclusion The intent of this project was to develop a device which would help to mitigate energy wasted by idle charge adapters. This was achieved through the realization of the prototype, which was successful in demonstrating this power-saving behaviour. Although the prototype did not possess multiple outlets and the overhead power consumption of the device was quite substantial, the prototype was successful in proving the original concept. Given more time further improvement could be made to the design in several key areas. For instance, the efficiency of the power supply could be improved by utilizing only passive components. In addition, lower-power TRIAC and relay circuits could be developed. With regard to the firmware, a more effective timing scheme could be developed for the sampling algorithm, which would also take advantage of the microprocessors sleep feature. Implementing such improvements would bring the ChargeGuard prototype closer to a full commercial product. 14