Digital Appliance Timer - Project 2 | ECE 445, Study Guides, Projects, Research of Electrical and Electronics Engineering

Material Type: Project; Class: Senior Design Project Lab; Subject: Electrical and Computer Engr; University: University of Illinois - Urbana-Champaign; Term: Spring 2003;

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 03/16/2009

koofers-user-29e
koofers-user-29e 🇺🇸

9 documents

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Digital Appliance Timer
By
Justin Funk
Eric Green
ECE 345, SENIOR DESIGN PROJECT
SPRING 2003
TA: Purvesh Thakker
May 5, 2003
Project No. 10
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Digital Appliance Timer - Project 2 | ECE 445 and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

Digital Appliance Timer

By Justin Funk Eric Green ECE 345, SENIOR DESIGN PROJECT SPRING 2003 TA: Purvesh Thakker May 5, 2003 Project No. 10

ii ABSTRACT This appliance timer will allow users to have a wide variety of control over the timer. Different functions will allow the user to program a specific time, turn on and off sensors, and set time lengths for operation. The timer will be accurate to one minute a year and easy to use. The modules involved in the construction of the timer include the following: a clock, a HC12 microcontroller, a Basic-X, an LCD, a keypad, and a power supply. Testing will be done to insure a high reliability and control. Testing will also insure the performance despite many different operating conditions i.e. power outages and incorrect user inputs.

1. INTRODUCTION

1.1 Overview The force behind the digital appliance timer was that even though there are many types in the market today, many are inaccurate and lack an easy-to-use interface. Our goal was to create an accurate timer along with user friendly features, while minimizing the cost. The project was to be broken down into different modules. Each module was to be designed separately, keeping in mind the other modules that would need to interface with it. Breaking the project up like this would be the easiest and most efficient way to approach this problem. We choose to include our own power supply, and the battery back up would be included in the clock. The user powers up the system and waits to be prompted by the program. The user can then identify which function of operation is desired, along with setting the times and overrides via the keypad. The functioning of the machine, once the user has set the desired time, operates independently. 1.2 Project Intent This project is to replace a timer with a digital system. The system will provide a real-time clock, accurate to about 1 min per year. It will use a 9 V battery back-up to keep the time accurate in case of power outage. The digital circuit will run off a power supply connected to a wall outlet. The digital circuit will drive a small relay to control an ac load. In addition, sensors for lighting via a photocell will be implemented (other sensors i.e. heat could be added later). Users will be able to control which method of triggering is used for either sensor control or timing control. 1.3 Performance Specifications

  • Accurate to 1 minute per year
  • Battery backup for clock
  • Accurate conversion from AC to DC for components
  • Able to turn on when user specified
  • Sensor affects operation of timer

Section 1 System Block Diagram Fig. 1. System Block Diagram 1.5 Block Descriptions  Power Supply: The power supply supplies power to the clock and the relay. It also converts wall power to 5 V dc to supply voltage to the microcontroller and to use in the filtering of signals from the various other blocks to the microcontroller. This will be used to protect the microcontroller from excess voltage. Power will also be supplied to the user interface and memory.  Relay: The relays will function as an on/off switch. Power will flow to the relays, and based on the input to the relays from the microcontroller it will decide whether or not to supply power to the appliance.  Appliance: This can be any appliance that will operate when power is supplied to it. We will be dealing with lamps during testing.  Clock: This part of the overall circuit will supply the current time/date to the microcontroller for use in its logic operations. There will be an internal power supply to be used in case of power outage.  Sensors: Optional sensors for the consumer to use in deciding on/off cycles. We will be mainly focusing on a sensor to determine the light in an area.  Microcontroller: The microcontroller used will be a Motorola 68HC912B32 Microcontroller. This will take inputs from the sensors, clock, and user interface. These inputs will be used to determine whether or not to send a signal to a relay turning on power to the appliance  BasicX-24: Used as a memory and as a relay between the HC12 and the LCD. Conditionals are used to determine the proper output. Power Supply Relays Appliance Microcontroller BasicX- User Interface Clock With Battery Backup Sensors

1. DESIGN PROCEDURE

