Spark V Atmega16 Hardware Manual
Spark V Atmega16 Hardware Manual
Spark V Atmega16 Hardware Manual
SPARK V
HARDWARE MANUAL
Version 1.12
JUNE 1st,2016
Notice
The contents of this manual are subject to change without notice. All efforts have been made to
ensure the accuracy of contents in this manual. However, should any errors be detected, NEX
Robotics welcomes your corrections. You can send us your queries / suggestions at
[email protected]
Content of this manual is released under the Creative Commence cc by-nc-sa license. For legal
information refer to: http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
Recycling:
Almost all of the robot parts are recyclable. Please send the robot parts to the recycling plant
after its operational life. By recycling we can contribute to cleaner and healthier environment for
the future generations.
INDEX
1 Introduction..................................................................................................................................6
2 SPARK V ATMEGA16...............................................................................................................7
3 SPARK V Block Diagram........................................................................................................... 8
3.1 SPARK V ATMEGA16 technical specification.................................................................8
4 Using SPARK V Robot............................................................................................................. 10
4.1 Connections.......................................................................................................................11
4.2 Powering up Spark V........................................................................................................ 14
4.3 Power management system on the SPARK V.................................................................. 15
4.4 Battery Charging...............................................................................................................16
4.5 Powering the robot using battery or external supply........................................................ 18
4.6 Battery Maintenance......................................................................................................... 18
4.7 Motion control ..................................................................................................................19
4.8 Position Encoders..............................................................................................................23
4.9 Infrared proximity and Directional light intensity sensors............................................... 26
4.10 Ultrasonic range sensors ................................................................................................. 28
4.11 White Line Sensor............................................................................................................31
4.12 LCD Interfacing............................................................................................................... 33
4.13 Buzzer.............................................................................................................................. 35
4.14 USB Interface...................................................................................................................36
4.15 XBee wireless interface....................................................................................................37
4.16 TSOP1738 IR receiver.....................................................................................................38
4.17 Servo mounted range sensor............................................................................................ 38
4.18 Battery voltage sensing.................................................................................................... 39
4.19 Power Port........................................................................................................................40
4.20 ATMEGA16 microcontroller...........................................................................................41
4.21 Spark V Schematics......................................................................................................... 43
5 Programming Spark V ATMEGA16 Robot.............................................................................. 45
5.1 Installing WIN AVR......................................................................................................... 45
5.2 Installing AVR Studio.......................................................................................................49
5.3 Setting up Project in AVR Studio.....................................................................................53
5.4 Writing your first code in AVR Studio.............................................................................58
5.5 Debugging the code in AVR studio.................................................................................. 60
5.6 Loading your code on robot using AVR Boot loader from NEX Robotics......................62
5.6.1 Boot loader operating principle.................................................................................62
5.6.2 Jumper settings for the boot loading......................................................................... 62
5.6.3 Installing FT232 USB to Serial converter drivers.....................................................63
5.6.4 Identifying COM Port number of the USB to serial .................................................66
5.6.5 Installation and Demonstration of AVR Bootloader.................................................68
5.7 Loading your code on the robot using STK500V2 AVR USB programmer from NEX
Robotics.....................................................................................................................................69
5.8 Loading your code on the robot using ATMEL’s AVRISP mkII Programmer ...............70
5.8.1 Fuse settings for ATMEGA16 microcontroller.........................................................74
6 Pin Functionality........................................................................................................................75
7 PC Based Control Using Serial Communication.......................................................................77
7.1 Communication protocol for simple robot control............................................................77
1 Introduction
Spark V is a low cost robot designed for robotics hobbyists and enthusiasts. It is jointly designed
by NEX Robotics with Department of Computer Science and Engineering, IIT Bombay. Spark V
will help you get acquainted with the world of robotics and embedded systems. Thanks to its
innovative architecture and adoption of the ‘Open Source Philosophy’ in its software and
hardware design, you will be able to create and contribute to, complex applications that run on
this platform, helping you acquire expertise as you spend more time with them.
Safety precautions:
Robot’s electronics is static sensitive. Use robot in static free environment.
Read the assembling and operating instructions before working with the robot.
If robot’s battery low buzzer starts beeping, immediately charge the batteries.
To prevent fire hazard, do not expose the equipment to rain or moisture.
Refrain from dismantling the unit or any of its accessories once robot is assembled.
Never allow NiMH battery to deep discharge.
Mount all the components with correct polarity.
Keep wheels away from long hair or fur.
Keep the robot away from the wet areas. Contact with water will damage the robot.
To avoid risks of fall, keep your robot in a stable position.
Do not attach any connectors while robot is powered ON.
Never leave the robot powered ON when it is not in use.
Inappropriate Operation:
Inappropriate operation can damage your robot. Inappropriate operation includes, but is not
limited to:
Dropping the robot, running it off an edge, or otherwise operating it in an irresponsible
manner.
Interfacing new hardware without considering compatibility
Overloading the robot above its payload capacity.
Exposing the robot to wet environments.
Continuing to run the robot after hair, yarn, string, or any other item has become
entangled in the robot’s axles or wheels.
All other forms of inappropriate operation.
Using robot in areas prone to static electricity.
Read carefully paragraphs marked with caution symbol.
2 SPARK V ATMEGA16
Spark V robot is based on ATMEGA16 microcontroller. It has 3 analog white line sensors, 3
analog IR Proximity sensors, 3 directional light intensity sensors and Battery voltage sensing.
Robot has support for 3 MaxBotix EZ series ultrasonic range sensors. It also has support for the
servo mounted sensor pod which can be used to make 180 degrees scan for the map making.
Robot can be powered by 6 AA size rechargeable Ni-MH batteries. Robot has built-in Smart
Battery Controller which charges the battery in intelligent way and also monitors the battery
charge level when robot is in operation. Robot has on-board FT232 based true USB to serial TTL
converter. Robot programming is done using NEX Robotics Bootloader via USB port. There is
no need to use external programmer. Robot has 2x16 alphanumeric LCD, Lots of LED indicators
and Buzzer etc. for quick debugging. Robot has on-board socket for XBee wireless module for
Multi robot and robot to PC communication. Robot has two low power 60 RPM DC geared
motors which are powered by L293D motor driver with the top speed of 66cm/second.
Note: You need to buy MaxBotix EZ series ultrasonic range sensors, XBee wireless module and
rechargeable NiMh Batteries separately.
Programming: Using NEX Robotics Boot loader via USB port (no need of separate
programmer)
Sensors:
Three white line sensors
Three IR proximity sensors
Three directional light intensity sensors
Two Position Encoders (optional)
MaxBotix EZ series ultrasonic range sensors (optional)
Servo mounted Ultrasonic Range Sensor (optional)
Battery voltage sensing
Indicators:
2 x 16 Characters LCD
Indicator LEDs
Buzzer
Battery low indication
Locomotion:
Two 60 RPM DC geared motors and caster wheel as support
Built-in clutch for protection of the motors from non continuous wheel stalling.
Top Speed: 66cm/second
Operational Modes:
Standalone (Autonomous Control)
PC as master and robot as slave
Distributed (multi robot communication)
Communication:
USB Communication using FT232 USB to Serial Converter
Simplex infrared communication (From infrared remote to robot)
ZigBee (IEEE 802.15.4) (Wireless) (Robots to Robots and Robots to PCs )(Optional)
Dimensions:
Diameter: 15cm
Height: 7cm
Power:
6 AA size NiMH rechargeable batteries (Batteries not included)
Onboard Smart Battery Controller charges the battery in intelligent way and also monitors the
battery charge level when robot is in operation.
Locomotion:
Two 60 RPM DC geared motors and caster wheel as support
Built-in clutch protection for the motors from non continuous stalling of the wheel
Top Speed: 66cm/second
Optional Accessories:
Servo mounted Ultrasonic range sensor for 180 degree scan
Servo mounted directional light intensity sensor for 180 degree scan
Two position encoders
MaxBotix EZ series ultrasonic range sensors
XBee wireless module
Software Support:
GUI Based control, AVR studio, WINAVR
Microsoft robotics studio Visual Programming Language (will be launched shortly)
Requires:
AC adaptor with exact 12VDC with 1Amp. current rating for battery charging.
6 NiMH rechargeable batteries
4.1 Connections
Battery Controller:
When robot is powered up, smart battery monitoring circuit monitors the battery voltage and if it
drops below 7V, it starts giving beeping sound and battery status indicator led blinks with red
color.
When robot is off and 12V DC is applied to the battery charging socket, Smart battery
monitoring circuit charge the battery.
Robot has on-board battery controller which charges robot’s battery. Use any AC adaptor /
SMPS which can give precise 12V supply with at least 1 amp current. If voltage is more than
12V the battery will not get fully charged.
Now smart battery controller will sense the presence of the battery charging supply and will start
charging the battery. It will terminate the battery charging once battery is fully charged. During
the charging process battery status can be monitored on the battery status LED. Refer to the table
below for battery charging status interpretation using battery status LED.
Important:
If you are using battery which is not used for long time then you have to charge it and
discharge it at least few times to bring the battery to its full storage capacity. To do this you
can load any motion program from the “Experiments” folder which is located in the
documentation CD and discharge the batteries after charging.
Warning:
Many transformer based AC adaptor’s voltage is 30 to 40% higher when there is no load.
Make sure that AC adaptor’s no load voltage is precisely 12V else it will damage the
robot and battery.
If you are using SMPS, then make sure that it doesn’t have mains leakage current flowing
through the DC supply. Else when you touch the robot, this high voltage leakage current
will damage the robot’s electronics.
To run the robot on the batteries, make sure that 4 pin relimate battery connector is inserted in
the battery connector socket. Refer to figure 4.8 for the battery connector’s location.
To run the robot on the external supply, remove the 4 pin relimate battery connector from its
socket and use another 4 pin relimate connector to give external supply. External supply should
be in between 7.1 to 9V. Red and Orange are the positive terminals. Brown and Black are the
negative terminals.
Warning:
Do not exceed 9V voltage limit else robot will get damaged.
Battery connector socket is not reverse polarity protected. If supply is applied in reverse
polarity, it will immediately damage the robot.
Use only good quality bench top power supply to power the robot using external supply.
Use of AC adaptor or cheap SMPS is not recommended.
Above figure shows the PWM waveforms for motor velocity control. In case (A), ON time is
90% of time period. This wave has more average value. Hence more power is delivered to the
motor. In case (B), the motor will run slower as the ON time is just 10% of time period.
In the figure 4.10 area marked with the red border are the LEDs connected to the input stage of
the L293D motor driver. Area marked by Blue border shows LEDs connected to the output of
the motor driver. Orange border marks position encoder output LEDs. Yellow border marks left
and right motor connectors.
L1 L2 PL R1 R2 PR Direction
(Red) (Red) (Yel.) (Red) (Red) (Yel.) Output
Direction (I/P) (I/P) (I/P) (I/P) (I/P) (I/P) (Red / Yel.)
PB0 PB1 PD3 PB2 PB3 PD4 Left Right
Motor Motor
FORWARD 0 1 1 1 0 1 Yellow Yellow
REVERSE 1 0 1 0 1 1 Red Red
RIGHT
(Left wheel forward, Right 0 1 1 0 1 1 Yellow Red
wheel backward)
LEFT
(Left wheel backward, 1 0 1 1 0 1 Red Yellow
Right wheel forward,)
SOFT RIGHT
(Left wheel forward,, Right 0 1 1 0 0 1 Yellow Off
wheel stop)
SOFT LEFT
(Left wheel stop, Right 0 0 1 1 0 1 Off Yellow
wheel forward,)
SOFT RIGHT 2
(Left wheel stop, Right 0 0 1 0 1 1 Off Red
wheel backward)
SOFT LEFT 2
(Left wheel backward, 1 0 1 0 0 1 Red Off
Right wheel stop)
HARD STOP 0 0 1 0 0 1 Off Off
SOFT STOP
1 1 1 1 1 1 Off Off
(Free running stop)
Table 4.3 Direction and PWM LED indications
Optical encoder MOC7811 is used for position encoder on the robot. It consists of IR LED and
the photo transistor mounted in front of each other separated by a slot in black opaque casing
with small slot shaped window facing each other. When IR light falls on the photo transistor it
gets in to saturation and gives logic 0 as the output. In absence of the IR light it gives logic 1 as
output. A slotted encoder disc is mounted on the wheel is placed in between the slot. When
encoder disc rotates it cuts IR illumination alternately because of which photo transistor gives
square pulse train as output. Output from the position encoder is cleaned using Schmitt trigger
based inverter (not gate) IC CD40106. CD40106 also drives left and right position encoder status
LEDs. For more details, refer to figure 4.13.
In the absence of the obstacle there is no reflected light hence no leakage current will flow
through the photo diode and output voltage of the photodiode will be around 5V. As obstacle
comes closer, more light gets reflected and falls on the photo diode and leakage current flowing
through the photo diode starts to increase which causes voltage across the diode to fall.
If IR LEDs are disabled using jumpers then same photo diodes works as directional light
intensity sensors.
Figure 4.16 Infrared proximity and Directional light intensity sensors and Jumper settings
for enabling IR Proximity sensors
Figure 4.6 shows 3 Infrared proximity and Directional light intensity sensors on the Spark V
robot. Sensors are numbered as 1, 2 and 3 from left to right in clockwise direction. In all the
manuals this numbering convention will be used for addressing the particular IR sensor.
IR photo diode consumes about 0.5mA when bright light drives the sensor in to saturation. IR
LED if enabled will consume about 30mA current each. Remove the appropriate jumper to
reduce the power consumption of the robot.
ATMEGA16 microcontroller has only 8 ADCs. 3 ADC pins are shared between IR Proximity
sensors and Ultrasonic Range sensors. At any given sensor location either IR Proximity sensor or
Ultrasonic range sensor can be used. Both sensors can not remain active at the same time. Figure
4.16 shows J2, J3 and J4 settings for enabling IR proximity sensors. Jumpers are marked with
red border. To use IR proximity sensors place the 2 jumper caps of the jumper corresponding to
particular sensor towards “IRP” (IR Proximity sensors). Out of these two jumpers one jumper
connects power to the sensor and other connects microcontroller’s ADC pin to the sensor output.
Figure 4.17 IR proximity sensors and correct jumper setting to enable them
Figure 4.17 shows schematic of the IR proximity sensor and the correct jumper setting to enable
them. For jumper positions and pin number of the jumpers refer to figure 4.16.
Figure 4.18 Jumper setting to use IR proximity sensor as directional light intensity sensor
Figure 4.18 shows the jumper settings to use IR proximity sensor as directional light intensity
sensor. For jumper positions and pin number of the jumpers refer to figure 4.16.
Figure 4.19 Ultrasonic range sensors and jumper settings to enable them
Spark V robot can be equipped with the 4 ultrasonic sensors from MaxBotix. Three sensors are
mounted just above the 3 IR proximity sensors. 4 th Sensor can be mounted on the servo motor for
taking 180 degrees scan for map making (marked as 4). Each sensor can sense distance range
from 6 inches to 254 inches. Ultrasonic sensor transmits a narrow beam of ultrasonic pulse and
measures time taken for echo of the beam. It gives output proportional to time taken for the
ultrasonic beam to return echo from the obstacle.
Spark V robot supports EZ0 to EZ4 series of ultrasonic range sensors from MaxBotix. Sensor
gives out analog output with 1 inch resolution. It gives output voltage of 9.8mV per inch. After
powering up, for first 100mS sensor runs calibration cycle. After that it can give readings with
49mS interval.
Figure 4.19 shows locations of the ultrasonic sensors. They are numbered as 1, 2, and 3 from left
to right. Number “4” marks connector for the 4th ultrasonic range sensor which can be mounted
on the servo motor for taking 180 degrees range scan.
ATMEGA16 microcontroller has only 8 ADCs. 3 ADC pins are shared between Ultrasonic
Range sensors and IR Proximity sensors. At any given sensor location either IR Proximity sensor
or Ultrasonic range sensor can be used. Both sensors can not remain active at the same time.
Figure 4.19 shows J2, J3 and J4 settings for enabling Ultrasonic range sensors. Jumpers are
marked with red border. To use Ultrasonic range sensor, place the 2 jumper caps of the jumper
corresponding to particular sensor towards “URF”. Out of these two jumpers one jumper
connects power to the sensor and other connects microcontroller’s ADC pin to the sensor output.
Figure 4.20 Ultrasonic range sensor daisy chaining (courtesy: MaxBotix website)
If many of the sensors transmit ultrasound simultaneously their reading will get mixed-up. In
order to prevent this, all the ultrasonic sensors are connected in the daisy chain. Microcontroller
sends a trigger to the first ultrasonic sensor. First sensor takes the distance reading and sends
trigger to the second sensor. Second sensor follows the same process. This makes sure that at any
given time only one sensor transmits ultrasound.
Figure 4.20 shows sensor daisy chaining. Sensor 1’s TX pin is connected to the Sensor 2’s RX
pin. In this way all 4 sensors are daisy chained. To enable the daisy chaining mode, pin “BW” of
the each ultrasonic sensor is tied to Vcc.
A small pulse trigger (more than 100uS) is given to the “RX” pin of the Sensor no. 1 from the
microcontroller’s PD6 pin. Sensor 1 transmits ultrasonic pulse and gives out distance reading
within 49mS. Sensor 1 triggers the Sensor 2 by transmitting a small pulse on its TX pin to the
RX pin of the second sensor. Now Sensor 2 takes reading. In this way sensor in the daisy chain
takes distance reading one at a time and triggers the next sensor connected.
If you want to install only one ultrasonic sensor, say sensor number 2 or 4 then you need to short
the pins “TX” and “RX” of the sensors which are connected in the daisy chain before the sensor
which is installed so that trigger from microcontroller can reach the installed sensor. Figure 4.21
area marked by red border shows pads corresponding to the particular sensors which are labeled
as P1, P2 and P3 corresponds to sensor numbers.
For example if you want to use only sensor number 2 then you have to short pad corresponding
to sensor 1. If you want to use sensor 4 (connector marked by sensor number 4 in the figure
4.19), then you have to short pad number 1, 2 and 3.
EZ0 to EZ4 sensors have progressively more directionality. Refer to figure 4.10 to get rough idea
of the sensor characteristics.
To interface LCD with the microcontroller in default configuration requires 3 control signals and
8 data lines. This is known as 8 bit interfacing mode which requires total 11 I/O lines. To reduce
the number of I/Os required for LCD interfacing we can use 4 bit interfacing mode which
requires 3 control signals with 4 data lines. In this mode upper nibble and lower nibble of
commands/data set needs to be sent separately. Figure 4.28 shows LCD interfacing in 4 bit
mode. The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable" and it is connected to PC2. This control line is used to tell the
LCD that microcontroller has sent data to it or microcontroller is ready to receive data from
LCD. This is indicated by a high-to-low transition on this line. To send data to the LCD, program
should make sure that this line is low (0) and then set the other two control lines as required and
put data on the data bus. When this is done, make EN high (1) and wait for the minimum amount
of time as specified by the LCD datasheet, and end by bringing it to low (0) again.
The RS line is the "Register Select" line and it is connected to PC0. When RS is low (0), the data
is treated as a command or special instruction by the LCD (such as clear screen, position cursor,
etc.). When RS is high (1), the data being sent is treated as text data which should be displayed
on the screen.
The RW line is the "Read/Write" control line and it is connected to PC1. When RW is low (0),
the information on the data bus is being written to the LCD. When RW is high (1), the program
is effectively querying (or reading from) the LCD.
The data bus is bidirectional, 4 bit wide and is connected to PC4 to PC7 of the microcontroller.
The MSB bit (DB7) of data bus is also used as a Busy flag. When the Busy flag is 1, the LCD is
in internal operation mode, and the next instruction will not be accepted. When RS = 0 and R/W
= 1, the Busy flag is output on DB7. The next instruction must be written after ensuring that the
busy flag is 0.
4.13 Buzzer
Robot has 3 KHz piezo buzzer. It can be used for debugging purpose or as attention seeker for a
particular event. The buzzer is connected to PC3 pin.
Important: Output pin of the TSOP1738 is shared with the left position encoder. You have to
remove the position encoder disc (if installed) before using TSOP1738.
You can also use SPI pins of the microcontrollers as general purpose I/Os or as SPI port for
interfacing with external device. SS (Slave select) pin of the SPI port is available as pad. Refer to
figure 4.44 and 4.45 for SPI pins location.
You can access all the pins of the microcontroller by soldering on the pads which are located just
beside the microcontroller pin.
IDE Installation
Since AVR studio uses WIN AVR compiler at the back end we need to install WIN AVR first
(Please note that WIN AVR must be installed before AVR Studio so that AVR Studio can easily
detect the AVRGCC plug-in).
Figure 5.1
Figure 5.2
Figure 5.3
Figure 5.4
Make sure that you select drive on which operating system is installed.
Figure 5.5
Figure 5.6
Figure 5.7
Figure 5.8
Click on “Run”
Figure 5.9
Figure 5.10
After clicking “Next” go through the license agreement. If it is acceptable then click “Next”
Figure 5.11
Now choose the destination drive. Select the same drive in which your operating system and
WINAVR is installed.
Figure 5.12
Select for the “Install / upgrade Jungo USB Driver” to support In System Programming (ISP) by
AVRISP mkII
Figure 5.13
Important: If “Install / upgrade Jungo USB Driver” is not selected then AVRISP mkII
programmer will not work with the AVR Studio.
Figure 5.14
Click “Finish” to complete the installation process.
Figure 5.15
Figure 5.16
Middle window shows current code under development. Window on the left side shows view of
source files, header files, External dependencies, and other files. Right side window shows all the
ports and other peripheral’s status. Bottom window is known as Build window. It shows results
of the compilation, errors, HEX file size and other warning messages etc.
1. Open AVR Studio. If any project is running it can be closed by clicking on Project in the menu
and select Close Project.
2. To create new project click on Project in the menu and select “New Project”.
Figure 5.17
3. Select Project Type as “AVR GCC”. Type project name in the “Project name” window. In this
case it is “buzzer_test”. Also check on Create folder check box. This will create all the files
inside the new folder. In the Location window select the place where would like to store your
project folder and then click “Next”.
Figure 5.18
4. Select debug platform and Device. In this case we have selected “AVR simulator” and
“ATMEGA16” microcontroller and click finish.
Figure 5.19
5. Now we are almost ready to write our first code. Before we start coding we will check other
setting to make sure that they are set properly.
Figure 5.20
Figure 5.21
7. In the Project Option “General” tab will open. Select device as “ATMEGA16” and frequency
(Crystal Frequency) as 7.3728MHz i.e. 7372800Hz. Set the optimization level be at “-O0”.
Figure 5.22
Figure 5.23
//Main Function
int main(void)
{
init_devices();
while(1)
{
buzzer_on();
//delay
_delay_ms(1000);
buzzer_off();
//delay
_delay_ms(1000);
}
}
We are now going to compile this code to generate the hex file which we will load on the
Robot’s microcontroller. Select “Build” menu and click on “Rebuild All”. It will compile the
“buzzer_test.c” code and will generate “buzzer_test.hex” file for the robot’s microcontroller.
Figure 5.24
You can verify successful compilation in the bottom most “Build” window of the AVR Studio.
Figure 5.25
You can also verify that “buzzer_test.hex” file is generated in the “default” folder inside the
folder you have selected.
Figure 5.26
Now debugging mode is started and an arrow is visible at the first line of our main function from
where the debugging will start.
Figure 5.27
Press “F11” key or “Step into” button from the toolbar to start debugging statement by
statement. Processor details are visible at left window and the I/O port status is displayed at the
rightmost window.
Figure 5.28
By this way we can continuously monitor the bit changes in any of the registers of
microcontroller and debug the code before actually burning it to the microcontroller. PORTC bits
changes as per our commands and these changes can be seen in right window. After debugging is
done select “Stop Debugging” from Debug tab.
Figure 5.29
5.6 Loading your code on robot using AVR Boot loader from NEX Robotics
All AVR microcontrollers can be programmed using In System Programming (ISP), external
programmer or using boot loader. Advantage with the boot loader is that you don’t need any
external hardware to load the .hex file on the microcontroller.
Figure 5.31
Step 4:
Check on the radio button “No, not this time” and then click on the next button.
Figure 5.32
Figure 5.33
Select the second option manually to install the drivers and click on next button.
Step 5:
Now check the second option and set the location of folder containing drivers
E.g.(C:\CDM 2.06.00 WHQL Certified).
Figure 5.34
Step 6:
On clicking next driver installation will begin.
Figure 5.35
Step 7:
On successfully installing the driver following window will appear. Click Finish to complete the
installation.
Figure 5.36
After installation of FT232 USB UART software, PC may ask for USB serial port software. To
install this software follow steps 1 to 7 of USB serial converter software installation.
Important: When using USB port for the communication, for proper operation first turn on the
robot then insert the USB cable in the robot. We have to follow this sequence because USB to
serial converter chip is powered by USB. If any fault occurs then turn off the robot and remove
the USB cable and repeat the same procedure.
Figure 5.37
Step 2:
Click on the Device manager in the Hardware tab.
Figure 5.38
Step 3:
Expand Ports (Com & LPT) tree. COM Port number is mentioned in the parenthesis next to USB
Serial Port.
Figure 5.39
Step 4:
If the COM port number is greater than 10 Terminal will not be able to detect it. To resolve this
problem, change the port number by right clicking on “USB serial Port” and select properties.
Figure 5.40
In the Port settings tab click on the “Advanced” button, the following window will appear.
Figure 5.41
You can change the COM port number by clicking on the Com Port number drop down list and
select the appropriate number. Make sure the new COM port is not being used by any other
device.
Otherwise, download “Installation and Demonstration of AVR Bootloader Manual” from the
following link:
http://www.nex-robotics.com/resources/avr-bootloader.html
5.7 Loading your code on the robot using STK500V2 AVR USB
programmer from NEX Robotics
NEX AVR USB ISP STK500V2 is a high speed USB powered STK500V2 compatible In-
System USB programmer for AVR family of microcontrollers. The compatibility with different
window platform is given in below table. For more information on how to use this programmer,
refer to its manual and drivers which are located in the folder “AVR USB ISP STK500V2” in the
robot’s documentation CD.
Compatibility Chart
5.8 Loading your code on the robot using ATMEL’s AVRISP mkII
Programmer
AVRISP mkII programmer from the ATMEL is the most versatile programmer. It is very easy to
use and has more features. Only flip side is that its bit expensive.
Step 1: Connect AVRISP mkII to the PC. It will install driver automatically provided that USB
driver installation option is selected while installing AVR Studio. For more details refer to figure
4.13.
Figure 5.44
Figure 5.45
Step 2: Select “AVRISP mkII”, select “USB port” and press “Connect”.
Following window will open.
Figure 5.46
AVRISP mkII use 6pin FRC connector for ISP while Spark V robot uses 10 pin FRC connector
for programming. We need to use AVR ISP adaptor to convert 6 pin to 10 pin connector which is
available on NEX Robotics website. It comes free with the AVRISP mkII programmer if it is
purchased from NEX Robotics website.
Step 3: Connect AVR ISP adaptor between robot and AVRISP mkII. Insert 10pin FRC
connector in the Spark V ATMEGA16 robot and turn on the power.
Figure 5.47
Figure 5.48
If ISP does not work properly then try to reduce the ISP frequency and try it again.
Figure 5.50
Go the “Fuse” tab while robot is powered on and AVRISP mkII is connected. Press “Read”
button. All the fuse settings will be visible.
Brown-out detection is disabled.
JTAGEN is set at Brown-out detection at VCC=2.7V
Boot size is at 4096 words with start address = $1C00
SUT_CKSEL is set at External crystal greater than 8MHz with startup time of 64ms
If needed you can set appropriate Fuse setting and write it by pressing “Program” button.
6 Pin Functionality
➢ UART can be connected between FT232 USB to Serial converter or XBee wireless
module using jumper J5.
➢ Output of the Left position encoder and TSOP1738 IR receiver are open collector and
both share the same 10K ohm pull-up resistor.
➢ Ultrasonic sensors are connected in daisy chain for trigger synchronizing. For more
details refer to chapter 4.
➢ AREF can be obtained from the 5V microcontroller.
➢ All the ADC pins must be configured as input and floating.
Table 6.1 shows the simple robot control protocol. Using this, robot can be moved in forward,
backward, left or right directions and its buzzer can be turned on or off. You can use any serial
port control software such as hyper terminal or terminal.exe etc. For user friendliness keys of the
numerical pad of standard 104 keys querty keyboards are used. When a particular number key is
pressed, its ASCII character value is transmitted over serial / USB port. Robot receives this
ASCII values and based on its value it actuates its motors, buzzer etc. Keys are mapped in the
intuitive way on the Numerical pad of the keyboard.
Important:
While using “Numerical Pad” of the key board, make sure that “Num. Lock” is on.
For transferring the command and data we are using the “Terminal Software” located in the
documentation CD. The Installation of terminal software and its use is explained in section 7.4.
Important: When using USB port for the communication, for proper operation first turn on the
robot then insert the USB cable in the robot. We have to follow this sequence because USB to
serial converter chip is powered by USB. If any fault occurs then turn off the robot and remove
the USB cable and repeat the same procedure.
XBee USB Wireless Module from the NEX Robotics enables wireless transmission of serial data
through PC’s USB port. It uses Xbee module for wireless communication. The Xbee module can
be configured via PC’s USB port easily using X-CTU utility to change frequency, baud rate etc.
It is located in the “Software and Drivers” folder in the documentation CD. XBee wireless
modules accepts serial data from any device. To interface it with the PC, FT232 USB to serial
converter is used. To connect XBee USB Wireless Module to the PC you need to install drivers
for FT232 USB to serial converter. To install drivers for FT232 USB to serial converter and to
identify or change COM port number, refer to section 5.6.3 and 5.6.4.
On the PC side this device is treated as the Communication Device Class (CDC) of USB family
and it is assigned a virtual Comport number allowing the user to make use of existing GUI. The
destination side (robot) requires another XBee wireless module.
Make sure that Xbee wireless module s installed on the robot. Serial port of the ATMEGA16 can
be connected to either USB port via FT232 USB to serial converter or to XBee wireless module.
To connect TXD and the RXD of the microcontroller to XBee wireless module, Jumper J5 needs
to be set in the correct setting. Refer to figure 7.3 for the jumper setting to use Xbee wireless
module.
For transferring the command and data we are using the “Terminal Software” located in the
“Software” folder of the documentation CD. The Installation of terminal software and its use is
explained in section 7.4.
Note: Wait for at least 5 seconds to start the wireless communication after turning on the robot
and the USB wireless module.
7.4 Using the Terminal software to control robot via USB port or XBee
wireless module
Terminal is easy to use free software for serial communication. It is located in the “Software and
Drivers” folder in the documentation CD. It can also be downloaded from http://hw-
server.com/software/termv19b.html. Serial communication protocol covered in the section 6.1B
can be used with the terminal software control robot over wire or wireless medium.
Step 1:
Copy Terminal software on the PC from the “Software and Drivers” folder from the
documentation CD and double click on the terminal software. The terminal window will open
up.
Figure 7.4
Step 2:
Select correct jumper setting of J5 to use USB for XBee wireless module for interfacing with the
robot. For more details, refer to sections 7.2 and 7.3
Identify the com port. For more details refer to section 5.6.3
Current version of the terminal software does not support COM port number greater than 10. If
identified COM port number is more than 10 then to change it refer to section 5.6.4.
Specify the COM port in the terminal software
Set the baud rate at 9600 bps
Figure 7.5
Step 3:
Now you are ready to transmit the data. Type the data into the text box and click send. For more
information about using terminal software click help.
Figure 7.7
Step 4:
Turn on the robot. Connect Robot’s USB cable or XBee USB wireless module to the PC.
Make sure that Num lock of the keyboard is on.
Use Numerical keypad to control robot.
Figure 7.8
In this chapter section 8.1 and 8.2 covers Installation and use of GUI. Section 8.3 covers the
communication protocol used in the GUI.
Step 3: Browse the location where set up will install or set the default location and click Next
Button to start the installation.
Figure 8.1
Step 2:
Connect Robot with the PC via USB cable or XBee wireless communication module.
Make sure that jumper J5 is correctly set for selected communication option. Refer to section 7.2
and 7.3 for correct jumper setting.
Step 3:
Select the COM port. For identifying the COM port, refer to section 5.6.4.
Press connect.
Now robot can be controlled by GUI.
Warning:
While using USB communication, ensure that the appropriate jumpers are in place. For more
refer section 6.2 and 6.3
Important:
When using USB port for the communication, for proper operation first turn on the robot then
insert the USB cable in the robot. We have to follow this sequence because USB to serial
converter chip is powered by USB. If any fault occurs then turn off the robot and remove the
USB cable and repeat the same procedure.
To set the speed of the left motor to 0xAB, follow the sequence of commands below. Attach
lower nibble “B” with command 1 and upper nibble A with command 2.
Step1: Send 0x1B Load the lower nibble of the left motor speed in the robot.
Step2: Delay of at least 3 milliseconds
Step3: Send 0x2A Load the upper nibble of the left motor speed in the robot and execute the
command
Step4: Delay of at least 3 milliseconds before loading next command
Note: It is very important that you send the byte containing command 1 first and then send the
byte containing command 2 for proper operation. The same rule is applicable for commands 3
and 4.
52 REVERSE 1 0 0 1
RIGHT (Left wheel
53 forward, Right
0 1 0 1
wheel backward)
LEFT(Left wheel
54 backward, Right
1 0 1 0
wheel forward,)
59 HARD STOP 0 0 0 0
Table 8.2
Example: To set left motor velocity to 0x84, right motor velocity to 0x65, and move
backward.
Step1: 0x14 Load the lower nibble ‘4’ of the left motor speed into the robot
Step2: Delay of at least 3 milliseconds
Step3: 0x28 Load the upper nibble ‘8’ of the left motor speed into the robot and execute the
command
Step4: Delay of at least 3 milliseconds
Step5: 0x35 Load the lower nibble ‘5’ of the right motor speed into the robot
Step6: Delay of at least 3 milliseconds
Step7: 0x46 Load the upper nibble ‘6’ of the right motor speed into the robot and execute the
command
Step8: Delay of at least 3 milliseconds
Step9: 0x52 move backward
Step10: Delay of at least 3 milliseconds before loading next command
60 Battery voltage
Robot sends back 8 bit battery voltage value. To convert this
value in to volts use the following conversion formula:
Battery Voltage = ADC data x 0.069