Tracking Fan

Published on February 2017 | Categories: Documents | Downloads: 49 | Comments: 0 | Views: 329
of 19
Download PDF   Embed   Report

Comments

Content

Cool O2 Automatic Sensor Fan

A report on a project performed for ME 106 - Mechatronics
San Jose State University
Department of Mechanical and Aerospace Engineering

By:

Yan Kin Chan
Peter Vuong
Andy Yip
Saurabh Gupta

May 16, 2006

Table of Contents
Summary ............................................................................................................................. 2
Introduction......................................................................................................................... 3
Design Details..................................................................................................................... 4
Results & Recommendations............................................................................................ 11
References......................................................................................................................... 13
Appendices........................................................................................................................ 14

1

Summary
An auto on/off fan was built based on a temperature sensor, two motion sensors, a fan,
and a servo. The fan turns on when the ambient temperature reaches a certain degree. The
motion sensors are used to track a person’s movement which then the servo will rotate
the fan toward that movement accordingly. A microcontroller was used to control the
overall operation of this fan. A program has been written and downloaded into the
microcontroller to control the temperature for powering on/off, and to control the degree
of rotation of the servo as it receives signals from the motion sensors.

The temperature sensor and the motion sensors send out a voltage to the microcontroller
which then we regulated so that it would not overload the microcontroller. These voltages
are then used as signals for giving commands to the microcontroller. Then, the
microcontroller, which is also connected to the fan and the servo, sends out voltages
(signals) back to the fan and servo allowing it to power on and off. The fan turns on only
when there is a signal sent to the fan.

From this project, we learned the difficulty in programming the microcontroller, the time
and effort professional engineers spent on producing a quality satisfactory product. When
programming the microcontroller, we encountered many problems such as debugging,
setting the servo to run, letting the motion sensor to run smoothly, and etc. In addition,
we learned more about servos, sensors, and other mechanical interfacing devices.

2

Introduction
Mechatronics is one of the fastest growing fields in the engineering industry.
Mechatronics is the combination of the fundamental mechanical engineering knowledge
of mechanical as well as electrical engineering. We can see this great engineering
application almost everywhere and everyday. For example, on washing and drying
machine, there are temperature sensors, timer, and other devices that are all connected
and controlled by a micro-controller that allows users to adjust the time, speed, and even
the temperature at which the machine operates. On HVAC designs, air conditioners have
implemented sensors that detect the temperature of the surrounding which send signals to
a controller that regulate the powering of the machine. Our objective of this project is to
build a device that has at least one sensor and one actuator that is controlled and operated
by a microcontroller.
The main concept of our project is to design a fan which power on itself as the it
detects movement and if the surrounding temperature has reach a certain degree. It also
has two motion sensors that track the person’s movement. The overall design operates
under a microcontroller that controls a servo, a fan, two motion sensors, and one
temperature sensor. The temperature sensor is actually a thermal resistor which changes
its resistance according to the surrounding temperature. The two motions sensors that we
used were the SonaSwitch Ultrasonic sensors. The sensors act as a speaker as well as a
microphone. It sends out signal up to a range of 7 feet, and as the signal bounces back as
it detects an object, the microphone receive that signal and sends out a voltage to the
microcontroller. The Futaba S3003 standard servo is used in conjunction with the motion
sensors to direct the fan towards the moving object. Again, the whole functionality of the
fan is controlled by a microcontroller where a program code has been downloaded into.
3

Design Details
The two key components of the design were the temperature sensor and the motion sensor. The
temperature sensor allowed for the fan to turn on automatically when the ambient temperature
reached greater than the threshold temperature. The motion sensor detected motion within a
vicinity of six feet allowing the fan base to rotate and point towards the user. Figure 1 shows the
prototype that was presented. Shown in the figure is a 60 mm fan attached on top of the Futaba
FP-S148 servo. Two Sonaswitch motion sensors were placed in plastic sensor holders which
were fastened to the wooden base. The wooden base housed the breadboard and the Atmega 128
microcontroller. The NTC thermistor which is not shown in the figure was located at the other
end of the wooden base. Detailed schematic diagrams of each of the subsystems are described
below.

