


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















By Alphonse Shiwala Girum Kassa Cho Whan Park ECE 445, SENIOR DESIGN PROJECT FALL 2007 TA: Tomasz Wojtaszek 12/04/ Project No. 15
We designed and built an automatic guided fan. The fan receives a signal from an infrared beacon, and tracks the user in any direction he or she goes. The speed control system changes the operation speed of the fan depending on the range between him and the device. ii
v
1.3 Subprojects The design was broken into 3 main modules. Each performs specific tasks. The modules implemented are: 1.3.1 Speed Control System The purpose of this module is to control the speed of operation of fan depending on the distance between the fan and the user. The module outputs 3 different voltages; 4.8 V when the user is close enough, 7.2 V when he is further away, and 12 V when he’s far away from the fan. In the original design, the fan was connected directly to the voltage output of this module. The above voltage values control the operation speed of the fan. The Fan should run at maximum speed when the user is located far away from the fan. When he is located in the medium range, the fan should run at medium speed, and finally, when he is located close to the fan, the fans runs at low speed. In the original design, we wanted the high range to be 5 meters and more, the medium range is between 3 meters and 5 meters, and finally, the low range is between 6 inches and 3 meters. The range detection system is active whenever the fan is stationary. There are 3 switches on this module. The first one is used to turn on and off the whole project. The second one activates and deactivates the range detection module, and the last one activates and deactivates the motion tracking module. Every other parts of the project are connected to the +5V power supply of the range detection module. 1.3.2 Infrared Receiving System The purpose of this module is to receive the signal being sent by the beacon, and compute the direction in which the fan should turn. 1.3.3 Motor Control System The purpose of this module is to turn the fan in the appropriate direction after receiving an instruction from the Infrared Receiving system.
2.1 Speed Control System This module can be broken into several components; the power supply, the voltage regulator circuit, the microcontroller, the analog multiplexer, the ultrasonic sensor, the current source and the voltage regulator. 2.1.1 Power Supply The whole circuit uses a 12 V external voltage source. The purpose of the power supply was to convert from the 12 V unregulated power source to provide +5 V, and a ground terminal that will be used by all the Microcontroller, the Multiplexer, the crystal oscillator, and the motor controller. We started the design by using resistors to drop the voltage from 12 V to 5 V, and then we switched to using the LM7805 voltage regulator to control the amount of voltage being supplied. The benefit of that component is the fact that it offers a best protection, and it has a thermal shutdown mode to protect all other components as well as the fan. The voltage regulator, as well as the other internal parts of the circuit couldn’t provide the fan with the desired current because of their power specs. Therefore, we used the 12 V external voltage source as the power supply of the current source used by the fan, as well as the power supply of the LM741 op-amp. 2.1.2 Voltage Regulator The purpose of this component was to provide 2 different voltage sources +2V and +3V. This component takes 5 V from the power supply, and its outputs are connected to the analog multiplexer. It’s a simple circuit composed of 3 resistors in series. We collect the outputs as the junction between the resistors. Instead of using a commercial voltage regulator, we used this design because, the internal voltage has already been regulated by the power supply, and we could easily change the output voltage by changing the resistor values, which wouldn’t be the case if we used the conventional ones. 2.1.3 Analog Multiplexer This component branches the desired voltage source to the voltage amplifier circuit. We used the PIC 16F877 as its select input, to determine which voltage source should be used. Unfortunately, its power specification won’t allow a high current being output from it, therefore, we had to use an independent current source.
Even though we get 12 V from this circuit, we were not able to provide the required operation current for the fan. However, we used the low current being output as the base current of NPN transistors used in the current supply. The value of that current varied as the voltage changed, providing us with an efficient way to increase or decrease the current supplied to the fan. 2.2 Infrared Receiving System + Beacon 2.2.1 IR Beacon 2.2.1.1 Battery (9V) A 9 V battery is used because it is relatively smaller than other batteries that have same voltage and life time. LM 555 Timer, a most crucial part of the beacon, can be used in voltage between 4.5V to 15V. the beacon has to be light-weighted, and easy to carry. Thus 9 V battery is suited for the beacon 2.2.1.2 LM 555 Timer This component generates pulse. The beacon uses two of LM 555 Timer. One is to modulate carrier frequency into 38 kHz for IR Receiver specification. The other is to generate burst of signal in order to increase maximum range of signal transmitted. In both case, astable mode is used. It is fairly simple to make LM 555 Timer into astable mode. Using formula given in data sheet, we got appropriate values for resistor and capacitors. We used potentiometer to calibrate frequency precisely. 2.2.1.3 Infrared LED This component emits infrared signal. 4 IR LED emit signal to all direction. The frequency of signal is 38 kHz. 2.2.2 Fan-Shaped Signal Isolator This component prevents overlapping of infrared signals. 36 degree separators isolate each beam pathway between receivers. We used separator degree of 36 degree because it is multiple of 1. degree which is minimum step angle of stepper motor. Thus motor can move each step more accurately. We have determined to use black color for our separator in order to reduce bouncing off infrared signals. Black color absorbs light waves. The material for separator was conducting metal. Insulating material such as electrical tapes and insulating plastics were use to prevent short circuit. 2.2.3 PIC16F This component decides what voltage source should be branched out to the stepper motor. The PIC gets the data from the TSOP41 Infrared Receiver which is connected to its input, and outputs the appropriate 2 bit binary input to shift register which decides
which way the motor should move. Also a clock pulse is generated for stepper motor as output. 2.3 Motor Control System We use 5v power supply for the uni-polar stepper motor controller and driver. We get this supply voltage from the voltage regulator that we use for all our system. This voltage regulator regulates from 12v input to 5v output. We used the Universal shift register as our uni-polar stepper motor controller. The four outputs of the universal shift register are connected to the motor driver. What this motor driver does is amplify the current that gets out from the universal shift register. The motor driver is built from four resistors, four NPN transistors, and four diodes. Finally, the four outputs of motor driver are connected to the uni-polar stepper motor. The uin-polar stepper motor has 6 terminals. It has also 2 phases, which has two terminals per phase. These four terminals are connected to the motor driver. Also, each phase has power supply terminals which are connected to the 5v power supply. The block diagram of uni-polar stepper motor, uni-polar stepper motor controller, and driver can be seen in Block Diagram 1.
VOUT = (VCC/ 512)*distance (inches) (3.1.4.1) TOUT = 147 * distance (inches) (3.1.4.2) Figures C.1 and C.2 indicate that both these outputs have a linear pattern, but the probability of error increases as we get further away from the sensor. We do not need to explicitly initialize the sensor; it does it automatically when it’s turned on. 3.1.4.1 Analog Output The dead zone of the sensor is 6 inches. When the object stands between 0 and 6 inches from the sensor, a voltage of 58.6 mV is being output. The maximum distance the sensor can detect is 254 inches, which corresponds to an output voltage of 2.48V. This particular sensor was designed to operate at full capacity when the object it is detecting is wide (for example, a wall). Even though this sensor has a very high range, we were not able to use it at its maximum capacity, but overall, we got some descent results for short and medium range detection (6inches 7 ft). Improving the reliability for the sensor to detect object for longer ranges was done by adding an error detection algorithm in the PIC. The way this algorithm works is: we read the data from the output of the sensor, and save it as a variable. Then, we read the output of the sensor again, and we compare to see whether it is smaller than the previous data we read. If it is, we replace the variable by the new data. If it isn’t, we discard the new data, and we repeat this process N time. Increasing the value of N, reduces the probability of error, but it also increases the overall running time of the code, since the algorithm is linear. Using 150 samples increased the stability of the input data, while providing us with a descent running time. We were able to detect the object located within a range of 11 ft. 3.1.4.2 Pulse Width Output We started the design by using the pulse width output. We had to count how long the pulse stays high to determine the range. The advantage of using this technique was the fact that we didn’t have to use the PIC’s internal AD converter, which means that we could have used any PIC. We didn’t use this design because it’s harder to implement the error detection algorithm, and it’s hard to count with accuracy how long the pulse is high.
3.1.5 PIC 16F877 Microcontroller and code As seen in figure B.1, the ultrasonic sensor was connected to the analog input of the PIC. To use analog inputs, pin 4 of the PIC had to be connected to ground, and pin 5 to VCC (+5 V), to be used as the positive and negative references. The PIC outputs a 2 bit binary signal on pin 16 and 17 to the analog multiplexer after deciding what voltage source needs to be branched out to the fan. For error detection purposes, it keeps track of the value of the previous output. We didn’t allow the system to go from high output voltage to low output voltage, and vise versa because this indicates that there’s an obstacle between the fan and the user, or that the person isn’t standing directly in front of the sensor (calibration error). Whenever such a transition occurs, the PIC outputs the previous binary output for ~10 seconds. After that, it outputs the signal corresponding to the current position of the sensor. If within that time interval, the user reappears at the correct range, the error detection algorithm is interrupted, and the code runs normally. For simplicity purposes, we wanted the system to detect the range only when the object in front of it was stationary. Doing otherwise would require the motor to turn as fast as the user is moving. If he moves faster, then the system would detect an object an object other than the user, and the fan would run at the wrong speed. To achieve that, we used the external interrupt input of the PIC on pin 33 (PIN_B0). This interrupt is triggered at the rising edge of the signal. The code stays in the interrupt state until the input goes low. As seen in figure F.2, the code starts up with a delay. This allows the ultrasonic sensor to initialize. Then, we enable the interrupts in case the fan is in motion. Then, we read the input of the ultrasonic sensor. This code runs 150 times in order to get stable inputs. Next, the code computes the range between the fan and the user. After computing the distance, the code checks for transition errors. Finally, the code outputs the correct binary signal to the analog multiplexer. This is the end of the loop. At this point the PIC reads the code from the beginning. As seen in figure F.2 , the code runs normally until the interrupt is activated. Whenever the interrupt signal goes high, we keep outputting the previous voltage until the input signal goes low again. This interrupt signal comes from the motion tracking module, and it is high whenever the fan is stationary. Therefore the fan keeps the same speed while the interrupt in high. 3.1.6 Current Supply The maximum current that we wanted the fan the fan to operate at is 700 mA, therefore, we had to find transistors that can use up to 1 A. As seen in figure B.1 , the base current of the transistor comes from the output of the voltage amplifier circuit. We used the 12 V rail as VCC, and we used the collector output as the new voltage source of the fan.
At each high edge of 5 Hz, the 38 kHz square wave is generated. 3.2.2 Infrared Receiving System (PIC16F877) There are three major functions in code for Infrared Receiving system. First one is reading 5 inputs from receivers. Since the TSOP41 infrared receiver is active low, the PIC will only read low input. The read function will activate move function if one or more receivers output low. Second one is clock pulse for stepper motor. Whenever PIC initiates movement of motor, it generates square wave clock pulse of 50 Hz. In order to get 50 Hz clock output, we used output_high() and output_low() statements as well as 20 ms delay. Third function of our PIC is to output direction according to data read. The stepper motor driver use S0 and S1 to determine direction of motor movement. This function produces two 2 bit outputs into motor. 3.3 Motor Control System 3.3.1 Uni-Polar Stepper Motor Controller and Driver In order to control the motion of our fan, we used a uni-polar stepper motor which is an electromechanical device that provides accurate incremental rotation. The uni-polar stepper motor that we used is capable of stepping 1.8 degree per pulse, it has two phases, also uses 5v and 1A to magnetize each phase and to be able to step every clock pulse. Also, each phase has 5 ohms resistance value. We choose this uni-polar stepper motor rather than any other motors that are available on the market to control the position of the fan, to follow the position of the object because it has less complexity of controlling, power driving, it has appropriate torque that is able to move the fan head and sensors, and it is easy to use to control the position. In order to control the motion of uni-polar stepper motor, we built stepper motor controller and driver circuit to control the stepping process to adjust different positions, speed and to amplify a low controller’s output current to a larger current the to stepper motor appropriately. The rotation of the stepper motor can be determined by this formula, Step Angle (Өº) =1.8º (N of Pulse) º) =1.8º (N of Pulse) (3.3.1.1) Step angle is the rotation angle every clock pulse, N is Number of clock pulse. The main parts that we used to build the uni-polar stepper motor controller and driver are one Universal Shifter Register (SN74LS194AN) as a uni-polar stepper motor controller, four NPN transistors and four diodes as a uni-polar stepper motor driver. The circuit is shown in figure 3.
3.3.2 Universal Shifter Register (SN74LS194AN) - Logic Chip What this Universal Shifter Register does is as follow: It has four operating modes synchronous parallel load, Right shift, left shift, and do nothing. It performs these modes when the clock transition is positive edge, from Low to High. It has capability of direct overriding clear channel. As seen in figure B.6, pins of the universal shift register are as follows: GND is 0V, Ground connection for chip, VCC is 5V Power supply for chip, CLR is Clear Output Pin, SR is Serial Shift Right Input Pin. A,B,C,D are Parallel Shift Input Pins, SL is Serial Shift Left Input Pin , QA, QB, QC, QD are Output Pins, S0 and S1 are Mode Select Pins, and CLK is Clock Input Pin The power supply for this logic chip is 5 Volts. The frequency of the clock that we used is 50Hz. This was the good frequency for our purpose because whenever we used higher than 50Hz, the speed of the stepper motor will be higher which decreases the torque of the motor. Also when we used less frequency than 50Hz, the torque of the stepper motor will be higher but its speed will decrease. Therefore, after testing with different frequency values, we decided to use 50Hz. With this clock frequency the stepper motor has very good torque to be able to move the fan and the sensors that was mounted on the top of the stepper motor. Torque (oz-in) verse Speed (Revolutions/Second) relationship of this particular stepper motor curve is shown in Figure C.6. S 0 and S 1 are the inputs to the controller logic chip. These inputs come from the PIC. S and S1 can be high or low. High is between 2v to VCC=5v. Low is between 0v to .8v. Function of the logic chip is controlled by CLK, S0, and S1.When S0 and S1 are Low, output stay the same or do nothing is accomplished. Synchronous parallel loading is accomplished by applying the four bits of data and taking both mode control inputs S and S1 are high. Shift right is accomplished synchronously with the rising edge of the clock pulse when S0 is High and S1 is Low and new data is entered at the shift-right data input. When S0 is Low and S1 is high, data shifts left synchronously and new data is entered at the shift –left serial input. The more detail operation of this universal shift register logic chip can be seen in Table E.1. Since the modes are occurring when there is a transition ↑(0 to 5 v) on the clock we can apply this mechanize to the stepper motor steps to control the motion and speed of the stepper motor. Therefore, the motion and speed of the rotation are control by the number of transition on the clock pulse per second, which was applied to this logic chip.
The subprojects were tested, verified and debugged individually. When we had them working, we integrated the whole project together, then we performed our final tests. The fan and the motor were added to the project when the whole circuit was working. We did all the simulations with PSPICE, and whenever we didn’t have a component in the library, we built on a proto board and tested to see if the circuit behaves as expected. 4.1 Speed Control System 4.1.1 Power Supply To make sure we had very low ripples, we tested the output of the voltage regulator. As seen in figure C.3, the maximum peak-to-peak ripple was 15.9 mV , moving at a frequency of 13.46 kHz. The maximum output voltage was 5.5 V. 4.1.2 Voltage Regulator To make sure our calculations were accurate; we simulated the circuit on PSPICE. Finally, we build the circuit, and tested it to see if we were getting the data we expected. We were very happy with the results we obtained. 4.1.3 Analog Multiplexer Building the multiplexer didn’t require much testing. We used the datasheet to figure out what inputs and outputs we had to use, then we tested to see if we were getting the correct output with and without the fan connected to the circuit. Without the fan, the multiplexer branches the correct input data to its output. But we noticed that the output dropped down to 0.1 V whenever we connected the fan directly to the output of the voltage amplifier. At first we thought the amplifier was the problem, and then we tracked down the problem to the analog multiplexer. The maximum current output is 0.0018 A which isn’t even close to the 0.3 the fan needs to operate at the lowest speed. 4.1.4 PIC 16F877 Microcontroller + Code To test the code, we used LED’s to check if we had the correct output. When we were 100% sure that it worked, we integrated it to the whole module. 4.1.4.1 Test 1: Testing the input and outputs Since it was the first time for most of us using a PIC, we tested it by setting the output to the input. Whenever the input was high, we wanted the output to be
high, and vice versa. After we got that part done, we started writing the actual code. 4.1.4.2 Test 2: Reading data from the PW output We had to make sure the PIC was able to read the data coming from the ultrasonic sensor. First, we tested it with the pulse width input. We used an LED to verify the data. The LED was blinking faster when the user was closer to the sensor, and the frequency gradually decreased as he went further away from it. 4.1.4.3 Test 3: Reading data from the analog output To make sure we were able to read data, we used LED’s to output high whenever voltage input was above 1.5 V, and to output low when the voltage was below that threshold. After we made sure that part worked, we started implementing the subroutines. 4.1.4.4 Test 4: Making sure the PIC goes through all the subroutines We used a delay of 1 second, as well as LED’s to make sure the code went through all the subroutines. The LED’s were supposed to go high whenever the code entered a particular subroutine. After making sure the subroutines worked correctly, we tested the actual output of the PIC. 4.1.4.5 Test 5: Outputting the correct 2-bit code depending on the distance When all the subroutines worked, we connected the output of the PIC to 2 LED’s and check whether we were getting the correct code that would go into the analog multiplexer. After this step worked, we started working on the interrupt subroutines. 4.1.4.6 Test 6: Using interrupts At first we manually activated the interrupt by changing the input from high to low, then back to low when we wanted the code to run normally. Unfortunately, this technique didn’t work because the PIC is very sensitive to voltages change; it changed as we put our finger close to the electric wires. So, to test the interrupt subroutine, we used one extra test PIC. We set the second PIC to send a periodic signal to the first one and observe the behavior of the code using LED’s. Whenever the code went into the interrupt subroutine, a LED went on. When the input was set to 0, the LED went low, which indicates that it went out of interrupt subroutine and resume it’s normal course.