Arduino Autonomous Robot (Land Rover / Car) Stage1Model2

by RajeshJ1 in Circuits > Arduino

4353 Views, 19 Favorites, 0 Comments

Arduino Autonomous Robot (Land Rover / Car) Stage1Model2

20141004_004652.jpg

Mid August 2014 - I decided to pursue Robotics and build a large humanoid robot.
This robot would be built in several stages. Stage 1 is to build a Land Rover. Model1 in
Stage1 was the Land Rover without Microcontroller while Model2 is one with Microcontroller.
Attached are details of Microcontroller based Land Rover - I have made the rover from
scratch, including design the source code. The target to complete Model2 was mid October.
I'm glad this was completed earlier, thanks to the holidays in early October.

Purchased the Chassis That Can Accommodate Either 4 Wheels or 2 Wheels and a Castor

20141003_223801.jpg

I purchased most of the material, including this chassis from Vega Kit and Visha Electronics at Lamington Road, Mumbai, India

Reverse of the Chassis

20141003_223808.jpg

Attached the 2 DC Motors to Chassis

20141003_225851.jpg

Attached the 2 DC Motors (Geared 300 RPM BO motor) to both front clamps. I have
extended the wires from the motors through holes in the Chassis so can reuse the motors as I
deem fit, later, for other models

Connected the Castor

20141003_230004.jpg

The Castor Wheel I Bought Had a Cover So Attached the Same

20141003_230041.jpg

L239D - Motor Driver Kit

20141003_230406.jpg

L239D Motor Driver kit. Standard (and more expensive) motor driver shields for
Arduino are available on EBay and other Marketplaces. These are very easy to program with the readymade code available easily on Internet. I used the tougher route and got this kit from Electronic
Component Shop at Lamington Road, Mumbai, which is economical and will let me make my own
code as per my circuit design.

FYI, Motor Driver circuit is needed to control the power delivered to the motor as motors
take much more current and voltage than Microcontrollers and if we don't use Motor driver
circuit, Microcontroller would blow off in the process of trying to power the motors.

One Pager Received With Motor Driver Kit

20141003_230441.jpg

The one pager I received with the Motor driver kit. A lot of research on Google and
various forums on Motor Driver Shields and Kits and use of common sense made me realize that
there are 2 inputs for each motor. These inputs would come from Arduino

Battery Holder

20141003_230536.jpg

I got this from Simple Labs. You too can order it online.

The Battery Holder Comes With ON-OFF Switch

20141003_230548.jpg

This battery holder comes with ON-OFF switch, which is helpful in turning power ON
and OFF to the motor driver kit.

Motor Driver Kit Has PWM to Control Motor Speed

20141003_231244.jpg

Close up of the motor driver kit shows EN pins which are used for PWM (Pulse Width
Modulation) i.e. to control the voltage to the motors their by controlling the motor speed.

I wanted the enable to be high i.e. full voltage to be given to the motor to make my
program easy. I did not have a jumper and wanted to complete my Model2 robot today so made
one through the 2 yellow single strand wires which I soldered to the EN pins

Enable Pins Shorted Through Homemade Jumper

20141003_232605.jpg

Arduino Compatiple (but Better) Board

20141003_232956.jpg

Induino R3 board. This is Arduino compatible board with more components and better
control. I had bought this in January 2014 so decided to use the same for my robot. It is available from Simple Labs and you can order the same online like I did.

Used Jumper Cables to Connect Motor Input to Arduino Board

20141003_233245.jpg

I used jumper cables to connect the Motor Input connections so these can be easily connected to the Microcontroller board

Motor Driver Kit Connected to Arduino

20141003_233340.jpg

Motor inputs connected to Pin8 to Pin11 of the Microcontroller. I can control the
logic level of these Pins thus control the HIGH (Logic 1) or LOW (Logic 0) value being
shared with Motor Input connections thereby control not only the direction of current and
hence direction of the motor but also switch the current to motor ON or OFF thus start or
stop the motor

The Motor Output Connections on the Motor Driver Kit Are Connected to Cables Connected to the Motors

20141003_234433.jpg

Both Boards Placed on the Chassis

20141003_235045.jpg

Placed the 2 boards on the chassis with bubble wrap under it to ensure the metal chassis does not short the boards via the metallic underside of the board (metallic due to soldering.)