Figure 1. Prototype of Cool O2 Automatic Sensor Fan Prototype of the project that was presented during the
fair. A 60 mm fan was attached on top of the Futaba FP-S148 servo. Two Sonaswitch motion sensors were placed in
plastic sensor holders which were fastened to the wooden base. The wooden base housed the breadboard and the
Atmega 128 microcontroller. The thermistor which is not shown in the figure was located at the other end of the
wooden base.

4

A temperature sensor circuit was constructed on the breadboard. The key component used in the
construction of the temperature circuit was the NTC thermistor. The thermistor is a temperature
sensitive resistor. A negative temperature coefficient unit was used, that is, the resistance
decreased with an increase in temperature. The datasheet for the NTC thermistor is attached in
Appendix B. The temperature sensor circuit was built such that the temperature and resistance
had a relationship of 1°F = 0.1V. Thus, the circuit output a voltage of 7.5 V at a temperature of
75°F . The NTC thermistor does not have a linear relationship with temperature. However, for
the narrow range of 75°F to 95°F required for this application, the relationship was sufficiently
linear. At room temperature of 70°F, the thermistor had a resistance of 50kΩ. At body
temperature of 98.6°F, the thermistor had a resistance of 36 kΩ. The schematic of the
temperature sensor is shown in Figure 2. The circuit can be divided into two main sections of opamp 1 and op-amp 2. The op-amp 1 section contained an inverting amplifier which converted the
variable resistance of the thermistor to a variable voltage. The op-amp 2 section contained an
inverting summing op-amp which provided a voltage offset allowing for the output voltage to be
proportional to temperature. An increase in ambient temperature caused a decrease in resistance
of the thermistor, resulting in an increase in Vout of the circuit.

5

Figure 2. Temperature Sensor Schematic The temperature sensor consisted of a thermistor which changed its
resistance as a function of ambient temperature. An increase in temperature caused a decrease in the resistance of the
thermistor and subsequently an increase in Vout.

A threshold temperature circuit was built to allow the user to set the temperature at which the fan
would automatically turn on. Figure 3 shows the schematic of the threshold temperature circuit.
In this case, the feedback resistor was set at 1KΩ and a trimpot resistor was used as a R1. A
trimpot resistor is a resistor with an adjustable resistance. Using a trimpot for R1 allowed the user
to adjust the threshold temperature to their liking. The gain of an non-inverting op-amp is given
as follows: Vout = Vin[1 + Rf/R1]. Thus, if a user wanted the fan to turn on at a higher
temperature, he or she would simply decrease the trimpot resistance resulting in an increase in
Vout. Alternatively, if the user wanted the fan to turn on at a lower temperature, he or she would
increase the resistance of the trimpot resistance resulting in a decrease in Vout.

6

Figure 3. Threshold Temperature Circuit Schematic A threshold temperature circuit set the temperature at
which the fan would automatically turn on. The circuit consisted of a non-inverting amplifier. A trimpot was used as
R1 which allowed the user to adjust the threshold temperature. Increasing the resistance of the trimpot will decrease
the value of Vout causing a lower threshold temperature. Alternatively, decreasing the resistance of the trimpot will
increase the value of Vout causing a higher threshold temperature.

The next circuit that was constructed was the comparator circuit. The comparator compared the
output voltage from the temperature sensor and the output voltage from the threshold
temperature circuit and switched its output to indicate the larger value. A standard LF741 opamp was used as a comparator. When the output voltage from the temperature sensor circuit was
greater than the output voltage from the threshold temperature circuit, the op-amp output +5 V.
When the output voltage from the temperature sensor circuit became smaller than the output
voltage of the threshold temperature circuit, the op-amp output -5 V. The output of the
comparator was connected to the power supply of the 60 mm fan. A diode was connected
between the output of the op-amp and the fan which allowed the current to flow in only one
direction. Thus, the fan would automatically power on with +5 V when the output voltage of
temperature sensor circuit was higher than the threshold temperature circuit.

7

Figure 4. Comparator Circuit The comparator circuit compared the two output voltages from the temperature
sensor and threshold temperature circuit and returned the higher output. The output of the comparator was connected
to the power of the fan. When the voltage of the output temperature reached higher than the threshold temperature
circuit, the fan automatically powered on with 5V.

