Omnidirectional Car With Obstacle Detection

by ishandon1 in Circuits > Arduino

861 Views, 5 Favorites, 0 Comments

Omnidirectional Car With Obstacle Detection

123.jpg
456.png

"This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)"

In this instructible, I will show you how to build your own omnidirectional car with obstacle detection.

Supplies

Step 1: Understanding the L293D Motor Driver Shield and the Ultrasonic Sensor

L293d.png
Ultrasonic sensor.png

Before we start building the actual obstacle avoiding robot car, let’s take a look at the motor driver shield. The control of the motors is done through an L293D motor driver shield which uses two L293D driver chips and a shift register. It also has some power breakout pins, pins to connect two servos and a breakout for IO pin 2. Oddly, pin 2 and pin 13 are unused by the board but only pin 2 has a breakout for a solder joint. For this project, we will use the analog pins on the motor driver as they are all usable.

You’ll need to solder some female pin headers to the power pins along the bottom of the shield and one for pin A0 and one for pin A2.


The object sensing is done by an ultrasonic sensor that uses ultrasonic sound waves to measure the distance to an object by timing how long it takes the pulse to bounce off of the object and return to the sensor. Because we know the speed that sound waves travel through air, we can use the time it takes a pulse to return to the sensor to calculate the object’s distance using the formula: Distance = Pulse Time x Speed of Sound In Air / 2

We need to divide by two since the pulse travels to the object and then back to the sensor, so it is traveling twice the object’s distance.

Each of the four wheels on the obstacle avoiding car is driven by a geared DC motor, you will need to attach a short power lead to each with some pins to screw into the terminals on the shield.

Step 2: Assembling the Car

Base Plate.png
Top Plate.png
Servo Holder.png

I have designed a simple chassis for the car to be 3D printed.

There are three printed components, the top and bottom plate sections and then a holder for the ultrasonic sensor.

The Arduino can be screwed on the base plate and the servo can be screwed on the top plate.

The base plate and the top plate can be screwed together.

Step 3: the Wiring

L293d top.jpg

Be sure to properly solder the header pins on the Motor driver for good connection.

Step 4: Understanding the Movement of Mecanum Wheels

mecanum.jpg

Mecanum wheels have rollers positioned at 45 degrees from the axis of rotation. This transfers the force from the rotation of the wheel by the motor 45 degrees from the axis of rotation. When you power each wheel independently and vary the speed and direction the wheels rotate, you can achieve omnidirectional motion.

Step 5: Programming the Arduino

1.png
2.png

The code is set to make the car have 2 modes - Manual and autonomous.

Triangle button on the controller will cycle between the 2 modes.

4 libraries are needed for this code to work, PS4 controller library, USB host shield library, motor driver library and the servo library.

Firstly, all functions needed for autonomous driving are defined before the loop.

If statements are used to give tasks to buttons on the controller.

The code is further explained with comments in the INO file that is attached.

Downloads