2.1 Subsystems All of our systems were designed individually. This allowed us to test each part of the circuit separately before trying to integrate them together 2.1.1 Power Supply The power supply we needed to design needed to be able to supply 5 V with a low voltage ripple and a fast starting time. We decided to take a transformer and step down normal wall socket voltage, and then we took this circuit and rectified the ac voltage into a dc signal. We then took this dc signal and regulated it to the correct voltage required. We also had to consider the current output, as we needed a fair amount to run all of the modules at the same time. Mathematical equations were used to determine initial values, then PSpice simulations were ran to determine the optimal values of our components. The maximum current is (20mA+Iz,min)=Is (1) and the voltage ripple is Vripple = IS / (60*C) (2) 2.1.2 Relays The relays needed to be able to handle normal wall voltage, but control that with a small dc voltage in comparison. This was accomplished through the use of a reed relay. It takes a 5 V signal from the microcontroller and flips a switch so that the wall voltage is passed through the relay. An operational amplifier will be used in order to amplify the current that the relay will draw from the microcontroller so that the circuit will not reset. 2.1.3 Clock Since the clock needs to be accurate to within one minute a year, we decided that we would get our clock signal from an atomic clock. The atomic clock receives a RF signal from Colorado and updates the time periodically. This was also appealing since the battery back up was also included in this pre-designed part. Removing the outside of the clock, we would take leads off of where the inputs entered the LCD on the clock. These leads would then be the time signal that would be sent to the microcontroller. 2.1.4 Sensors Two photodiodes would be used to detect light intensity. One photodiode would be covered, so that the dark current would be sent as a signal out. The other photodiode would remain unchanged. Both signals would be sent to separate operational amplifiers so that their signals would be amplified. The dark current would be amplified high enough so that it did not exceed the voltage level for a logic 0. The signal from the uncovered photodiode, after being amplified, would be sent to a voltage regulator, so that it wouldn’t exceed 5V. Both signals are sent to a

comparator. Then the output of the comparator is sent to the microcontroller. Additional sensors could be added for different appliances, but only lighting was considered. 2.1.5 Basic X- The Basic X-24 was used for memory and to reduce input/output lines for the microcontroller. The microcontroller would be able to use three pins for other operations while one pin was low. When that pin is high it sends signals to the BasicX-24. These signals are used to determine what message to display to the LCD, based on the state the microcontroller is in. The messages would be stored on the BasicX-24, and are accessed through a series of conditionals. The BasicX-24 is the interface between the LCD display and the microcontroller. 2.1.6 User Interface The user interface consists of two parts: the keypad, and the LCD. The user is prompted for specific entries by the LCD. Three varieties of LCDs were observed and tested. The user then reacts to each prompt with the keypad. Additional logic read the values from the keypad then held them to the proper values, so that the microcontroller could read them in at a later time. 2.1.7 Microcontroller The HC12 microcontroller was used as the main processor in our design. 5 V was used to power the HC12. Inputs from the keypad, the keypad, and the sensors will be inputted into the microcontroller, which will then perform logical operations to decide what the system should do. These logical operations are decided by the program written in assembly and loaded into the HC12 through the computer interface. Outputs from the HC12 will then control the MUXs and other logic within the circuit, as well as driving the relay. 2.2 Tools Used in Design PSpice was used to design the power supply along with the simulation software provided. Equations were used to get theoretical values, and then testing was done to insure proper operation.

3.1.2 Relays The relays we were looking for needed to run off of a 5 V signal from the HC12 microcontroller. At the same time, the relay needed to be able to carry a large voltage when the relay was closed. A current is required to remain active. To remain in its active state, the relay required 82 mA of current. The HC12 could only supply 47.42 mA of current when supplying only one pin. At the worst of its operation, when it tried to activate the relay the HC12 was only supplying 39 mA of current to the relay. This was an issue to deal with when it came time to integrate the components together. This lack of current was easily solved by a unity-gain amplifier. This easily solves the problem as the voltage is kept constant while the current is increased. Figure 3 shows the final design for our relay. 0 0 0 D LED 0 U1A LF 3 2 8 4 1

  • V + V- OUT (^) 120Vac V 0Vdc 0 Fig. 3. Relay With Operational Amplifier 3.1.3 Sensors For our light sensors we obtained two photodiodes. These diodes where connected to operational amplifiers (See Figure 4) to amplify their voltage outputs. 0

