Submitted To:
Dr. Stefan Andrei
Lamar University
Department of Computer Science
08/12/2014
Group Members:
Garrett Bourque
Kanchandeep Kaur
Pooja Aryal
Pedro Velez
Pranay Reddy Peddireddy
Russell Alphin
Sagar Bonthu
Saya Reddy Bijjur
Shaomin Zhang
Shireesh Babu Doosa
Yingho Xu
Yu Wu
1
Abstract
This paper describes how we implemented and examined the development of an embedded
system, namely the A4WD1 v2 Rover. It is a robot manufactured by RobotShop Distribution Inc.
which acquired Lynxmotion, Inc. in 2012. RobotShop Distribution Inc. is a U.S. company
specialized in designing a great variety of programmable embedded systems, especially robots.
The main objective of the project is to implement an autonomous A4WD1 v2 Rover, from
assembling, programming and testing. During the testing, the rover moves forward, backward,
left or right. It also can avoid obstacles which are detected by the sensors. We divided our team
into four groups. Some students were responsible for the assembly of the rover, which was the
initial phase of our project. After the rover was assembled, the software was implemented to
enabled the robot to perform the desired operations. At the same time, some students designed
the project's website, others were involved in programming the rover's code, and the remaining
students wrote the final report. While working on this project, our team experienced certain
challenges during implementation phase that delayed testing of the rover's functionalities. But at
the end, we overcame those challenges by working together while gaining knowledge about how
to implement an embedded system.
2
Acknowledgement:
We would like to express our deep gratitude and appreciation to our instructor, Dr. Stefan Andrei,
for his guidance and support throughout the project. The project would not have been successful
without his motivation, support, and expertise. We would like to express our deepest appreciation
to all who provided us the opportunity to complete this report. This project has helped us gain
knowledge about embedded systems, and it helped further develop our programming skills.
3
T a b l e Of Con t e n t
S.no TOPIC PAGE No.
1. Introduction.........................................................................5
2. Hardware Implementation...................................................7
2.1 Hardware Specification......................................................7
2.2 Assembly.............................................................................9
3. Source code............................................................................17
4. Conclusion and future works...............................................29
5. References............................................................................30
4
1. INTRODUCTION:
An embedded system is a system that has software (firmware) embedded into computer-
hardware. An embedded system can be a dedicated system or application, or it can be part of an
application or of a larger system. It has a dedicated function within a larger mechanical or
electrical system, often with real-time computing constraints. Some embedded systems use a real
time operating system which supervises the application software tasks running on the hardware
and organizes the accesses to system resources according to priorities and timing constraints of
tasks in the system. Many appliances likes watches, microwaves, Video Camera Recording
(VCR), cars use embedded systems.
Lynxmotion Aluminum 4WD1 v2 Robot Kit by RobotShop Distribution Inc.
The Lynxmotion Aluminum 4WD1 Robot Kit by RobotShop Distribution Inc. is a robust,
modifiable, and expandable chassis for remote control or autonomous robot experimentation.
The robot chassis is made from heavy-duty anodized aluminum structural brackets and ultra-
tough laser-cut Lexan panels. It includes four 12.0vdc 30:1 gear head motors and four 4.75inches
tires and wheels.
The robot has excellent traction by utilizing popular remote controlled (R/C) truck tires and
wheels. It uses two small NiMH battery packs and a Sabertooth 2x12.00 R/C motor controller.
There are additional decks available that can be added to expand it's functionality. The decks can
5
be stacked on top of each other, so we can add as many as the application require. The robot is
capable of carrying up to a 5lb payload. This version of the robot uses a Bot Board II, a Basic
Atom Pro and three GP2D12 distance sensors for obstacle detection and avoidance.
The robot is compatible with the following batteries and chargers.
Chargers & Accessories
6.0 - 12vdc Ni-CD & Ni-MH Universal Smart Charger (USC-02)
Batteries
12.0 Volt Ni-MH 1600mAh Battery Pack (BAT-01)
12.0 Volt Ni-MH 2800mAh Battery Pack (BAT-01)
6.0 Volt Ni-MH 1600mAh Battery Pack (BAT-03)
6.0 Volt Ni-MH 2800mAh Battery Pack (BAT-05)
2. H ARDWARE IMPLEMENTATION
2.1SPECIFICATIONS:
The A4WD1 v2 Rover consists of following hardware.
a) A4WD1 v2 Rover Body Kit
The A4WD1 v2 Rover chassis is made from heavy-duty anodized aluminum structural brackets and ultra-tough laser-cut Lexan panels. The chassis of the robot is expandable. The body's rectangular shape allows us to mount the four servo motors on its four corners, the servo controller on the bottom, and Bot Board II on the top side of the Body Kit.
b) Bot Board II
The Bot Board II is the best carrier board for the Basic Atom, or any other 24 or 28 pinmicrocontrollers. It has an onboard speaker, three buttons and three LEDs, a Sony PS2controller port, a reset button, logic and servo power inputs, an I/O bus with power andground, and a 5vdc 250mA regulator. Up to 20 servos can be plugged in directly.
Figure: The Bot Board II Circuit Board
6
c) The BASIC Atom 28 Pin
The powerful Basic Atom is faster and has more memory than a BS2. This chip is easy to program and reliable to use. It can be plugged into the Bot Board for complete access to all of the I/O pins. It is BS2 Pin Compatible and includes O'Scope and In Circuit Debugger (ICD).
d) Sabertooth 2X12.00(SSC-32 Servo Controller)
The Sabertooth 2X12.00 has 32 channels of 1uS resolution servo control. The Sabertooth 2X12.00 supports bidirectional communication with Query commands, Synchronized or "Group"moves and 12 built in Servo Hexapod Gait Sequencer, MiniSSC-II emulation.
Figure: Sabertooth 2X12.00 Circuit Board
e) The DB9 Serial Data Cable - 6'
The DB9 Serial Data Cable is used to connect to a Bot Board II or SSC-32 servo controller with the computer in order to configure the A4WD1 v2 Rover.
f) Servo Motors
The motors are efficient and reliable. They have neutral time for robotics use. The electric motors need 12Vdc to operate and have a speed of 200 RPM (revolutions per minute). The motors also have a 30:1 gear reduction ratio.
g) Off Road Robot Tire
The A4WD1 v2 Rover tires are Traxxas Stampede Tera (Model Number: TRC-01). The tire's diameter is 4.75 inches and the width is 2.375 inches. The hubs accept any 6mm output shaft. The total weight of the tires is 0.75 oz.
7
Figure: AW4D1 wheels and tires.
h) 12mm Hex Mounting Hub
In order to mount the four TRC-01 Off Road tires, we used the 12mm hex pattern RC truck hubs.The hubs are compatible with any electric motor that has a 6mm shaft. The hub's model number is HUB-12, and their weight is 0.07 oz each. i) 12.0 Volt Ni-MH 2800mAh Battery Pack
The rover uses a 2800mAh Ni-MH 12Vdc battery pack to reduce the total weight compared to a similar Ni-Cad battery pack. The installed battery pack is the BAT-06.
The specification of the A4WD1 Rover is as follows. Overall Length: 12.00" Overall Width: 13.50" Tire Height: 4.75" Chassis Length: 9.75" Chassis Width: 8.00" Chassis Height: 4.00" Ground Clearance: 1.63" Weight: 4lbs 6 oz. Speed: 36" per second.
2.2 ASSEMBLY
For the rover to function well, it is very important to implement the hardware properly. We followed various steps to assemble the hardware components. They are as follows:
Step 1:
Mounting the motor: In order to connect the motor, the red wire is connected to the positive battery terminal (+) and the yellow wire is connected to the negative terminal(-). We used two 3X6 mm screws to mount the motor to the chassis.
8
Step 2:We connected the chassis end brackets using 3mm x 6mm screws.
Step 3: We used four of the 3mm x 6mm screws to attach the bottom lexan panel.
Step 4:We removed the tire-connection screws, and attach the tires as instructed. We verified that the tires treads were aligned properly.
Step 5: We installed the motor controller. We consulted the given instructions when connecting the wiresto the terminals.
Step 6 :
We connected the board and the chip in order to assemble the Botboard II and the SSC -32 processor. When installing the board to rover's chasis we use four .250” 4-40 screws. Once the Botboard II was attached to the chasis, we proceded to install the Atom Pro chip.
3. SOURCE CODE
The language used is BASIC, and the software package has compiler and a linker associated withit. We wrote the firmware using the provided IDE, and after the software being compiled, it wastransferred (loaded) to the rover using the same IDE. The IDE also allowed the team to verify thesensor's detection and range of detection.
Below are the two source codes used for the AW4D1 v2 Rover.
Source code 1: 4WD1AUTO.BAS
This code is used for setting up all the parameters for servos, setting up min, max speed,direction of movement when faced with obstacle, servo pulse out, and basic robot movementloops.
'Program name: 4WD1AUTO.BAS
'Connections
'Pin 16 Jumper to battery (VS)
'Pin 17 Left GP2D12 Sensor (Right facing sensor)
'Pin 18 Right GP2D12 Sensor (Left facing sensor)
'Pin 19 Rear GP2D12 Sensor
'Pin 0 Left Sabertooth channel.
9
'Pin 1 Right Sabertooth channel.
'Pin 12 A Button.
'Pin 13 B Button.
'Pin 14 C Button.
'Pin 9 Speaker.
temp var byte
filter var word(10)
ir_right var word
ir_left var word
ir_rear var word
LSpeed var word
RSpeed var word
minspeed con 1750
maxspeed con 1250
LSpeed = 1500
RSpeed = 1500
low p0
low p1
sound 9, [100\880, 100\988, 100\1046, 100\1175]
main
gosub sensor_check
; Numbers lower than 1500 result in forward direction.
; Numbers higher than 1500 result in reverse direction.
LSpeed = (LSpeed - 10) min maxspeed ;accelerates the motors
RSpeed = (RSpeed - 10) min maxspeed
;
; For testing should include sound when the sensors detect anything
; Need to take a look to see what happens if we change (LSpeed + ir_right)
10
; Added the if endif statements and the sound
if(ir_left > 15) then
sound 9, [100\880, 100\988, 100\1046, 100\1175]
LSpeed = (LSpeed + ir_left) max minspeed ; when something is detected, this decelerates the opposite side
endif
;
; For testing should include sound when the sensors detect anything
; Need to take a look to see what happens if we change (RSpeed + ir_left)
if(ir_right > 15) then
sound 9, [100\880, 100\988, 100\1046, 100\1175]
RSpeed = (RSpeed + ir_right) max minspeed
endif
; if both front sensors are detected
if(ir_left > 15) then
if(ir_right > 15 ) then
sound 9, [100\880, 100\988, 100\1046, 100\1175]
LSpeed = (LSpeed + ir_left) min maxspeed
RSpeed = (Rspeed + ir_right) min maxspeed
endif
endif
;
;
; For testing should include sound when the sensors detect anything
if (ir_rear > 15) then
; included what I believe is sound
sound 9, [100\880, 100\988, 100\1046, 100\1175]
LSpeed = (LSpeed - ir_rear) min maxspeed ;if something is detected behind the robot, accelerates both sides
11
RSpeed = (RSpeed - ir_rear) min maxspeed
endif
; Send out the servo pulses
pulsout 0,(LSpeed*2) ; Left Sabertooth channel.
pulsout 1,(RSpeed*2) ; Right Sabertooth channel.
pause 20
goto main
sensor_check
for temp = 0 to 9
adin 17, filter(temp)
next
ir_right = 0
for temp = 0 to 9
ir_right = ir_right + filter(temp)
next
ir_right = ir_right / 85
for temp = 0 to 9
adin 18, filter(temp)
next
ir_left = 0
for temp = 0 to 9
ir_left = ir_left + filter(temp)
next
ir_left = ir_left / 85
for temp = 0 to 9
adin 19, filter(temp)
next
ir_rear = 0
12
for temp = 0 to 9
ir_rear = ir_rear + filter(temp)
next
ir_rear = ir_rear / 85
serout s_out,i38400,["ir_right - ", dec ir_right, " ir_left - ", dec ir_left, " ir_rear - ", dec ir_rear, "LSpeed - ", dec LSpeed, " RSpeed - ", dec RSpeed, 13]
return
Source code 2: 2_ZigZag.BAS
This code is used for testing the ZigZag movement of robot and the ability to avoid the obstacle.
'Pins: (pin spec is coming from samples)
'Pin 16 Jumper to battery (VS)
'Pin 17 Left GP2D12 Sensor (Right facing sensor)
'Pin 18 Right GP2D12 Sensor (Left facing sensor)
'Pin 19 Rear GP2D12 Sensor
'Pin 0 Left Sabertooth channel.
'Pin 1 Right Sabertooth channel.
'Pin 12 A Button.
'Pin 13 B Button.
'Pin 14 C Button.
'Pin 9 Speaker.
PIN0 con p0
PIN1 con p1
PIN9 con p9
PIN17 con p17
PIN18 con p18
PIN19 con p19
; hi, this is an array.
13
TIMES con 10
ii var word
array var word(TIMES)
; this value is determined by field test and debug prints
; rather than reading the data sheet. so, it might be not
; very accurately correct but it should work well.
THRESHOLD_SENSDIST con 180
sensor_left var word
sensor_right var word
sensor_rear var word
; the speed thresholds are from sample code, and i cannot
; guarantee its correctness. let's see the test results.
;SPEED_MIN con 1250; 1750 ' min speed
SPEED_MAX con 1750; 1250 ' max speed
SPEED_FORWARD con 1550 ;[1500, 1250]
SPEED_FORWDACC con 1700 ;[1500, 1250]
SPEED_BACKWARD con 200 ;[1750, 1500]
SPEED_TURNMAX con 1200;1600 ;1450
SPEED_TURNMIN con 700;1250 ;==ZERO speed.
speed_left var word
speed_right var word
; timer used during turning.
CYCLE con 100 ; supposed to be unit as mili-sec
TIMER_TURN con 10 ; if yes, that is 1 sec
timer var word
14
; a very simple state machine
STATE_INIT con 0
STATE_FORWARD con 1
STATE_TURNLEFT con 2
STATE_TURNRIGHT con 3
STATE_BACKWARD con 4
STATE_FORWDACC con 5
state var word
; here the program executes
; first, init of course
low PIN0
low PIN1
sound PIN9, [100\880, 100\988, 100\1046, 100\1175]
; and now, start the state machine
state = STATE_INIT;
; main() of this program, based on the state machine
main ;()
if (state = STATE_INIT) then
; just go straight forward
state = STATE_FORWARD;
endif
; check the sensors
gosub sensor_check
15
if (state <> STATE_BACKWARD) then
if ((sensor_left > THRESHOLD_SENSDIST) AND (sensor_right > THRESHOLD_SENSDIST)) then
; there is an obstacle infront of me
; so, try to back up.
state = STATE_BACKWARD;
timer = 0;
endif
endif
if (state = STATE_FORWARD) then
; now do something according to the sensors
if (sensor_rear > THRESHOLD_SENSDIST) then
state = STATE_FORWDACC;
timer = 0;
else
if (sensor_left > THRESHOLD_SENSDIST) then
; there is an obstacle at my left hand
state = STATE_TURNRIGHT;
timer = 0;
else
if (sensor_right > THRESHOLD_SENSDIST) then
; there is an obstacle my right hand
state = STATE_TURNLEFT;
timer = 0;
else
; nothing happens, so keep going forward.
speed_left = SPEED_FORWARD;
speed_right = SPEED_FORWARD;
16
endif
endif
endif
endif
if (state = STATE_TURNLEFT) then
speed_left = SPEED_TURNMIN;
speed_right = SPEED_TURNMAX;
if (timer > TIMER_TURN) then
; turning finished, now go forward
state = STATE_FORWARD;
timer = 0;
serout s_out,i38400, [" --LEFT TURN END, FORWARD...-- ", 13];
else
timer = timer + 1;
serout s_out,i38400, [" -<-LEFT-<- ", 13];
endif
endif
if (state = STATE_TURNRIGHT) then
speed_left = SPEED_TURNMAX;
speed_right = SPEED_TURNMIN;
if (timer > TIMER_TURN) then
; turning finished, now go forward
state = STATE_FORWARD;
timer = 0;
serout s_out,i38400, [" --RIGHT TURN END, FORWARD...-- ", 13];
else
17
timer = timer + 1;
serout s_out,i38400, [" ->-RIGHT->- ", 13];
endif
endif
if (state = STATE_BACKWARD) then
speed_left = SPEED_BACKWARD;
speed_right = SPEED_BACKWARD;
if (timer > TIMER_TURN) then
; backing finished, now go, er, left
state = STATE_TURNLEFT;
timer = 0;
serout s_out,i38400, [" --BACKING END, ER, TURN-LEFT...-- ", 13];
else
timer = timer + 1;
serout s_out,i38400, [" -.-BACKING-.- ", 13];
endif
endif
if (state = STATE_FORWDACC) then
speed_left = SPEED_FORWDACC;
speed_right = SPEED_FORWDACC;
if (timer > TIMER_TURN) then
; backing finished, now go, er, left
state = STATE_FORWARD;
timer = 0;
serout s_out,i38400, [" --ACCELARATING END, FORWARD...-- ", 13];
else
18
timer = timer + 1;
serout s_out,i38400, [" -+-ACCELARATING-+- ", 13];
endif
endif
; in case the speeds are out of limits.
;speed_left = speed_left min SPEED_MIN;
speed_left = speed_left max SPEED_MAX;
;speed_right = speed_right min SPEED_MIN;
speed_right = speed_right max SPEED_MAX;
if (state = STATE_TURNLEFT) then
serout s_out,i38400, [" B-<-<-<- sl=", dec speed_left, " sr=", dec speed_right, 13];
endif
if (state = STATE_TURNRIGHT) then
serout s_out,i38400, [" B->->->- sl=", dec speed_left, " sr=", dec speed_right, 13];
endif
if (state = STATE_BACKWARD) then
serout s_out,i38400, [" B-.-.-.- sl=", dec speed_left, " sr=", dec speed_right, 13];
endif
; finally, send out the servo pulses
pulsout PIN0,(speed_left *2);
pulsout PIN1,(speed_right*2);
; wait, why multiply by 2 ???
; i donnot know, see what happens..
if (state = STATE_TURNLEFT) then
19
serout s_out,i38400, [" E-<-<-<- "];
endif
if (state = STATE_TURNRIGHT) then
serout s_out,i38400, [" E->->->- "];
endif
if (state = STATE_BACKWARD) then
serout s_out,i38400, [" E-.-.-.- "];
endif
pause CYCLE;
goto main
; a subroutine, to read the sensors.
sensor_check ;()
for ii = 0 to (TIMES - 1)
adin PIN18, array(ii);
next
sensor_left = 0;
for ii = 0 to (TIMES - 1)
sensor_left = sensor_left + array(ii);
next
sensor_left = sensor_left / TIMES;
for ii = 0 to (TIMES - 1)
adin PIN17, array(ii);
next
sensor_right = 0;
for ii = 0 to (TIMES - 1)
sensor_right = sensor_right + array(ii);
next
20
sensor_right = sensor_right / TIMES;
for ii = 0 to (TIMES - 1)
adin PIN19, array(ii);
next
sensor_rear = 0;
for ii = 0 to (TIMES - 1)
sensor_rear = sensor_rear + array(ii);
next
sensor_rear = sensor_rear / TIMES;
4. CONCLUSION
In this project, our team went through the whole process of implementing an autonomousA4WD1 v2 Rover, starting with the assembly, and finishing with the programming and testing ofthe rover. During operation, the rover moves forward, backward, left, and/or right. It is alsocapable of avoiding obstacles detected by the sensors.
During the implementation of the A4WD1 v2 Rover, the team faced with some obstacles thatprevented them from adding all the desired functionality. The first and major obstacle found wasthe incompatibility of the charger with the 12Vdc battery pack. This cause delays in testing sincewe did not have a charged battery to verify the firmware's accuracy. Another limitation found bythe team was that the A4WD1 v2 Rover's sensors are unable to detect some obstacles along it'spath.
Aside from the fairly small obstacles faced by the team, the A4WD1 v2 Rover allowed us to gainexperience implementing an embedded system and gave the students team work experiences thatcan be applied in conjunction with the knowledge gain in the project.
5. REFERENCES
1. Dr. Stefan Andrei: Lectures notes for ‘Embedded Systems’ Class (COSC-430101/COSC-5340-01), Summer of 2014: Embedded Systems. Lamar University, Department of Computer Science, Beaumont, Texas
2. http://en.wikipedia.org/wiki/Rover_%28space_exploration%29
3. http://www.lynxmotion.com/driver.aspx?Topic=assem05
4. http://galaxy.lamar.edu/~sandrei/Johnny5/
5. http://www.superdroidrobots.com/ATR_std2.aspx
21