The prototype also incorporated two SonaSwitch Mini S motion sensors which detected motion
within a vicinity of six feet and rotated the servo motor accordingly. The SonaSwitch motion
sensor consists of a transmitter and a receiver. The transmitter sends out ultrasonic waves which
are either reflected back to the receiver or depart from the sensor range. The datasheet of the
SonaSwitch motion sensor is attached in Appendix B. Figure 5 shows the schematic of the
SonaSwitch Mini S motion sensor [1]. 5 V was supplied to pin 7 and pin 6 was held to ground.
Pin 2, the NPN open collector output was connected to the microcontroller. As the motion sensor
detected motion, a 20mV signal was sent to the microcontroller which made the connected pin
low. Alternatively, when no motion was detected, a 5 V signal was sent to the microcontroller
which made the pin high. A program was downloaded to the Atmega 128 microcontroller
allowing the servo to rotate when a 5 V signal was returned to the microcontroller. The copy of
the programming code is attached in Appendix A.

8

Figure 5. Sonaswitch Mini S Motion Sensor Schematic of the Sonaswitch Mini S motion sensor is shown. Pin
2, the NPN open collector output was connected to the microcontroller. A 5 V signal was returned to the
microcontroller when the motion senor did not detect any motion. The sensor returned a 20mV signal to the
microcontroller when the sensor detected motion. Pin 6 was held to ground and a 5V power supply was supplied to
pin 7.

The servo motor served as the base of the fan as the 60 mm fan was attached on top of the servo.
As the motion sensor detected motion, the servo motor and fan rotated to point in the direction of
the user. The Atmega 128 microcontroller sent a stream of pulse-width modulated control signals
in order to rotate the servo. In order to keep the servo from jittering, the 74HC4017 decade
counter was used. The schematic of the 74HC4017 decade counter is shown in Figure 6 [2]. The
yellow wire attached to the servo carried the control signal and was connected to pin 2 on the
decade counter. +5 V was supplied to the red wire on the servo while the black wire was held to
ground.

Figure 6. 74HC4017 Decade Counter The 74HC4017 decade counter was wired between the servo and the
microcontroller connection. The signal line of the servo was connected to pin 2. Pin 14 was connected to PB6
(OC1B) and pin 15 was connected to PB2. Pin 13 was held to ground and +5 volts was applied to pin 16.

9

Figure 7 shows the block diagram of the prototype. The comparator compared the two output
voltages from the temperature sensor and threshold temperature circuit and output a voltage to
indicate the higher value. If the voltage form the temperature sensor circuit was greater than the
threshold voltage, the fan would be automatically powered on with +5 volts. The SonaSwitch
Mini S motion sensor was used to for the rotating of the fan base to point towards the user. When
no motion was detected, a 5 volt signal was sent from the SonaSwitch sensor to the
microcontroller which made the pin high. While the pin was kept high, the program downloaded
onto the microcontroller sent a pulse width modulation signal to rotate the servo.

Figure 7 Block Diagram of the Prototype The block diagram of the prototype is shown. The two main
components of the project were the temperature and motion sensors. The block diagram shows that the servo motor

10

rotated even when the ambient temperature was below the threshold temperature. Further improvements can be
made to the system such that the servo motor only rotates when the ambient temperature is greater than the threshold
temperature.

Results & Recommendations
The prototype of the Cool O2 Automatic Sensor Fan did perform as planned. The temperature
sensor worked flawlessly. The threshold temperature was set at 95°F in order to show the
operation of the temperature sensor. When the thermistor was touched and a body heat of 98.6°F
was applied, the fan automatically powered on with +5 volts from the output of the comparator
circuit.

The motion sensor design worked as well, but had a few quirks. The original design was that the
servo motor would rotate and the fan would point towards the user as soon as the motion sensor
detected motion. However, the prototype that was produced was setup such that the servo motor
would rotate when the user walked outside of the motion sensor range. When the pin on the
microcontroller went high, the servo would rotate to point the fan towards the user. Ideally, the
servo should have rotated when the pin on the microcontroller went low. Another problem was
rotation of the servo motor. The servo would rotate between the two sensors six times before
turning off for 20 seconds. After the 20 seconds, the servo would function normally for six more
rotations. Due to the lack of time, this problem could not be investigated.

Future improvements can be made to the project. The project was built such that the servo motor
rotated when the motion sensors did not detect any motion. The design could be modified so that
the servo motor rotates as soon as the motion sensors detect motion. If the block diagram is
reviewed, it can be seen that the temperature sensor circuit and motion sensor circuit are not
connected. This means that the servo currently rotates as long as the motion sensors are active

