Hi there guys
I am back with another tutorial of the tiva instructables series.
This time it is a TIVA based obstacle avoiding robot made by friends of mine as their semester project.
I hope you will enjoy this one!!!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Introduction
In the animal kingdom, many different critters use whiskers to help them find their way around in the dark, through murky waters, or even to help them hunt prey. Whiskers can be very useful when the animals cannot rely on sight. This project shows you how to build a simple robot that uses whiskers as "bump sensors" to help the robot detect when it is about to bump into an obstacle, so it can turn around and avoid crashing.
Basically, it is designed to move in the forward, left and right directions as per command given by the micro-controller. The motor driver is also controlled by the microcontroller.
This robot can't move in backward direction as Servo can rotate approximately 180 degrees (90 in each direction)
Position "-90": Left
Position "0”: Neutral
Position "90": Right
The movement of the robot has been done
using Differential Drive algorithm. To move forward, both front wheels are moved in the same direction. To move to right, right wheel is stopped and left wheel is moved forward. To move to left, left wheel is stopped and right wheel is moved forward. To stop the robot, both front wheels are stopped.
Step 2: Components Needed:
·> TM4C123G microcontroller
·> L293D motor driver IC
·> HC-SR04 ultra-sonic sensor
·> Robot chassis + 2 DC Motors with holder + 2 Wheels + 1 Castor Wheel + Screws & Nuts
·> SG90-Micro Servo
·> LM7805 voltage regulator + Heat sink
·> 9V/200mAh power battery
·> 5V/200mAh power bank
·> Basic electronics kit contains breadboard, connecting wires etc.
·> Tools: Screw driver, Scissor / Wire stripper
·> Jumper Wires: Male to Male, Male to Female
·> Android Studio(for android app)
·> Keil uVision4
Step 3: Component Details
Now some details regarding the components used in the projects
The first step and the base of our robot is a chassis. The chassis has to include a body, two motors and a switch.
> Ultra-sonic Sensor:
In Order to make a robot that can maneuver by its own we need some sort of an input, so it can "know" or "judge" what to do. a very comfortable sensor that fits our goal (avoiding obstacles) is the Hc-sr04 ultrasonic sensor
Scientific Explanation Of the sensor's action:
What the sensor does it is calculating the distance from an object by sending bursts of ultrasound towards it and measuring the time it takes to the sound waves to get back (Distance = Velocity * Time).
We can use this information in order to determine whether there's a close "obstacle" near the robot and then- avoid it !
Trig: Trigger input of Sensor
Echo: Echo output of Sensor
It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package i.e. from 2cm to 400cm or 1-13 feet.
Operating Voltage: 5V
Ultra-sonic frequency: 40 kHz
> Servo Motor:
A servo motor is an electrical device which can push or rotate an object with great precision. If you want to rotate and object at some specific angles or distance, then you use servo motor.
Servo motor works on PWM (Pulse width modulation) principle, means its angle of rotation is controlled by the duration of applied pulse to its Control PIN. Basically servo motor is made up of DC motor which is controlled by a variable resistor (potentiometer) and some gears.The values of duty cycle of PWM for the three positions (i.e. Neutral, Left, Right) are shown in the figure 4.
> L298N Dual H-Bridge Motor Driver:
This motor driver is used to drive the DC motor with the greater current ratings which Tiva board can’t supply. Two DC motors can be derived from one driver. 9V supply is provided to the controller and 5V can be taken from it for other purposes. If both control signals are at the same level motor is not rotated. And it is rotated if we supply one signal high and the other low in one direction and in reverse direction if the opposite signals are supplied. It is powerful enough to drive motors from 5-35V at up to 2A peak.The pin configuration of the driver is shown in the figure 5.
Figure 1: Tiva MC
Figure 2: Ultrasonic Sensor
Figure 3: Servo motor
Figure 4: PWM
Figure 5: Motor Driver
Step 4: Basic Operation and Circuit
To start measurement, Trig of SR04 must receive a pulse of high(5V) for at least 10μs,this will initiate the sensor will transmit out cycle of ultra-sonic burst at 40kHz and wait for the reflected ultra-sonic burst. When the sensor detected ultra-sonic from receiver, it will set the Echo pin to high (5V) and delay for a period (width) which is proportional to distance. To obtain the distance, measure the width of Echo pin.
Time = width of Echo pulse in μs
Speed of sound = 340ms-1
Distance in cm = Time/58
Distance in inches = Time/148
Microcontroller is needed a minimum of 3.3V and maximum of 4.2V.For this, we used power bank.We used 7805 voltage regulator IC to hold 5V to give supply to pin 16 of motor driver IC for its internal working .Pin 8 of LM93D is connected with the source.
For motor rotation it requires a minimum of 9V, otherwise motor will not rotate.
Step 5: Code
The code has been made on KEIL UVISION4.
The code is simple and clear
Step 6: Summarized Steps
Following are the summarized steps to make this project:
Step 1: Assemble the robot chassis.
Step 2: Program L293D motor driver to control the wheels. Test the wheel movement control.
Step 3: Write a C code to for generating PWM using Timer as Output device and test it by blinking of led that is configured.
Step 4: Modify the PWM code for Servo motor and test its rotation.
Step 5: Write a C code for measuring frequency using Timer as Input device, modify it for Ultra-Sonic sensor and test it.
Step 6: Integrate sensor input to control the bot movement.
Step 8: Test it in the field and celebrate!
Step 7: Special Thanks
I specially thank Miss Bushra Khalid and her group members for sharing their work.
I hope you learnt from this tutorial.
Feel free to ask any question. Stay Tuned :)
Tahir Ul Haq