(^3) + 2 6 7 4 0 1 2 0 0 0 Fig. 4. Sensor Amplifier Circuit Input

Once the signal was amplified it was to be sent to the comparator. The signals were not distinct and could not be used. If the intensity of light created a more stable signal, the photodiodes would have been a good sensor. 3.1.4 Basic X- The Basic X-24 takes 4 inputs from the microcontroller. These inputs are obtained by a function (getpin). The values taken from the pins are then converted to Boolean values (CBool). These values are then compared to set values and strings are outputted. These outputs are taken serially to the LCD. The program continued through a loop until a specific value changed. The program would restart as soon as this value went back to its original state. Even if the Basic X-24 loses power the program continued to run. Operational amplifiers would be used to amplify the signal from the HC12. 3.1.5 User Interface The user interface consisted of two parts. The LCD took a constant 5V DC supply (which could be supplied from the power supply). The serial input came from the Basic X-24. The string value would be displayed directly. The LCD used needed a clear statement in the loop of the Basic X-24 in order to clear the data not to be displayed. The keypad used needed a MM74C922 decoder to power and convert the row/column signal into a hexadecimal signal. The basic layout of the logic is shown in Figure 5. MM74C JK/FF S JK/FF 1st Digit Hrs 2nd Digit Hrs 1st Digit Mins S U11A 74F 1 2 JK/FF Demux JK/FF 2nd Digit Mins Fig. 5. Keypad Logic Arrangement

4. DESIGN VERIFICATION

4.1 Testing 4.1.1 Power Supply The first test on the power supply was a PSpice simulation. The simulation showed the output voltage having a ripple between 5.141V and 5.147V. The time to reach maximum voltage was 0.05 s. The real test showed the same data (as seen in Figure 8). Fig. 8. Graph of Output Voltage from the Power Supply 4.1.2 Basic X- There were very few tests that could be applied to the Basic X-24. The first was whether the program continued to run even after the power was cut. This simple test showed that the program would remain in the same state even after power was cut. The next test was to see if the inputs changed the outputs. As different values of the inputs are applied the outputs showed different values. 4.1.3 User Interface The LCD has a built in test. The way to test whether or not the LCD is working is to plug a constant 5V dc signal into the serial port before power is applied. Then at start up, a message

will be displayed on the LCD. For the keypad, capacitors were added to make sure that the keys did not bounce. Documents showed the best possible combination for capacitances. 4.1.4 Sensors Sensors were first tested with an oscilloscope. Maximum voltage could be varied by the intensity of light. The dark current was observed to be the same as that listed in documentation. The rest of the sensors were not finished. However, the output of the comparator could be tested as a logic high or low for various intensities of light. 4.1.5 Microcontroller The microcontroller was tested with LEDs. The program was up loaded into the HC12 and ran. While running commands were entered via the keypad to change states of the program. By watching the LEDs we were able to determine if it was switching states accurately or not. Once the program switched states correctly, we could make sure that each section of code worked. The input section of the code was tested by using the show section of the code. The show section of the code was fairly certain to work as it was a simple storing of the value specified into an output port. The override was simple to test. By using the LEDs we could see that it was operating properly. The run section was tested by a combination of the other sections of code and some LEDs. By inputting a time to start with the input section of code, we could simulate a clock signal and see if it was operating correctly if it would turn on an LED. Similarly, we could also specify an ending time and check to be certain that it would turn off as ordered to. 4.2 Conclusions Each tested component worked exactly as expected, sometimes after slight modification. However, when testing the integration of components, they would not work. We found that the integration problems were due to power issues, most of which were the lack of current supplied. These issues could be resolved by adding in operational amplifiers where necessary.

6. CONCLUSIONS

