Professional Documents
Culture Documents
Report
Report
Report
CAPSTONE PROJECT I
TOPIC: HUMAN FOLLOWING ROBOT
CONTENTS
1. INTRODUCTION..............................................................................................................................1
1.1 Abstract..................................................................................................................................1
1.2 Objective................................................................................................................................1
2. THEORY...........................................................................................................................................2
3. IMPLEMENT..................................................................................................................................14
4. RESULT..........................................................................................................................................23
5.1 Conclusion............................................................................................................................23
5.2 Application............................................................................................................................23
6. REFERENCE...................................................................................................................................24
2
Capstone project 1
Instructor: Huynh Thai Hoang
1. INTRODUCTION
1.1 Abstract
For a robot that operates autonomously, the interaction between the person and
the robot is the major factor. In order for a robot to communicate and interact with the
person, it should also be capable of following that particular person. Keeping this in
mind, there should be a capacity in the robot to get information from the surroundings
while pursuing the required object. The primary goal of our work was to design and
fabricate a robot that not only tracks the target but also moves towards it while doing
the tracking. The main hindrance in this kind of work is that the detection of the target
is a sensitive thing to carry out. The object has to be unique for the robot to recognize it
and carry out the objective. An ultrasonic sensor is used to protect the robot from
collision with the object and keep a constant distance between human and robot. All the
processing is carried out by the microprocessor while the control of the motors is
carried out by the controller.
1.2Objective
Robotic technology has increased appreciably in the past couple of years. Such
innovations were only a dream for some people a couple of years back. But in this rapid
moving world, now there is a need for robots such as “A Human Following Robot” that
can interact and co-exist with them.
Robot requires a mechanism to perform this task accurately. This helps the
individual to envision and act accordingly. The robot has to be intelligent enough to
obey a human in crowded places, a vibrant setting, indoors and outdoors places.
Typically, human following robots are equipped with several different diverse
combination of sensors i.e... light detection and ranging sensor, radio frequency
identification module (RFID), laser range finder (LFR), infrared (IR) sensing modules,
thermal imaging sensors, camera, wireless transmitter/receiver etc. for recognition and
locating the target. All the sensors and modules work in unison to detect and follow the
target.
1
Capstone project 1
Instructor: Huynh Thai Hoang
The capability of a robot to track and follow a moving object can be used for
several purposes.
● To help humans.
● To create ease for people.
● Can be used for defense purposes.
2. THEORY
2.1 Sensor
What is Ultrasonic?
Human ears can hear sound waves that vibrate in the range from about
20 times a second (a deep rumbling noise) to about 20,000 times a second (a
high-pitched whistling). However, ultrasound has a frequency of over 20,000 Hz
and is therefore inaudible to humans.
The sensor is small, easy to use in any robotics project and offers excellent
non-contact range detection between 2 cm to 400 cm (that’s about an inch to 13
feet) with an accuracy of 3mm.
2
Capstone project 1
Instructor: Huynh Thai Hoang
Operating Voltage DC 5V
Operating Current 15 mA
Max Range 4m
Min Range 2 cm
Dimension 45 x 20 x 15mm
HC-SR04 Pinout
VCC: is the power supply for HC-SR04 Ultrasonic distance sensor which we
connect the 5V pin on the STM32F103C8T6
Echo: pin produces a pulse when the reflected signal is received. The length of
the pulse is proportional to the time it took for the transmitted signal to be detected.
3
Capstone project 1
Instructor: Huynh Thai Hoang
allowing the receiver to differentiate the transmitted pattern from the ambient
ultrasonic noise.
The eight ultrasonic pulses travel through the air away from the transmitter.
Meanwhile the Echo pin goes HIGH to start forming the beginning of the echo-back
signal.
In case, if those pulses are not reflected back then Echo signal will timeout after
38ms and return low. Thus, a 38mS pulse indicates no obstruction within the range of
the sensor.
If those pulses are reflected back the Echo pin goes low as soon as the signal is
received. This produces a pulse whose width varies between 150 µS to 25 mS,
depending upon the time it took for the signal to be received.
The width of the received pulse is then used to calculate the distance to the
reflected object.
Formula:
These types of radiations are invisible to our eyes, which can be detected by an
infrared sensor. The emitter is simply an IR LED (Light Emitting Diode) and the detector
is simply an IR photodiode that is sensitive to IR light of the same wavelength as that
emitted by the IR LED. When IR light falls on the photodiode, the resistances and the
output voltages will change in proportion to the magnitude of the IR light received.
Working Principle
4
Capstone project 1
Instructor: Huynh Thai Hoang
This sensor includes an IR LED & an IR Photodiode, so by combining these two
can be formed as a photo-coupler otherwise optocoupler.
IR LED is one kind of transmitter that emits IR radiations. This LED looks similar
to a standard LED and the radiation which is generated by this is not visible to the
human eye. Infrared receivers mainly detect the radiation using an infrared transmitter.
These infrared receivers are available in photodiodes form. IR Photodiodes are
dissimilar as compared with usual photodiodes because they detect simply IR radiation.
Different kinds of infrared receivers mainly exist depending on the voltage, wavelength,
package, etc.
Active IR Sensor
This active infrared sensor includes both the transmitter as well as the receiver.
In most of the applications, the light-emitting diode is used as a source. LED is used as a
non-imaging infrared sensor whereas the laser diode is used as an imaging infrared
sensor.
These sensors work through energy radiation, received & detected through
radiation. Further, it can be processed by using the signal processor to fetch the
necessary information. The best examples of this active infrared sensor are reflectance
and break beam sensor.
Passive IR Sensor
The passive infrared sensor includes detectors only but they don’t include a
transmitter. These sensors use an object like a transmitter or IR source. This object
5
Capstone project 1
Instructor: Huynh Thai Hoang
emits energy and detects through infrared receivers. After that, a signal processor is
used to understand the signal to obtain the required information.
Controlling a DC Motor
In order to have a complete control over DC motor, we have to control its speed
and rotation direction. This can be achieved by combining these two techniques.
PWM is a technique where the average value of the input voltage is adjusted by
sending a series of ON-OFF pulses.
The average voltage is proportional to the width of the pulses known as Duty
Cycle.
6
Capstone project 1
Instructor: Huynh Thai Hoang
The higher the duty cycle, the greater the average voltage being applied to the DC
motor (High Speed) and the lower the duty cycle, the less the average voltage being
applied to the DC motor (Low Speed).
An H-Bridge circuit contains four switches with the motor at the center forming
an H-like arrangement.
Closing two particular switches at the same time reverses the polarity of the
voltage applied to the motor. This causes a change in spinning direction of the motor.
Control Pins
7
Capstone project 1
Instructor: Huynh Thai Hoang
For each of the L298N’s channels, there are two types of control pins which allow
us to control speed and spinning direction of the DC motors at the same time viz.
Direction control pins & Speed control pins.
Using the direction control pins, we can control whether the motor spins
forward or backward. These pins actually control the switches of the H-Bridge circuit
inside L298N IC.
The module has two direction control pins for each channel. The IN1 and IN2
pins control the spinning direction of the motor A while IN3 and IN4 control motor B.
The speed control pins viz. ENA and ENB are used to turn the motors ON, OFF
and control its speed.
Pulling these pins HIGH will make the motors spin, pulling it LOW will make
them stop. But, with Pulse Width Modulation (PWM), we can actually control the speed
of the motors.
The module usually comes with a jumper on these pins. When this jumper is in
place, the motor is enabled and spins at maximum speed. If you want to control the
8
Capstone project 1
Instructor: Huynh Thai Hoang
speed of motors programmatically, you need to remove the jumpers and connect them
to PWM-enabled pins on the stm32f103c8t6.
5V: pin supplies power for the switching logic circuitry inside L298N IC.
ENA: pins are used to control speed of Motor A. Pulling this pin HIGH will make the
Motor A spin, pulling it LOW will make the motor stop.
IN1 & IN2: pins are used to control spinning direction of Motor A. When one of them is
HIGH and other is LOW, the Motor A will spin. If both the inputs are either HIGH or LOW
the Motor A will stop.
IN3 & IN4: pins are used to control spinning direction of Motor B. When one of them is
HIGH and other is LOW, the Motor B will spin. If both the inputs are either HIGH or LOW
the Motor B will stop.
9
Capstone project 1
Instructor: Huynh Thai Hoang
ENB: pins are used to control speed of Motor B. Pulling this pin HIGH will make the
Motor B spin, pulling it LOW will make the motor stop.
2.3.1 Features
■ Core: ARM 32-bit Cortex™-M3 CPU – 72 MHz, 90 DMIPS with 1.25 DMIPS/MHz –
Single-cycle multiplication and hardware division – Nested interrupt controller with 43
maskable interrupt channels – Interrupt processing (down to 6 CPU cycles) with tail
chaining.
■ Clock, reset and supply management – 2.0 to 3.6 V application supply and I/Os – POR,
PDR, and programmable voltage detector (PVD) – 4-to-16 MHz quartz oscillator –
Internal 8 MHz factory-trimmed RC – Internal 32 kHz RC – PLL for CPU clock –
Dedicated 32 kHz oscillator for RTC with calibration.
■ Low power – Sleep, Stop and Standby modes – VBAT supply for RTC and backup
registers.
■ DMA – 7-channel DMA controller – Peripherals supported: timers, ADC, SPIs, I 2Cs and
USARTs.
10
Capstone project 1
Instructor: Huynh Thai Hoang
■ Up to 7 timers – Up to three 16-bit timers, each with up to 4 IC/OC/PWM or pulse
counter – 16-bit, 6-channel advanced control timer: up to 6 channels for PWM output
Dead time generation and emergency stop – 2 x 16-bit watchdog timers (Independent
and Window) – SysTick timer: a 24-bit down counter.
11
Capstone project 1
Instructor: Huynh Thai Hoang
12
Capstone project 1
Instructor: Huynh Thai Hoang
13
Capstone project 1
Instructor: Huynh Thai Hoang
14
Capstone project 1
Instructor: Huynh Thai Hoang
Flow chart
3. IMPLEMENT
15
Capstone project 1
Instructor: Huynh Thai Hoang
By using the travel time and the speed of the sound, we can calculate the
distance between the sensor and the obstacle.
16
Capstone project 1
Instructor: Huynh Thai Hoang
Prescaler is set to 72 -> This will divide the APB clock by 72, and bring the timer
clock to 1 MHz. It is necessary because the HCSR04 sends the signal in microseconds.
ARR is set to 0xffff -> I have selected is as maximum as possible. This basically
sets the limit, up to which we can count in microseconds.
Also make sure the TIMx Capture Compare interrupt is enabled. You can enable
the Global interrupt also, if you don’t see this option
17
Capstone project 1
Instructor: Huynh Thai Hoang
Pin PA8 -> is automatically selected as TIM1_CH1 pin. I will use it as the ECHO
Pin
Pin PA9 -> will be used as TRIG Pin, so select it as the output.
Formula for calculating values for pwm generating is not very complex, it only
requires in depth knowledge of the stm32f103 clock, timer structure and timer
18
Capstone project 1
Instructor: Huynh Thai Hoang
registers. I divided the formula and method in steps and it is very easy to calculate the
values. Below formula for calculating the value’s for generating specific pwm signals.
Timer Tick Frequency: is the frequency at which the timer is completing its one
instruction cycle.
Counter Frequency: is the frequency at which we want our timer tick counter
to increment.
19
Capstone project 1
Instructor: Huynh Thai Hoang
Note: Pwm Resolution and Timer Prescaler are 16-bit registers their value must not exceed
65535.
Now looking at the final formula we need two things in it. Timer Prescaler Value and Pwm
Resolution(Steps). You can assign Timer Prescaler Value or Pwm Resolution(Steps) a fixed
value and calculate the other perimeter.
20
Capstone project 1
Instructor: Huynh Thai Hoang
Stm32f103c8t6 has 4, 16 bit timers, Timer 1,2,3 and 4. We can use all four
timers for generating pwm(pulse width modulation) signal. Each timer has fixed
pins on which the pwm signal can be output called channels. Timers 1 and 2 are
multiplexed with other peripherals to use their pwm function. We have to make
sure that the timer is not colliding with any other peripheral function.
Timer 3 and 4 are stand alone and they do not collide with any other
peripheral function. So it's good to use them. I am using Timer 4 in the
project/tutorial.
I am using an Internal clock source so check this check box in the timer
settings. I am using timer 4, channel 1 for pwm output so i selected channel 1.
Channel 1 corresponds to PB6 of stm32f103 microcontroller. The settings
diagram is given on the right side.
21
Capstone project 1
Instructor: Huynh Thai Hoang
From the PWM calculation formula in section 3.2.1, now we will calculate the
values pwm signal output for 50 Hz frequency of motor DC.
22
Capstone project 1
Instructor: Huynh Thai Hoang
23
Capstone project 1
Instructor: Huynh Thai Hoang
IR Sensor
H- Bridge (L298N)
16x2 LCD Display and I2C
4. RESULT
5.1Conclusion
5.2Application
● Can assist in carrying loads for people working in hospitals, libraries, airports,
etc.
● Can service people at shopping centers or public areas.
● Can assist elderly people, special children and babies.
● Can follow a particular Vehicle.
24
Capstone project 1
Instructor: Huynh Thai Hoang
5.3 Future work
6. REFERENCE
1. Linux Embedded, “Hướ ng dẫ n lậ p trình PWM vớ i STM32”, Hướ ng dẫ n lậ p
trình PWM vớ i STM32 | Embedded System (hethongnhung.com).
2. Last Minute Engineers, “L298N with DC Motor”, In-Depth: Interface
L298N DC Motor Driver Module with Arduino (lastminuteengineers.com).
3. Last Minute Engineers, “SR04 Ultrasonic Sensor”, How HC-SR04
Ultrasonic Sensor Works & How to Interface It With Arduino
(lastminuteengineers.com).
4. Last Minute Engineers, “
5. Electronics | Project| Focus, “ What is an IR Sensor : Circuit Diagram & Its
Working”, IR Sensor : Circuit Diagram, Types Working with Applications
(elprocus.com).
25