Autonomous and Remote Control Robot
by Psuedohim in Circuits > Raspberry Pi
3166 Views, 5 Favorites, 0 Comments
Autonomous and Remote Control Robot
This robot build is meant to be relatively cheap and quick. Here is what you will need to get started:
Hardware
- 1 Raspberry Pi
- 1 Dual H-Bridge Motor Driver
- 1 Buck Converter
- 2 3V-6V DC Motors
- HC-SR04 Ultrasonic Sensor
Other
- A box to act as a chassis
- My box is 7.5" x 4" x 2"
- A hot glue gun
- A knife or pair of scissors
- A soldering iron
Obtain a Box
Try to find a box that fits all of your hardware without leaving too much room. A box that measured 7.5" x 4" x 2" fit all of my components perfectly.
Cut Holes for Motors
Cut out holes on both sides of the body so that it is possible to make a connection between the wheels and the motors.
Solder Leads Onto Motor Connections
Most DC motors will come with small loops to which you will need to make a connection. Soldering the wires onto the loops is the best way to ensure a strong connection.
The leads will be connected to the outputs on the H-Bridge driver.
Glue Motors Inside of Box
Using hot glue, place your motors in the box so that they secure against the corners. Apply a generous amount of glue and be sure to hold in place until glue has stiffened.
Connect H-Bridge to Motors
Connect the leads that are coming off of the motors to the outputs on the H-Bridge. See ( https://www.bananarobotics.com/shop/How-to-use-the-L298N-Dual-H-Bridge-Motor-Driver ) for more information on the L298N H-Bridge.
Solder Leads Onto Buck Converter
To power the H-Bridge I will be using 2 1s lipo batteries. At full charge these batteries put out over 8V when connected in series. I do not need my motors running so quickly so I use the buck converter to bring the voltage down to 5V. No matter what you are using to power the H-Bridge you will need to run a common ground from the H-Bridge to your Raspberry Pi.
If you are using a power source that is in the range of 4V - 7V then you may not need to use a buck converter. In this case, the leads coming from the power source can be connected directly to the H-Bridge. However, you will still need to run an extra wire from ground on the H-Bridge to a ground pin on the Raspberry Pi.
Install Buck Converter
Find a spot to glue your buck converter into. Make sure you have access to the small screw located on the top of the board. We will be using this screw to adjust the output voltage.
Install LIPO Batteries
WARNING! Improper use of lipo batteries can lead to bodily harm or destruction of property. Make sure you fully understand the ins and outs of lipo batteries before implementing them in any project.
To secure my lipo batteries in place I used a velcro like material on the inside of the lid. This makes sure they cannot be easily poked or punctured by a pin.
Install HC-SR04 Ultrasonic Sensor
Wiring
If you would like to be able to copy the code from github and use it without any issues then you must wire your robot exactly as I am going to describe.
Dual H-Bridge
IN1 - GPIO 2
IN2 - GPIO3
IN3 - GPIO 4
IN4 - GPIO 17
Ultrasonic Sensor
VCC - 5V GPIO
TRIG - GPIO 27
ECHO - GPIO 22
The echo pin outputs 5 volts, the GPIO pins on the pi are only rated for 3.3 volts. Giving a GPIO 5 volts may cause damage to the pi. To avoid this we will put a voltage dividing circuit between ECHO and GPIO 22. To learn how to make a voltage divider, refer here.
Software
First off, you will need to have raspbian installed onto your Raspberry Pi. For more information on installing raspbian onto your Pi, check out this installation guide.
Once raspbian is booted up you will want to ssh into the raspberry pi. Here is a good guide on how to do so securely.
Once you have ssh'd into the pi, install git and 'clone' the files from this link:
https://github.com/Psuedohim/ARCRobot/tree/master/ARCRobot-1
This can be accomplished via:
git clone https://github.com/Psuedohim/ARCRobot/tree/master...
Finally to run the program, get into the ARCRobot-1 directory and run python3 go_auto.py.