11

even if the ambient temperature is below the threshold voltage. For future work, the output signal
of the comparator should be sent to a pin on the microcontroller which activates the motion
sensor only when the ambient temperature is greater than the threshold voltage. Currently, the
servo rotates between two positions to point the fan towards the user. An improvement that can
be made is to have the servo rotate between three positions. Thus, when both the sensors detect
motion, the servo would point towards the center position. Another simple yet effective
improvement could be to implement an LCD thermometer. The output of the temperature sensor
circuit could be sent to a LCD digital voltage readout and converted to the corresponding
temperature to display the ambient temperature. This would allow the user to read the current
temperature and know when the fan will automatically power on.

12

References
1.

EDP Company, “SonaSwitch” (n.d.). Retrieved May 10, 2006 from:
http://www.edpcompany.com/sonaindex.html

2.

Furman, B.J., “Interfacing a Servo” (2005). Retrieved May 10, 2006 from:
http://www.engr.sjsu.edu/bjfurman/courses/ME106/ME106pdf/servo-atmel.pdf

13

Appendices
Appendix A – Programming Code
Shown below is the programming code downloaded onto the microcontroller that allowed the
servo motor to rotate depending on the state of the pins.
#include <avr/io.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include <avrlibdefs.h>
#include <avrlibtypes.h>
#define RC_Reset PB2

uint16_t RCpulse[10], *iRC;
void InitRCout(void);
void StartRCout(void);
void SetServo(int,int);
int main(void)
{
DDRA=0x00;//set input
PORTA=0xff;//ultrasonic sensor
DDRB=0xff;//set output
PORTB=0xff;//servo

PORTB=PINA;
while(1)
{
switch(PINA)
{
case 0xfe://if it detects the one on left
sei();//servo turns left
InitRCout();
StartRCout();
SetServo(0,1000);
break;
case 0xfd:
//if it detects the one of right
sei();//servo turns right
InitRCout();
StartRCout();
SetServo(0,2000);
break;
14

}
}
return 0;
}
// Servos are connected to pins 1,3,5,7,9
// Dead time on pins 2 (after 1),4 (after 3) ,6 (after5), 8 (after 7), 0 (after 9)
// Channel must be 0-4 maps to 1,3,5,7,9
// value is from approx 500 (0.5 ms) to approx 2500(2.5 ms)
void SetServo(int channel, int value)
{
int period= 5000;
int index= channel*2+1;
// Temporarily disable interrupts
unsigned char tmp = SREG;
cli();
RCpulse[index]= value;
index++;
if (index == 10) index= 0;
RCpulse[index]= period - value;
// Reenable interrupts if they were on before
SREG = tmp;
}
void InitRCout(void)
{
unsigned char i;
//
// High Speed Counter settings: CLK/8 normal.5us resolution
//
TCCR1A = (1<<COM1B1);
TCCR1B = (1<<CS11);
sbi(DDRB,2);
sbi(DDRB,6);
for (i= 0; i< 5; i++) SetServo(i, 1500); // Puteveryone at neutral (1.5 ms).
}
void StartRCout(void)
{
unsigned char tmp = SREG;
cli();
PORTB |= BV(RC_Reset); // Reset counter (set out0 high)
OCR1B = TCNT1; // Capture our start time reference
PORTB &= (char)~BV(RC_Reset);
SREG = tmp;
iRC = &RCpulse[0]; // Point to firstentry
TIMSK |= BV(OCIE1B); // Enable Compare on match interrupt

15

}
SIGNAL(SIG_OUTPUT_COMPARE1B)
{
// PORTC++;
if( (iRC == &RCpulse[0]) )
{
PORTB |= BV(RC_Reset);
PORTB &= (char)~BV(RC_Reset);
}
TCCR1A &= (char)~_BV(COM1B0); // Clear on match
TCCR1C |= _BV(FOC1B); // Force
OCR1B += *iRC++; // Calculate time to next compare.
TCCR1A |= _BV(COM1B0); // Set on match
if (iRC > &RCpulse[9])
{
iRC = &RCpulse[0];
}
}

16

Appendix B – Datasheets
Datasheet of the NTC thermistor:

17

Datasheet of the SonaSwitch Motion Sensor:

18

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close