0% found this document useful (0 votes)
24 views10 pages

Tracking Objek

The document describes a project to create a motion sensing and tracking system using PIR sensors and a servo motor. The system is designed to keep a person centered in a webcam frame as they move around a room. It uses 4 PIR sensors to detect motion in different areas and a servo motor to rotate the webcam. When a sensor detects motion, the Arduino controller sends a signal to the servo motor to rotate the webcam toward that area. The system demonstrates tracking a person moving between the sensor areas. Challenges addressed include sensor wiring, coding for reliable tracking, and sensor overlap. Future work could include more sensors and a second servo for up/down pitching.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views10 pages

Tracking Objek

The document describes a project to create a motion sensing and tracking system using PIR sensors and a servo motor. The system is designed to keep a person centered in a webcam frame as they move around a room. It uses 4 PIR sensors to detect motion in different areas and a servo motor to rotate the webcam. When a sensor detects motion, the Arduino controller sends a signal to the servo motor to rotate the webcam toward that area. The system demonstrates tracking a person moving between the sensor areas. Challenges addressed include sensor wiring, coding for reliable tracking, and sensor overlap. Future work could include more sensors and a second servo for up/down pitching.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Motion sensing and tracking with PIR sensors and servo motor

By: Jhi Yong Loke and Xu Zheng


May 1, 2016
Motivation
While at home doing chores, video chatting with friends and relatives should be more convenient
without having to move the angle of the camera manually. The same can be said about self-
videotaping (e.g. skateboarding tricks, project demonstrations, etc). The motivation behind this
project is to design a product that provides a simple way of keeping a person’s position in the
middle of the webcam’s frame while he or she walks around the room doing chores.

Problem definition
The product has to detect and track a moving person autonomously while keeping the person in
the middle of the camera’s frame.

Project components
The design of the tracking system is divided into 3 major components:
 Turning base – to provide the rotational motion
 Sensors – to detect the movement of a person
 Controller – to control the orientation of the rotational motion corresponding to the
activation of the sensors.

Material selection
 Turning base
A generic servo motor was chosen because it is cheap. Furthermore, the servo motor
satisfies the needs of the project, since the webcam provided is not heavy. Apart from the
servo motor, pan/tilt brackets were required to mount the webcam to the motor.

 Sensors
PIR (Passive Infrared) sensors were selected as the sensors for motion tracking because
they are cheap and they are capable of sensing human’s radiation (Infrared) up to 10
meters of range. A total of 4 PIR sensors were required for this project.

 Controller
An Arduino Uno microcontroller was chosen because it was already available at the
beginning of the project and it satisfies the needs of the project for controlling purposes.

Working principle (PIR sensor)


PIR Sensor: The PIR sensor is the core component of the system. The working principle is based
on infrared (IR) radiation. The PIR sensor has two slots with each slot made of a special material
that is sensitive to IR. When a warm body like a human or animal passes by on front of the
sensor, it first intercepts one half of the PIR sensor, which causes a positive differential change
between the two halves. When the warm body leaves the sensing area, the reverse happens,
whereby the sensor generates a negative differential change. These differential pulses are the
signals being detected. Figure 1 describes the working mechanism of the PIR sensor. The sensor
(Figure 2) is widely used in security system to detect the motion of human. [1]
Figure 2 – PIR sensor
Figure 1 – Working mechanism of a PIR sensor

Detailed design
The webcam is screw mounted to the pan/tilt brackets which are attached to the servo motor. The
servo motor is connected to the Arduino Uno microcontroller which commands it to turn the
brackets, consequently turning the camera in the yaw axis. The angle of rotation is limited to 0,
60, 120, 180 degrees since only 4 PIR sensors were used. The direction of rotation determined by
which one of the 4 PIR sensors, connected to the microcontroller, is interrupted by a person’s
movement. Figure 3 is the circuit diagram developed on Fritzing.

Figure 3 – Circuit diagram