Arduino IDE

20141003_235231.jpg

Started the Arduino IDE - a place that enables us to write programs in English like language that are then transferred to the Microcontroller using USB cable.

Program for Autonomous Bot

20141003_235608.jpg

The program - it is a simple program that allows the bot to move forward for 3 seconds, halt then move backwards for 3 seconds, turn right for 3 seconds and then turn left for 3 seconds. I developed this program after about 15 hours of R&D. The great advantage of this program is that all my subroutines for moving forward, backward, turning, stopping, etc. are ready which would help me immensely in upcoming Models.

I have attached the program:

void setup() {
pinMode(8, OUTPUT); // Input1 of Motor1 set on Pin 8 of Arduino
pinMode(9, OUTPUT); // Input2 of Motor1 set on Pin 9 of Arduino

pinMode(10, OUTPUT); // Input1 of Motor2 set on Pin 10 of Arduino
pinMode(11, OUTPUT); // Input2 of Motor2 set on Pin 11 of Arduino

}
void loop() {
Halt(); // Stop both motors. This gives smooth motion by avoiding jumping of the motor while changing rotation immediately
Forward(); // Calling Forward Function which in turn calls Forward1 & Forward2 functions

delay(3000); // Delay of 3 seconds
Halt(); // Stop the Robot

delay(250); // Delay of 0.1 Seconds before starting any motor again to ensure smooth motion (no kick)

Reverse(); // Calling Reverse Function which in turn calls Reverse1 & Reverse2 functions

delay(3000); // Delay of 3 seconds
}
void Forward() { // Move Robot Forward i.e. both Motors moves Forward
Forward1(); // Motor1 moves Forward
delay(150); // Delay of 0.15 Seconds before second motor starts to avoid loading the batteries
Forward2(); // Motor2 moves Forward

}
void Reverse() { // Move Robot backwards i.e. both Motors moves Reverse
Reverse1(); // Motor1 moves backwards
delay(150); // Delay of 0.15 Seconds before second motor starts to avoid loading the batteries
Reverse2(); // Motor2 moves backwards

}
void Halt() { // Both Motors Stop (Not Break which is abrupt halt)
Halt1();
Halt2(); // Stop both motors. This gives smooth motion by avoiding jumping of the motor while changing rotation immediately

}

void Forward1() { // Motor1 moves Forward (Clockwise direction)
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
}
void Forward2() { // Motor2 moves Forward (Clockwise direction)
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
}
void Reverse1() { // Motor1 moves Reverse (Anti Clockwise)
digitalWrite(8, LOW);
digitalWrite(9, HIGH);

}
void Reverse2() { // Motor2 moves Reverse (Anti Clockwise)
digitalWrite(10, LOW);
digitalWrite(11, HIGH);

}
void Halt1() { // Motor1 Stop (Not Break which is abrupt halt)
digitalWrite(8, LOW);
digitalWrite(9, LOW);

}
void Halt2() { // Motor2 Stop (Not Break which is abrupt halt)
digitalWrite(10, LOW);
digitalWrite(11, LOW);

}
void Stop1() { // Motor1 Break i.e. abrupt halt
digitalWrite(8, LOW);
digitalWrite(9, LOW);

}
void Stop2() { // Motor2 Break i.e. abrupt halt
digitalWrite(10, LOW);
digitalWrite(11, LOW);

}

Spacers - Professional Feel and Helps Route Wires Easily

20141004_004416.jpg

Spacers - It is best to use these to separate the PCB from the metal chassis. These not only give a professional feel to the final product but also help in routing of the wires in the spaces between the board and chassis.

PCB (in This Case Microcontroller) With Spacers

20141004_004425.jpg

Downloading the Program From Laptop to Arduino Board

20141004_004550.jpg

Downloading the program from Laptop (remember the program we developed in the Arduino IDE?)

The Autonomous Bot

20141004_004652.jpg

Independent unit without laptop or USB cable. The Microcontroller board is powered by a 9v battery while the Motor Driver is powered by the Batteries in the Battery holder - this is because the Microcontroller board takes up a few tens of mA of current while the Motor Driver board and the DC Motors connected to the driver board take up 100's of mA of current which cannot be provided by the Power OUT Pin of the Microcontroller.

I have kept the power supplies separate in this model. In future models there would be one power supply.

Video of the Bot