Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ATMEGA2560 DEVELOPMENT
BOARD MANUAL
JUNE 2016
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
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
info@nex-robotics.com
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
Read the user manuals completely before start using this product
Recycling:
Almost all the part of this product are recyclable. Please send this product to the recycling
plant after its operational life. By recycling we can contribute to cleaner and healthier
environment for the future generations.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
Table of Contents
1 Introduction..................................................................................................................................4
1.1 ATMEGA 2560 Features.................................................................................................................................. 6
1.2 Peripheral Overview .........................................................................................................................................7
3 Hardware Description............................................................................................................... 52
3.1 Power and IO Port Configuration....................................................................................................................52
3.2 LED Interface .................................................................................................................................................54
3.3 Switch Interface...............................................................................................................................................55
3.4 RC Servo Motor Interface...............................................................................................................................56
3.5 RS232 Serial Communication.........................................................................................................................57
3.6 USB Communication......................................................................................................................................58
3.7 XBEE Wireless Communication.....................................................................................................................59
3.8 SD/MMC Card Interface.................................................................................................................................60
3.9 Motor Controller Driver IC L293D Interface..................................................................................................61
3.10 High Current Driver ULN2003 Interface......................................................................................................64
3.11 LCD Interface................................................................................................................................................68
4 Application Examples................................................................................................................72
5 Schematics................................................................................................................................. 74
........................................................................................................................................................74
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
1 Introduction
ATMEGA2560 Development Board is a powerful development platform based on
ATMEGA2560 microcontroller which is one of the most rich feature AVR microcontroller from
Atmel featuring 256K Flash, 8K RAM, 86 I/O lines arranged in nine 8 bit ports, 16 ADCs, 4
UARTs, 6 timers, 8 interrupts and much more. This board is ideal for developing embedded
applications involving high speed wireless communication, USB based data logging, real time
data monitoring and control, interactive control panels etc.
The expansion ports are taken for all the pins of the microcontroller in neat PORT wise
configuration. Board has lots of peripherals such as LCD, SD /MMC card, ZigBee wireless
adaptor board, True USB to Serial converter, 8 servo motors connector, DS1307 based RealTime Clock, ULN2003 7 channel driver, L293D dual DC motor driver, three Potentiometers, 8
switches, 8 LEDs, boot switch and RS232 serial interface etc.
The board is highly suitable for customization. The on-chip peripherals and the external
hardware on the development board are interconnected using pin headers and jumpers. The I/O
pins on the microcontroller can be accessed from 10 pin FRC connectors. The board is made
from double sided PTH PCB board to provide extra strength to the connector joints for increased
reliability. It supports the operating supply voltage between 7V to 14V and has built-in reverse
polarity protection.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
Specifications
Microcontroller: ATMEGA2560 with 14.7456 MHz crystal (Also supports
ATMEGA128, ATMEGA1280, ATMEGA640)
Double side high quality PTH PCB for added strength.
Power: 9 to 14V, AC or DC
Switches: Boot, Reset, Power
10 pin FRC connectors for all IO ports
RS232,USB and Xbee serial interface along with the MCUs UART selection jumpers
SD card Interfacing
8 channels for RC Servo motor control
RTC interface with 3V Li battery
Motor driving interface with L293D
On-board ULN2003 chip interface
Eight number of on-board LEDs and Switches
A Buzzer interfacing
Compatible with General purpose prototyping board for stackable design
Application examples in AVR studio provided in the documentation CD
Kit Contains
1- ATMEGA2560 Development Board
1- USB Cable
1- DB9 Serial Cable
3- 10 pin FRC Cables
10 - 1 to 1 jumper cables
1- Documentation CD
Documentation CD contain following Application examples
IO interfacing
Buzzer test
LCD interfacing
ADC sensor data display on the LCD
ULN2003 interface
L293D demo
UART2 Serial
UART1 XBee
UART0 USB
RTC demo
Servo control
SD card interface
Warning:
Input power supply should not exceed 15 V AC/DC.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
1. ATMEGA2560
Plug-in
Module
2. Reset Switch
3. ISP Connector
4. PORTE Header
5. PORTH Header
6. PORTB Header
7. PORTL Header
8. PORTD Header
9. PORTG Header
10. PORTC Header
11. PORTJ Header
12. PORTA Header
13. PORTK Header
14. PORTF Header
15. ADC Header
16. LCD contrast POT
17. LCD header
18. LCD Backlight Jumper
19. 16*2 LCD
20. ULN2003 Header
21. RTC Header
22. L293D Header
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
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 2.1
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
Figure 2.2
Click Next in the WIN AVR setup wizard.
Figure 2.3
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
Figure 2.4
Make sure that you select drive on which operating system is installed.
Figure 2.5
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
10
Figure 2.6
Click Finish to complete WIN AVR installation
Figure 2.7
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
11
Figure 2.8
Click on Run
Figure 2.9
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
12
Figure 2.10
After clicking Next go through the license agreement. If it is acceptable then click Next
Figure 2.11
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
13
Now choose the destination drive. Select the same drive in which your operating system and
WINAVR is installed.
Figure 2.12
Select for the Install / upgrade Jungo USB Driver to support In System Programming (ISP) by
AVRISP mkII
Figure 2.13
Important: If Install / upgrade Jungo USB Driver is not selected then AVRISP mkII
programmer will not work with the AVR Studio.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
14
Figure 2.14
Click Finish to complete the installation process.
Figure 2.15
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
15
Figure 2.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 peripherals status. Bottom window is known as Build window. It shows results
of the compilation, errors, HEX file size and other warning messages etc.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
16
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 2.17
3. Select Project Type as AVR GCC. Type project name in the Project name window. In this
case it is 1_Buzzer_Beep. 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 2.18
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
17
4. Select debug platform and Device. In this case we have selected AVR simulator and
ATMEGA2560 microcontroller and click finish.
Figure 2.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 2.20
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
18
Figure 2.21
7. In the Project Option General tab will open. Select device as ATMEGA2560 and
frequency (Crystal Frequency) as 14.7456MHz i.e. 14745600Hz. Set the optimization level be at
-O0.
Figure 2.22
Selecting proper optimization options
Optimization option defines the optimization level for all files. Higher optimization levels will
produce code that is harder to debug. Stack variables may change location, or be optimized
away, and source level debugging may "skip" statements because they too have been optimized
away.
The levels of optimization are:
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
19
For more information on optimization, see the 'man' pages for avr-gcc.
Important: While you writing the code, choose appropriate optimization option. If you feel that
code is not working properly as it should be then turn off all optimization by selecting
optimization option as -O0. Once you know that your code is properly working then you can
incrementally increase optimization level.
We suggest that always use optimization level as -O0 at the beginner level.
8. Make sure that in the External Tools, proper path for avr-gcc.exe and make.exe are given and
press ok.
Figure 2.23
Now we are ready to write our first code.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
20
21
port_init ();
sei (); //Enables the global interrupts
}
//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
ATMEGA2560 microcontroller. Select Build menu and click on Rebuild All. It will compile
the 1_Buzzer_Beep.c code and will generate 1_Buzzer_Beep.hex file for the ATMEGA2560
microcontroller.
Figure 2.24
You can verify successful compilation in the bottom most Build window of the AVR Studio.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
22
Figure 2.25
You can also verify that 1_Buzzer_Beep.hex file is generated in the default folder inside the
folder you have selected.
Figure 2.26
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
23
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 2.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 2.28
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
24
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 2.29
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
25
Note:
Bootloader code is loaded on the ATMEGA2560 Microcontroller of the Development Board
using ISP programmer. It is recommended that you only use Bootloader to the load the hex file.
If you use ISP programmer with the Development Board to load .hex file then boot section code
get erased and ATMEGA2560 Development Board will no longer support boot loading.
Figure 2.30
Connections:
Insert the two 2-pin jumpers on TXD0 and RXD0 below the ATMEGA2560 socket
Insert 2-pin jumper at Boot load jumper J1
Connect the 9 pin DB serial cable between Board serial connector and PC serial port.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
26
Figure 2.31
Connections:
Insert the two 2-pin jumpers on TXD0 and RXD0 near the POWER PORT.
Insert 2-pin jumper at Boot load jumper J1
Connect the USB cable between Board USB connector and PC USB port.
Note: Remove the RXD0 and TXD0 jumpers below the ATMEGA2560 Plug-In Module, if
inserted.
2.6.2.3 Installing FT232 USB to Serial converter drivers
Before using USB port we need to install the driver software for FT232 USB to serial converter.
The software is located in the Software and Drivers \ CDM 2.06.00 WHQL Certified folder,
provided in the ATMEGA2560 Development Board CD or can also be downloaded from the
NEX Robotics website.
Steps to install the drivers for USB to serial converter:
Step 1:
Copy the driver installation folder on your PC from Software and Drivers \ CDM 2.06.00
WHQL Certified Folder in the CD.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
27
Step 2:
Connect the USB to serial converter cable between ATMEGA2560 Development Board and the
PC.
Step 3:
On connecting the device Found New Hardware message will appear in the taskbar tray and
the following window opens.
Figure 2.32
Step 4:
Check on the radio button No, not this time and then click on the next button.
Figure 2.33
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
28
Figure 2.34
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 2.35
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
29
Step 6:
On clicking next driver installation will begin.
Figure 2.36
Step 7:
On successfully installing the driver following window will appear. Click Finish to complete the
installation.
Figure 2.37
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.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
30
Important: When using USB port for the communication, for proper operation first turn on the
Board then insert the USB cable in the Board. We have to follow this sequence because USB to
serial converter chip is powered by USB. If any fault occurs then turn off the Board and remove
the USB cable and repeat the same procedure. After complete installation of USB Serial
converter driver, we need to identify the comport number, where the USB cable is connected to
which USB port.
2.6.2.4 Identifying and changing COM Port number of the Serial Port
To use terminal.exe or any other serial program, we need to first identify communication port
which is generally referred as COM n, i.e. COM1 or COM2 etc. on which USB to serial
converter or wireless device or MAX232 is connected. Follow these steps to identify your COM
Port number.
Step 1:
Right Click My Computer and click on properties. System properties window will appear and
click on Device Manager in Hardware tab.
Figure 2.38
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
Figure 2.39
31
Step 3:
Expand Ports (Com & LPT) tree. COM Port number is mentioned in the parenthesis next to USB
Serial Port.
Figure 2.40
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 2.41
In the Port settings tab click on the Advanced button, the following window will appear.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
32
Figure 2.42
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.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
33
2.7 Loading your code on the ATmega2560 microcontroller using AVR USB
programmer (STK500v2) from NEX Robotics
This is the second option for loading the program. 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.
Compatibility Chart
Operating System
Windows XP
Windows Vista
Windows 7
Avrdude (HID)
YES
YES
YES
Figure 2.50: NEX AVR USB ISP STK500V2 programmer from NEX Robotics
Jumper Description
J1: If inserted, provides 5V at VTG (pin no.2) of ISP connector. If removed 0V at VTG (pin
no.2) of ISP connector. In default mode, this jumper is not inserted.
J2: If inserted, enables UBS HID mode. If removed enables USB CDC mode. In default mode,
this jumper is not inserted.
J3: If inserted, enables slow clock speed (for 32 KHz to 1MHz speed microcontrollers). If
removed enables normal clock speed. In default mode, this jumper is not inserted.
First we need to install driver. The driver installation for CDC mode and HID mode are
explained in details in the following sections.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
34
Figure 2.51
2. After identifying the hardware, the windows driver installation wizard should start. Select
No, not this time and click next to continue.
Figure 2.52
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
35
3. Select Install from a list of specific location and click next to continue.
Figure 2.53
4. Browse to AVRUSBSTK500\Drivers directory and click next to continue.
Figure 2.54
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
36
Figure 2.55
6. After successful installation of drivers following window will appear. Click finish to complete
the installation.
Figure 2.56
7. To identify the COM port assigned to NEX AVR USB programmer, refer to section 2.6.2.4.
Note : NEX AVR USB ISP STKV2 programmer use 10 pin FRC connector for ISP while
ATMEGA2560 on Development Board uses 6 pin FRC connector for programming. We need to
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
37
use AVR ISP adaptor to convert 10 pin to 6 pin connector which is available on NEX Robotics
website.
Connect AVR ISP adaptor between ATMEGA2560 plug-in module ISP socket on controller
board and AVR USB ISP STKV2 programmer. Insert 6 pin FRC cable in the ISP socket present
on the ATMEGA 2560 socket of the ATMEGA2560 microcontroller Plug-In module.
Figure 2.57
Turn ON the ATMEGA2560 Development Board.
8. Open AVR Studio from Start Menu. Click Con button on the tool bar to open Connect Dialog.
Figure 2.58
9. In the connect dialog, select platform as STK500, select appropriate port and click connect. If
Connect Dialog reappears, then recheck that the COM port is available and try again.
Figure 2.59
10. In the next window, click cancel to skip firmware upgrade.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
38
Figure 2.60
11. After clicking cancel, AVR Studio will open STK500 interface. In the main tab, select the
appropriate microcontroller and read its signature. Observe that the signature matches the
selected device.
Figure 2.61
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
39
12. In the Program tab, select the appropriate hex file and click program to load the hex file in
the microcontroller.
Figure 2.62
13. The programming status can be observed in the bottom area of the window.
Figure 2.63
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
40
14. Select correct Fuse setting before programming ATMEGA2560. Do not change them
unless you have very clear understanding of the fuse settings. Below Figure shows the Fuse
setting for ATmega2560 Microcontroller. This information is only given for the reference.
Figure 2.64
Go the Fuse tab while development board is powered on and STK501V2 USB ISP
programmer 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 = $7000
SUT_CKSEL is set at External crystal greater than 8MHz with Start-up time of 64ms
If needed you can set appropriate Fuse setting and write it by pressing Program button.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
41
Case 2: Installing drivers for HID mode (Works on all windows operating systems)
1. If connected, disconnect programmer from PC and insert HID/CDC jumper. Now reconnect
programmer to PC and observe the task bar for Found New Hardware message.
2. HID mode does not require additional drivers. It uses generic windows drivers.
3. Go to Device Manager and observe that new Human Interface Device (HID) is installed. If
there are other HID devices connected to PC, you may optionally identify each device by
viewing its properties.
Figure 2.66
4. Before proceeding ensure that you have AVRDude.exe and AVRDude.conf on your PC.
These files are available in the zip file that was downloaded earlier from NEX Robotics website.
Turn off the ATmega2560 Development Board.
NEX AVR USB ISP STKV2 programmer use 10 pin FRC connector for ISP, while
ATmega2560 Development Board uses 6 pin FRC connector for programming. We need to use
AVR ISP adaptor to convert 10 pin to 6 pin connector which is available on NEX Robotics
website.
Connect AVR ISP adaptor between ATmega2560 plug-in module ISP socket on controller board
and AVR USB ISP STKV2 programmer. Insert 6 pin FRC cable in the ISP socket (shown in
figure on section 1.3) of the ATmega2560 microcontroller Plug-In module.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
42
Figure 2.67
Turn ON the ATMEGA2560 Development Board.
5. Go to Start Menu>Run and type cmd to open command prompt.
Figure 2.68
6. On the command prompt, type the path of the folder that contains avrdude.exe and
avrdude.conf files. For e.g. refer fig. below.
Figure 2.69
7. On the command line type the command as shown in the fig. below. Here -p m2560 refers to
the microcontroller part number. The last section after U in quotes specifies the location of
hex file, that is to be load on microcontroller.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
43
Figure 2.70
8. Press enter. You should see the programming status in the command prompt window. If there
is any error, recheck ISP connection and command line parameters.
Figure 2.71
After successful loading of the buzzer_test.hex you will hear beeping sound being ON-OFF
continuously after some delay.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
44
Figure 2.73
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
45
Figure 2.74
Step 2: Select AVRISP mkII, select USB port and press Connect.
Following window will open.
Step 3: Insert 6-pin connector of AVRISP mkII in the 6-pin ISP Socket of ATMEGA2560
Microcontroller plug-in module, and turn on the power.
Step 4: Go to Main tab
Select ATMEGA2560 microcontroller. Click on the Read Signature button.
It will read the signature and if its matches with the microcontroller signature then we are ready
to load hex file on the ATMEGA2560 Microcontroller;If ISP does not work properly then try to
reduce the ISP frequency and try it again.
Figure 2.75
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
46
Figure 2.77
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
47
Figure 2.78
Go the Fuse tab while ATMEGA2560 Development Board 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 = $7000
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.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
48
3 Hardware Description
In this chapter various components mounted on the board and their principal of operation is
explained in detail. It is very important that you go through this chapter before starting to use the
ATMEGA2560 Development Board.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
49
Pin Function
5V 1A output of 7805 voltage regulator
5V 1A output of 7805 voltage regulator
Ground
Ground
Vin DC (Input supply 1.2V DC drop due to bridge rectifier)
Vin DC (Input supply 1.2V DC drop due to bridge rectifier)
NC
NC
NC
NC
Table 3.2 Power Port configuration
Warning: Never ever connect power port to any of the I/O port or interface port. It will
immediately damage the circuit.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
50
LED Connections
For connecting a single LED, connect 1-1 cable between a single pin of LED header and
I/O pin.
For using entire eight LEDs connect the 10-pin FRC cable between LED Header and the
8-bit IO port header.
Application example:
For controlling LEDs when switch is pressed refer to the example code on IO interfacing
which is located in the experiments folder in the documentation CD.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
51
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
52
Application Example:
Refer to the experiment UART2_Serial which is located in the folder experiments in the
documentation CD.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
53
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
54
Application Example:
Refer to experiment UART0_USB from Experiments folder from the documentation
CD
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
55
XBee Connections
TXD and RXD pins of the XBee wireless module can be directly connected to the RXD and
TXD of the UART 1 directly by shorting XBee header. If you want to connect XBee to different
UART then use 1 to 1 connectors supplied with the boards for the connections. For more details
refer to Figure 3.13.
Note: Remove the 2-pin jumpers on the RXD1 and TXD1 connector below the ATMEGA2560
socket.
Application Example:
Refer to experiment UART1_XBee from Experiments folder from the documentation CD
Pin Function
1(CS)
2(SCK)
3(MOSI)
4(MISO)
5 to 10
Not connected
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
56
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
57
Pin Name.
Pin Function
Input4
Inhibit1
Inhibit2
Input3
Input2
Input1
GND
NC
Pin Name
Pin Function
GND
VINB
VINE
4
5
6
7
A
B
C
D
Ground
Regulated supply from the bridge rectifier with current rating of
the AC adaptor / SMPS used.
Power supply to the motor drive block inside the L293D
( Connect the supply 5V to 36V)
Channel A1 output
Channel A2 output
Channel B1 output
Channel B2 output
Table 3.5
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
58
Following table shows the pin connections done in the application example L293D_ demo
which is located in the Experiments folder in the documentation CD.
L293D Logic Input Header
PORTL
3 (Input4)
PL2
4 (Inhibit1)
PL3
5 (Inhibit2)
PL4
6 (Input3)
PL5
7 (Input2)
PL6
8 (Input1)
PL7
Table 3.6
Output connections:
To power motor driver block inside the L293D you need to connect pin 3, VINE (Vin External)
of the L293D output connector to either VINB (Vin supply of Board) or the external power
source between 5V to 36V DC. Use VINB only if AC adaptor /SMPS which is powering the
board can give sufficient current to the motor without causing huge current surges.
L293D Output Connector
GND
VINB
VINE
A
B
C
D
Output Connection
NC
NC
5V Supply Pin
LED Header Pin no. 1
LED Header Pin no. 2
LED Header Pin no. 3
LED Header Pin no. 4
Table 3.7
Application Example:
Refer to experiment L293D_demo from Experiments folder from the documentation CD
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
59
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
60
Pin Function
Logic input signal for channel 1 to 7
Table 3.8
Output connections:
To drive the external load you need to connect pin 3, VINE (Vin External) of the L293D output
connector to either VINB (Vin supply of Board) or the external power source between 5V to 50V
DC. Load should be connected between VINE and pin OUT1 to OUT7. Use VINB only if AC
adaptor /SMPS which is powering the board can give sufficient current to the motor without
causing huge current surges.
Application Example:
Refer to experiment ULN2003 interface from Experiments folder from the documentation
CD
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
61
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
62
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
63
Pin Function
Data /Instruction Register Select
Read/Write Control
Enable
Input for buzzer (not used in this example)
Data line 0 to 3
Table 3.10: LCD connections
LCD Connections
LCD requires minimum seven I/O pins and two supply pins VCC and GND for its operation.
The LCD header provides all the necessary connections for controlling LCD using a single 8-bit
port.
For using LCD, connect the 10pin FRC cable provided with the board between LCD
header and PORT C of the microcontroller.
Connect the 2pin jumper at LCD_BKL jumper connector if backlight is required.
Adjust the Contrast if required with LCD contrast Pot.
Application Example:
Refer to experiment LCD interfacing from Experiments folder from the documentation CD.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
64
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
65
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
66
4 Application Examples
The following examples codes are given in Documentation CD. All the codes are written using
the AVRStudio Version 4.17. The installation of the software is explained chapter 2
For easier learning follow the experiments in the sequence mentioned below.
4.1 Buzzer test
This program will make buzzer beep.
To make Buzzer On and off third pin of the PORTC is used. To turn on the buzzer, make
PORTC3 pin logic 1 and logic 0 to off.
4.2 IO interfacing
This experiment demonstrates simple Input and Output operation. When switch is pressed the
respective LED will glow.
4.3 ULN2003 interface
This experiment demonstrates the ULN2003 testing .Alternate input made logic high and
respective LEDs are 'ON'
4.4 L293D demo code
This experiment demonstrates L293D driver for motor control application using PWM
4.5 LCD interfacing
This experiment demonstrates LCD interfacing in 4 bit mode.
4.6 ADC LCD
In this experiment three POTs are connected to the three channels of ADC module of
ATMEGA2560 Microcontroller and converted digital result is displayed on the LCD.
4.7 UART2 Serial
In this program Microcontroller receives data from the PC, adds one to the ASCII value and
echoes back to the PC through Serial port.
4.8 UART1 XBee
In this program Microcontroller receives data from the PC, adds one to the ASCII value and
echoes back to the PC through Xbee port.
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
67
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
68
5 Schematics
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
69
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
70
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA
71