In regards to the power budgeting, the Arduino Uno microcontroller does not have sufficient
current to operate the servo, thus a separate power source (5V) is required to power the servo
alone. Nevertheless, another power source (5V) is sufficient to power the microcontroller and all
4 of the PIR sensors. It is important to note that the servo has to be grounded to both the power
source and the microcontroller’s ground.
Figure 4 shows the preliminary setup of the system. Figure 5 shows the end product with
isolating hoods.

Figure 4 – Preliminary setup Figure 5 – End product (with isolating hoods)

Appendix A includes the code programmed in Arduino Integrated Development Environment


(IDE).

Demonstration
Figures 6 to 9 demonstrate how the device senses and tracks a person moving from the first to
the last PIR sensors’ position in a clockwise direction. Furthermore, the figures show the 4
angles of orientations of the webcam.

Figure 6 – Activation of the first PIR sensor (0 degrees angle of orientation)


Figure 7 – Activation of the second PIR sensor (60 degrees angle of orientation)

Figure 8 – Activation of the third PIR sensor (120 degrees angle of orientation)

Figure 9 – Activation of the fourth PIR sensor (180 degrees angle of orientation)
Challenges
1. Coding
The major challenge lies in the coding portion of the project. A total of 5 coding
iterations were made to develop a reliable system. The main problem that occurred was
that the servo motor turns back and forth a couple of times before settling at the desired
orientation when a person moves from one position to another. This can be explained by
the fact that the view factor of the sensors is relatively wide. The issue was mitigated by
introducing a “counter” for each sensor. The controller counts the number of times a
sensor sees the person and averages the counts, then turns the servo to that particular
direction. Appended below are segments of the code showing the how averaging of the
counters works.
For(int count = 0; count < 100; count++ ){
pirVal_1 = digitalRead(PIR1);
}... (do the same for other PIR sensors)

if(pirVal_1 == HIGH){
count1 = count1 + 1;
ave1 = 7*ave1/10 + 3*count1/10;
}... (do the same for other PIR sensors)

if(ave1 > (ave2 && ave3 && ave4)){


Serial.println("Motion Detected on PIR 1");
pos = pos1;
}... (do the same for other PIR sensors)

servo.write(pos); //turns the servo motor to the defined angle of


rotation

2. Wiring
The customized wiring connectors loosen fairly easily and would sometimes disconnect
from the sensor. The problem was solved by soldering the wire to the connectors.

3. Quality and reliability of the PIR sensors


The first batch of PIR sensors that was purchased did not include internal pull up resistors
which necessitated more parts, increasing complexity. Similarly, a couple of the PIR
sensors were found faulty such that they sent signals to the microcontroller continuously
although there was nobody in front of it. Furthermore, the wires disconnect very easily
from the circuit board. A new batch of PIR sensors from another vendor was purchased to
fix the problem.

4. Overlapping of the sensors


The PIR sensors have relatively wide-angle sensing capabilities such that when a person
is sufficiently close to the sensors, more than 1 of the sensors would eventually see the
person, creating erroneous results. Isolating hoods (Figure 10) were created to mitigate
the problem.

Figure 10 – Isolating hood

Future work
1. Incorporate more PIR sensors for more angles.
2. Adding 1 more servo motor for pitching angles.

Conclusion
The goal of this project is to design and implement a human motion-detecting and tracking
system. The system is accomplished by incorporating a generic servo motor, 1 pan/tilt brackets,
4 PIR sensors and an Arduino Uno microcontroller. The system is limited to 4 yaw orientations
(0, 60, 120, 180 degrees) since only 4 PIR sensors were used. The generic servo motor is suitable
for the scope of this project project because it is easy to program and it has relatively precise
position control capabilities. The Arduino microcontroller is suitable because it is reliable in
receiving the signals from the PIR sensors, at the same time controlling the servo motor’s
rotation.

References
[1] https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/how-pirs-work

Appendix A
Appended below is the code.
//Motion sensing and tracking using PIR sensors and servo motor
//By: Jhi Yong Loke and Xu Zheng
//May 1, 2016