Our design did not work at the end of the semester. Three main problems occurred during the course of the semester. The first was the clock not working. Our original intent to take the leads as inputs did not work. The only way to access the inputs was to dismantle the clock. Once dismantled, we could not tell what the inputs were. However, we knew from testing the leads that it was not outputting the right signal (all the leads showed a high voltage). At this point, we should have modified the design of our clock to focus on the internal clock feature of the BasicX-24. This clock would have been easier to use and would have eliminated the need for the HC12, in one respect. The appeal of the battery back up built into the purchased clock kept us trying to get a signal from it, even though it was futile. Trying to reverse engineer the clock was a challenge that could have taken a whole semester itself. The second problem occurred with the HC12. The HC12 was, in the end, an unnecessary component for many reasons. The first is that the BasicX-24 had many functions that could have done the same operations as the HC12. The operations would have taken less run time and required less memory if used on the BasicX-24. The simplicity of the BasicX-24 was also a great appeal. Everything could have been contained on one chip. The HC12 also had problems because it is an old microcontroller. We found it very difficult to find usable code that was helpful. The third and final issue that hurt us in the end was power issues. If we were to amplify many of the signals (amplification specified on previous pages), then many problems could have been avoided. The problems with the relays drawing too much current could have been avoided. The interfacing between the HC12 and the BasicX-24 would not have been a problem. We know this for certain because each one works individually. Our project was very expandable in additions that could be made in the future. Sensors were looked at thoroughly, though only for lighting applications. Sensors would have been designed if not for the strict time constraint, due to our inability to get the other parts working. Project Expansion: Other Sensor Types (i.e. Temperature, Motion, Sound) Remote Access/Web Access Larger Memory/More Functions

APPENDIX

Basic X-24 Code (Commented) Option Explicit Public Sub Main() 'Takes Input from Pin 16 Dim PinLogicLevel1 As Byte Call PutPin(16, bxInputPullup) PinLogicLevel1 = GetPin(16) 'Takes Input from Pin 16 and makes it into a Boolean True or False Dim A As Boolean A = CBool(PinLogicLevel1) 'Sets size of data being transmitted Dim ComOut(1 to 20) As Byte Dim ComIn(1 to 20) As Byte 'Opens communication so that serial data can be transmitted to the LCD via strings Call OpenQueue(ComOut, 20) Call OpenQueue(ComIn, 20) Call OpenCom(1, 2400, ComIn, ComOut) 'Baud must be same on LCD 'Loop used while one input high (conserve I/O lines) Do While (A = True) 'Some Sort of Clear needs to go here for display Call PutQueueStr(ComOut, Chr(254) & Chr(1)) 'Takes Input from Pin 17 Dim PinLogicLevel2 As Byte Call PutPin(17, bxInputPullup) PinLogicLevel2 = GetPin(17) 'Takes Input from Pin 17 and makes it into a Boolean True or False Dim B As Boolean B = CBool(PinLogicLevel2) 'Takes Input from Pin 18 Dim PinLogicLevel3 As Byte Call PutPin(18, bxInputPullup) PinLogicLevel3 = GetPin(18) 'Takes Input from Pin 18 and makes it into a Boolean True or False Dim C As Boolean C = CBool(PinLogicLevel3)

REFERENCES

Texas Instruments, TTL Logic , Texas Instruments, 2003 Motorola Semiconductor Technical Data, Optoelectronics , Motorola, Inc. 1992 ECE Part Shop, University of Illinois at Urbana-Champaign, “hc912,” http://www.ece.uiuc.edu/eshop/availablemodules/HC912/HC912.htm. Basic X-24 Sample Code http://campus.murraystate.edu/academic/faculty/bob.pilgrim/info/ http://www.basicx.com/ http://www.basicx.com/Products/BX-24/bx24instset.htm http://www.totalrobots.com/examples/example26.htm http://www.basicx.com/Products/SLCD/2x16SLCDV1.2.pdf Others For Transformer http://www.stancor.com/pdfs/pg47_50.pdf For LCD http://www.seetron.com/slcds.htm For Keypad http://www.jkmicro.com/newsite/documentation/pdf/keypad_data_sheet.pdf Electronic Circuits Laboratory, University of Illinois at Urbana-Champaign, “Project #2: Power Supply Circuit,” 2003, http://courses.ece.uiuc.edu/ece343/segment2.html.