Infrared Motion Detector TOP
The motion detector circuit consists of two components, the emitter and the sensor/detector. The emitter is simply made up of an infrared emitting diode reverse biased to a 5-volt source. The sensor uses the MRD821 to detect the IR beam from the emitter. It outputs a high of around 9 to 10-volts when the IR beam shines directly to it. If the beam is cut, it outputs a low of around 0.4 to 2-volts. This signal is fed into pins 2 and 6 of a 555 timer, which in turn outputs the amplified signal at pin 3. The output is a TTL low when the IR beam is continuous and TTL high when the beam is cut. (Actually, outputs of about 6 to 7-volts are sometimes measured. A de-amplifier could be added at the end of the circuit to make sure the output does not exceed TTL levels.)
The schematic diagram of both emitter and detector are shown in figure 1. There are three pairs of such sensors interfaced to the computer through the printer port. In order for motion to be sensed, a moving object must simultaneously trigger at least two of the detectors signifying that it has moved from one point to another. If the sensors have established motion, the controlling program proceeds to the appropriate routine.
TOP
Figure 1. Schematic diagram of IR Motion Detector emitter and detector circuit.
TOP
// IR Array Program Driver Program
// Decoding is done via software
int irmotion(){
int count=0,trigger=0,sensor=0; //initialize trigger & count flag
int motion[3]={0x00,0x00,0x00}; //initialize array for sensor status
outportb(0x37a,0x08); //get mux's attention
outportb(0x37a,0x08); //get mux's attention
do{
sensor=0;
sensor=inportb(0x379); //get value at this port
sensor=sensor & 0x70; //mask it
motion[0]=sensor & 0x10; //assign status of each sensor
motion[1]=sensor & 0x20; //as an element in motion array
motion[2]=sensor & 0x40;
if(motion[0]==0x10){ //at least 2 sensors must be triggered
if(motion[1]==0x20 || motion[2]==0x40) //detect motion
trigger++;
}
if(motion[1]==0x20){
if(motion[0]==0x10 || motion[2]==0x40)
trigger++;
//if motion is detected, trigger flag is incremented
}
if(motion[2]==0x40){
if(motion[0]==0x10 || motion[1]==0x20)
trigger++;
}
count++; //increment count every pass to this function
delay(30);
}while(count!=2 && trigger!=2);
return trigger; //if trigger=2, main function should
//go to routine that deals with presence of intruder
}
|