Abstract
The purpose of this product is to create an extremely energy efficient ceiling light/fan. This is accomplished using modern microcontroller implementation and a variety of sensors and actuators. The main aspect of the device is its ability to operate, without any human intervention, put itself in a mode that is most economical: no wastage.
Introduction
In recent times, energy has become quite an issue, and ways in which to save energy are becoming very important in all new devices created. Perhaps it’s the fact that it is rare to find any home without high power devices, or simply that oil prices are on the rise. No matter what the reason is, the necessity for everything to be energy efficient has become extremely important. One thing that has been kept, for the most part, manual over the years is lighting, except for the automatic on/off incorporated into many new systems. When tied into a ceiling fan fixture, it becomes very practical to make this hot item more economically feasible. There are two main ideas that are used to accomplish the task at hand in this product. The first deals with adjusting the light level based on the current lighting condition. The second deals with adjusting the fan speed based on the temperature. By realizing that people can end up staying in a room all day and do not always remember or care to adjust the lighting or fan speed, it was determined that this can save energy and therefore money for consumers. Since in the day there is often enough light outside and at night it is not that hot, adjustments can be made without making the customer uncomfortable. Of course there are a number of other features such as automatic on/off based on occupancy, fire sensing and alerting ability and safe protection.
Implementation
The prototype of this device was made by using a Basic Stamp as a brain to control the fixture by means of the PBasic programming language. Branching out from the brain there are a number of secondary circuits to control a variety of functions. For the light, a DS1804 digital potentiometer is used in conjunction with an amplifying circuit as well as a relay for the on/off function. For the fan a DS 1804 is used to control the pulse rate of a 555 timer which powers the fan through a MOSFET. For sensing purposes a DS1620 is used for temperature sensing and a photo resistor/ capacitor pair for light level sensing. To determine the occupancy of people, two infrared phototransistors and a single infrared LED is employed to determine direction of movement.
Hardware Specifications
The hardware for this product is pretty complicated in the fact that there are a lot of complex aspects that have to be considered. However, by using the microcontroller, this is not too much of an issue. The schematic for the circuitry is displayed in the appendix (3).
Light Sensor – The light sensor consists of a photo resistor and capacitor pair. As the resistance value changes, the time constant (RxC)value changes. The capacitor value used is .05 micro Farads in series with the photo resistor. The bridge between the two is connected thorough a current limiting 470 ohm resistor to pin 11 of the Basic stamp. The other end of the photo resistor is connected to ground, while the other end of the capacitor is connected to positive 5 volts.
Occupancy Detection – The occupancy detection circuit incorporates two infrared phototransistors and a single infrared Light Emitting Diode. Both of the phototransistors are connected in the same fashion. Positive 5 volts connects to the collector, while the emitter is connected to ground through a 10 k Ohm resistor. The bridge of the resistor and emitter are connected through a 470 ohm current limiting resistor to the Basic Stamp (pin 14 and pin 15). The IR LED is simply connected through a 100 ohm resistor to 5 volts and ground, pointed at the two phototransistors. With this configuration, a blockage of the phototransistor means a low to the basic stamp.
Light Control – The light control mechanism is created using a digital potentiometer, a transistor and a relay with a transistor and diode attached. The digital potentiometer (DS1804) is the part that does the analog control of the light. It is connected in a voltage divider circuit with a 1 Mega Ohm resistor, as well as a 4.7 k ohm resistor connected in parallel. This supplies a variable voltage to the base of a JFET that has its collector at 5 volts and its emitter connected in series through the relay to drive the light. The relay (with a current spike protecting diode connected in parallel) is turned on and off by a BJT that has a base voltage (0V or 5V) given by pin 5 of the basic stamp. The increment and Up/Down inputs are given by pins 10 and 9 on the Basic Stamp respectively. As for the reset, it is done using a selector circuit (explained later) so that the number of pins used can be optimized. Pin 8 on the DS1804 is connected to 5 volts. Pin 4 is connected to ground. Pin 5 is connected to the other resistor to make the divider circuit.
Temperature Sensor – The temperature sensor simply uses the DS1620 temperature transducer to change the current temperature to a series of voltage pulses corresponding to the number value of the temperature. Pin 8 of this is connected to both positive 5 volts and through a .1 micro Farad capacitor to ground. Pin 4 is connected directly to ground. The data and clock pins (1 and 2) are connected to the Basic Stamp pins 8 and 7 respectively. The reset pin, pin 3 is connected to the Basic Stamp via the selector circuit.
Fan Control – The fan control is accomplished by utilizing a 555 timer, DC1804 (potentiometer) and a MOSFET. Here, the main analog control is accomplished by using the digital potentiometer; this is connected as a resistor for the 555 timer. Pin 6 of the DS1804 is connected through a 15 k ohm resistor to pin 7 of the 555, which is shorted to pin 2. Pin 5 and pin 8 on the pot are both connected to positive 5 volts. Pin 4 is connected to ground and pin 7 to the selector circuit. The increment and Up/Down pins (1 and 2) are connected to pins 10 and 9 respectively on the Basic Stamp. The 555 timer has its pin 1 grounded and its pin 8 at positive 5 volts. Pin 2 and pin 6 are connected by a short together while also being connected through a .01 micro Farad capacitor to ground. The reset (pin 4 is connected to the Basic Stamp via pin 6 on the BS2. The output of the 555 (pin 3) is connected through a 1 k ohm resistor to the gate of the MOSFET. The source is connected to ground, while the drain is connected to the motor that is connected to positive 12 volts on the other end. And of course, there is a diode in parallel with the motor to prevent any inductive kickback.
Selector Circuit – The selector circuit is a way that was used in order to save pins on the microcontroller. This became an important aspect of making the system efficient, it was quickly determined that the only way to add some more features was to decrease the amount of pins used. By making either a high or low from a single B.S. pin (pin 4), different IC’s can be made to listen or ignore: very useful. This was done by using two inverter circuits connected together (in our case actual NAND circuits with all inputs bridged together). First, the signal from the BS2 was inverted; this goes to the fan circuit digital pot. Then, this signal was inverted again, basically a buffer, this was fed to the light circuit digital pot. and to the temperature transducer reset pin. Therefore, a high at pin 4 of the basic stamp would enable the digital potentiometer controlling the light, while a low at pin 4 would enable the digital potentiometer controlling the fan and the temperature sensor(DS 1620).
User input – The user input is given by two buttons. One is for the light control and one is for the fan control. With each, there are three levels for automatic control and two for manual control. Each button is configured in normally open and active low mode (best for least errors): a press at the button gives a low to the corresponding pin of the Basic Stamp. One end of the button is connected to ground, while the other end is connected to positive 5 volts through a 1 k ohm resistor and also to pins 12 and 13 on the Basic Stamp through a 470 ohm current limiting resistor.
Fire detection and alarming - This circuitry is utilizing the existing temperature sensing circuitry and an additional circuitry composed of a piezoelectric buzzer. Pin 3 of the basic stamp is used and connected to the positive end of the buzzer. The negative end of the buzzer was connected to the ground.
Electrocution protection–The safety protection feature is realized by implementing a capacitance proximity sensor. The circuit is basically a RC circuit which connects to an input pin on the basic stamp. The resistor selected has a value of 10 MΩ. The capacitor is constructed such that one plate is made of a sheet of aluminum attached to the ceiling where the fan/light device is, and another plate is human being who tries to touch the light or fan.
Hardware Functionality
This system was designed so that it would function mainly by using a microcontroller, which was intensively programmed. However the systems controlled and the sensors used represent a major part of the system and are hardware, so the functionality of these aspects are discussed here.
The light sensing circuitry controls the hardware that creates the optimum light output level. As light values are sampled from the outside world, the values obtained are compared to the value of light desired, and more or less current is allowed to flow through the approximately 13 ohm light bulb by changing the value of the digital potentiometer. The relay is turned on and off depending on the condition of occupancy and manual override. If the button is pressed to be put in the 5th mode, the relay is deactivated and the light is turned off. Also, if the occupancy detector says nobody is inside the room, the relay is again deactivated. By using two phototransistors, the direction of movement can be determined, and thus a counter can be established to determine if there are people in the room. There are five user input modes. The first three set three different light level conditions to be kept constant by the system. The 4th is an override that makes the light stay at full power no matter what the current light level in the room and the 5th turns off the light.
The temperature sensing circuitry controls the hardware that maintains the optimum fan speed level. The fan speed is controlled using pulse width modulation. By obtaining the current temperature value in the room and comparing it to how the fan should react to different temperatures, based on the user input, the fan speed is increased or decreased by means of changing the pulse duration by altering the digital potentiometer value. By turning off the 555 timer (deactivating the reset pin), the fan can be turned completely off. This is done if there is nobody in the room, the user manually turns it off by the button or there is a fire [turning the fan off if there is a fire to prevent spreading by those means (Prof. Kapila)]. The fan has 5 levels chosen by the button. The first sets a range for the fan to be full blast at a lower temperature, the second at a higher temperature and the third at an even higher temperature. The speed is controlled based on the temperature depending on the mode it is in. The 4th level simply puts the fan into its high state, while the 5th turns it off.
The selector circuit is made so that when one circuit is operational, the other is ignoring the input it is getting from the data pins.
The fire detection and alarming circuit is configured that when there is a fire, the light will start blinking and the buzzer will start making high pitched noise. The temperature sensing circuitry is constantly checking the temperature. When the temperature measured is higher than the alarming temperature predefined by the programmer, the light circuit and the buzzer circuit will be activated. A button is also associated so that when it is pressed, the buzzer would stop producing sound and the light would stop blinking. The system would then go into its original state, which constantly waits for the entrance of people.
The safety protection feature of this device was designed to prevent human being from being electrocuted. Whenever a person’s part of body is in a danger range which is determined by the programmer, the power to the system will be disconnected by turning off the 555 timer and the reed relay.
Software Specifications
The software for this system is an extremely important aspect; it is what allows such a difficult task to be made simple without the need to use vast amounts of electronic circuitry. The software used for the prototype is what came with the Basic Stamp, the PBasic programming language. The program is not very advanced, but it does the job. There are a number of special functions that were used for this task.
The Rctime command is one such function. It is a command that calculates the amount of time a specified pin takes to change state. Basically, it calculates the time for the pin to go from a logic low to a logic high state or vice versa. In the function, the pin, end state and output variable must be given when using the command.
Another function that was used was the serial in/out command. This command translates a stream of binary pulses into a numerical value. This is when it is used as shiftin (gets an input of pulses). When used to output pulses (shiftout), it operates in the opposite manner. The values that must be given to the command are the in/out pin to be used, the clock pin, in what order the pulses will be sent and the variable or value to be sent or received.
Another function used is the For Loop. This function simply repeats a specified task, what is in the loop, over and over for a specified amount of times. The values that are given to the function are the start and stop count for the number of cycles to run.
Although these are a few of the more advanced functions utilized, there are a number of simple functions that were used that if not there would make it quite impossible to accomplish the task at hand. On top of this, an important thing that is worth mentioning is the effort that was put into making the program shorter and run faster and more efficiently. It might sometimes seem as if a lot was done in certain places, however it is determined that these actions are necessary to make the system work to its best capability. Often, it is necessary to determine the best size for each variable declared; saving space while still keeping efficiency was a key.
Software Functionality
Since it is the brains of the entire operations, it is simple to realize that a lot of time went into the design and implementation of the program. Problems were often sought out and solutions found. Not to mention much had to be accounted for in order to make the program operate fast enough so that the buttons and occupancy sensor would instantly pick up any new activity. The program was split up into blocks in order to make it easier to understand and therefore easier to improve upon it. The main program is displayed in the appendix (1) and the secondary statistical program is also displayed there (2).
Variable Declaration – Here all the variables were declared. The majority of these were given names so that the value they store can be easily grasped. Also, the amount of space that is allocated to each variable is important. If it is not necessary to use a word (16 bits), then one should not be used. Often variables as small as a nibble, only four bits, were used.
Light Automation – This is the part in which the subroutine to make the lighting system smart was put into operation. What is done here is to first look at what level of lighting the user has defined. Based on this, a certain light level (amount of light that is to be present in the room) is obtained. This value is then compared with that of the current light level in the room, received through the RCtime function from the light sensing circuit. Depending on if the current light level is too bright or to dim, within a range, the output light will be adjusted to reach that light level specified by utilizing a for loop to control the digital pot connected to the light circuit. This subroutine is within a main loop and therefore is continuously active.
Fan Automation – This part of the program is what automates the fan control and makes it operate as a smart system. The entire algorithm depends on what temperature range the current condition is in. After this is determined, based on the temperature, obtained by the DS1620 while using the shiftin and shiftout commands, a value to change the fan speed to is obtained. Using a comparison of the previous value to this new value based on the range of the digital potentiometer, the speed of the motor is altered using a For Loop to increment or decrement the resistance level of the DS1804. In this subroutine, much effort is taken in order to minimize the use of redundant operations, such as going through loops that are not necessary. The usefulness of past values should be quite evident in this block.