#include <Servo.h>
Servo servo;

//attach PIR to the designated pins


int PIR1 = 4;
int PIR2 = 5;
int PIR3 = 6;
int PIR4 = 7;
/////////////////////////////////////////////////////////////////////////////
//initialize the signal values from the PIR sensors
int pirVal_1;
int pirVal_2;
int pirVal_3;
int pirVal_4;
/////////////////////////////////////////////////////////////////////////////

//initialize the counters which counts the duration of which the person
stands in front of the sensors
float count1;
float count2;
float count3;
float count4;
/////////////////////////////////////////////////////////////////////////////
//initialize the average of the counters
float ave1;
float ave2;
float ave3;
float ave4;
/////////////////////////////////////////////////////////////////////////////

int pos; //initialize the angle of rotation


int pos1 = 180; //position for PIR 1
int pos2 = 120; //position for PIR 2
int pos3 = 60; //position for PIR 3
int pos4 = 0; //position for PIR 4
/////////////////////////////////////////////////////////////////////////////

void setup(){
Serial.begin(9600);
servo.attach(9); // Attaches the servo to pin 7
pinMode(PIR1, INPUT);
pinMode(PIR2, INPUT);
pinMode(PIR3, INPUT);
pinMode(PIR4, INPUT);
}
/////////////////////////////////////////////////////////////////////////////

void loop(){
//loop for counting the overall duration a person is in front of each PIR
sensor
for(int count = 0; count < 100; count++ ){
pirVal_1 = digitalRead(PIR1);
pirVal_2 = digitalRead(PIR2);
pirVal_3 = digitalRead(PIR3);
pirVal_4 = digitalRead(PIR4);

if(pirVal_1 == HIGH){
count1 = count1 + 1;
ave1 = 7*ave1/10 + 3*count1/10; //counts the average duration a person is
in front of the PIR sensor
}
else{}

if(pirVal_2 == HIGH){
count2 = count2 + 1;
ave2 = 7*ave2/10 + 3*count2/10; //counts the average duration a person is
in front of the PIR sensor
}
else{}

if(pirVal_3 == HIGH){
count3 = count3 + 1;
ave3 = 7*ave3/10 + 3*count3/10; //counts the average duration a person is
in front of the PIR sensor
}
else{}

if(pirVal_4 == HIGH){
count4 = count4 + 1;
ave4 = 7*ave4/10 + 3*count4/10; //counts the average duration a person is
in front of the PIR sensor
}
else{}
}
/////////////////////////////////////////////////////////////////////////////

//determines which PIR sensor the person is in front of the longest


if(ave1 > (ave2 && ave3 && ave4)){
Serial.println("Motion Detected on PIR 1");
pos = pos1; //defines the corresponding angle of rotation
}
else{}

if(ave2 > (ave1 && ave3 && ave4)){


Serial.println("Motion Detected on PIR 2");
pos = pos2; //define the corresponding angle of rotation
}
else{}

if(ave3 > (ave1 && ave2 && ave4)){


Serial.println("Motion Detected on PIR 3");
pos = pos3; //define the corresponding angle of rotation
}
else{}

if(ave4 > (ave1 && ave2 && ave3)){


Serial.println("Motion Detected on PIR 4");
pos = pos4; //define the corresponding angle of rotation
}
else{}
/////////////////////////////////////////////////////////////////////////////

servo.write(pos); //turns the servo motor to the defined angle of rotation


/////////////////////////////////////////////////////////////////////////////

//sets the counts, the averages and the signal values back to 0 for the next
loop
count1 = 0;
count2 = 0;
count3 = 0;
count4 = 0;
ave1 = 0;
ave2 = 0;
ave3 = 0;
ave4 = 0;

pirVal_1 = LOW;
pirVal_2 = LOW;
pirVal_3 = LOW;
pirVal_4 = LOW;
/////////////////////////////////////////////////////////////////////////////
}

You might also like