Sei sulla pagina 1di 71

ATMEGA2560 DEVELOPMENT BOARD MANUAL

ATMEGA2560 DEVELOPMENT
BOARD MANUAL
JUNE 2016

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

Products electronics is static sensitive. Use the product in static free


environment.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Table of Contents
1 Introduction..................................................................................................................................4
1.1 ATMEGA 2560 Features.................................................................................................................................. 6
1.2 Peripheral Overview .........................................................................................................................................7

2 Programming ATMEGA2560 Development Board................................................................... 8


2.1 Installing WIN AVR..........................................................................................................................................8
2.2 Installing AVR Studio.....................................................................................................................................11
2.3 Setting up Project in AVR Studio................................................................................................................... 16
2.4 Writing your first code in AVR Studio............................................................................................................20
2.5 Debugging the code in AVR studio.................................................................................................................23
2.6 Loading your code on ATMEGA2560 Development Board using AVR Boot loader from NEX Robotics...25
2.6.1 Boot loader operating principle..............................................................................................................25
2.6.2 Boot Loading Techniques.......................................................................................................................26
2.6.3 Installation and Demonstration of AVR Bootloader...............................................................................33
2.7 Loading your code on the ATmega2560 microcontroller using AVR USB programmer (STK500v2) from
NEX Robotics..........................................................................................................................................................34
2.7.1 Driver Installation....................................................................................................................................35
2.8 Loading your code on the ATMEGA2560 Development Board using ATMELs AVRISP mkII Programmer
.................................................................................................................................................................................46

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

1.1 ATMEGA 2560 Features

High Performance, Low Power AVR 8-Bit Microcontroller


32 x 8 General Purpose Working Registers
Up to 16 MIPS Throughput at 16 MHz
256K Bytes of In-System Self-Programmable Flash
In-System Programming by On-chip Boot Program
4K Bytes EEPROM
8K Bytes Internal SRAM
Up to 64K Bytes Optional External Memory Space
Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode
Four 16-bit Timer/Counter with Separate Prescaler, Compare- and Capture Mode
Four 8-bit PWM Channels
Twelve PWM Channels with Programmable Resolution from 2 to 16 Bits
16-channel, 10-bit ADC
Two/Four Programmable Serial USART
Master/Slave SPI Serial Interface
Byte Oriented 2-wire Serial Interface
Programmable Watchdog Timer with Separate On-chip Oscillator
On-chip Analog Comparator
Interrupt and Wake-up on Pin Change

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

ATMEGA2560 DEVELOPMENT BOARD MANUAL

1.2 Peripheral Overview

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

23. ADC POTs


24. ULN2003 CON
25. L293D CON
26. XBee Header
27. XBee Module
28. SD/MMC Header
29. SD/MMC Socket
30. USB_serial Header
31. USB connector
32. Serial DB9 Connector
33. Power Port
34. Boot Load switch
35. Boot Load Jumper
36. AC/DC Socket
37. Power Switch
38. Power LED
39. Terminal block connector
40. Servo Header
41. Servo connector
42. LED Header
43. LEDs
44. Switch Header
45. Switches

ATMEGA2560 DEVELOPMENT BOARD MANUAL

2 Programming ATMEGA2560 Development Board


There are lots of IDEs (Integrated Development Environment) available for the AVR
microcontrollers. There are free IDEs which are based on AVR GCC like AVR Studio from
ATMEL and WIN AVR and proprietary IDEs like ICC AVR, Code vision AVR, IAR and KEIL
etc. IDEs like ICC AVR and code vision AVR are very simple to use because of their GUI based
code generator which gives you generated code. Almost all the proprietary IDEs works as full
version for first 45 days and then there code size is restricted to some size. We have used free
IDE like AVR Studio from ATMEL and proprietary IDE like ICC AVR for the ATMEGA2560
Development Board. In this manual we are going to focus on the AVR studio from the ATMEL.
It uses WIN AVR open source C compiler at the back end. It has many attractive features like
built-in In-Circuit Emulator and AVR instruction set simulator. After writing and compiling the
program it gives .hex file. This .hex files needs to be loaded on the ATMEGA2560
Development Board using In System Programmer (ISP).

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).

2.1 Installing WIN AVR


Insert the ATMEGA2560 Development Board documentation CD and from the Software and
Drivers folder copy WIN AVR 2009-03-13 on the PC and click on WinAVRxxxx.exe file.

Figure 2.1

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

ATMEGA2560 DEVELOPMENT BOARD MANUAL

WIN AVR installation package will open. Choose language as English.

Figure 2.2
Click Next in the WIN AVR setup wizard.

Figure 2.3

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Press I Agree after going through license agreement.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Select all the components and press Install.

Figure 2.6
Click Finish to complete WIN AVR installation

Figure 2.7

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

11

ATMEGA2560 DEVELOPMENT BOARD MANUAL

2.2 Installing AVR Studio


Go to Software and Drivers folder from the documentation CD, copy folder AVR Studio
4.17 on the PC and click on AvrStudio417Setup.exe to start the installation process.

Figure 2.8
Click on Run

Figure 2.9

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

12

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Click Next to start installation of AVR Studio 4

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Click Next to start the installation process.

Figure 2.14
Click Finish to complete the installation process.

Figure 2.15

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

15

ATMEGA2560 DEVELOPMENT BOARD MANUAL

2.3 Setting up Project in AVR Studio


AVR studio is an Integrated Development Environment (IDE) for writing and debugging AVR
applications. As a code writing environment, it supports included AVR Assembler and any
external AVR GCC compiler in a complete IDE environment.
AVR Studio gives two main advantages:
1. Edit and debug in the same application windows. Faster error tracking.
2. Breakpoints are saved and restored between sessions, even if codes are edited.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

6. Open Project menu and click on the Configuration option.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

-O0 No optimization. This is the same as not specifying any optimization.


-O1 Optimize. Reduces code size and execution time without performing any
optimizations that take a great deal of compilation time.
-O2 Optimize even more. avr-gcc performs almost all optimizations that don't involve a
space-time tradeoff.
-O3 Optimize yet more. This level performs all optimizations at -O2 along with -finlinefunctions and -frename-registers.
-Os Optimize for size. Enables all -O2 optimizations that don't increase code size. It also
performs further optimizations designed to reduce code size.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

2.4 Writing your first code in AVR Studio


We are going to write our first code for our ATMEGA2560 Development Board.
This program will make ATMEGA2560 Development Boards buzzer beep.
Copy the following code in window code area. We will see how this code works in the next
chapter.
//Buzzer is connected at the third pin of the PORTC
//To turn it on make PORTC 3rd (PC3 )pin logic 1
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
//Function to initialize Buzzer
void buzzer_pin_config (void)
{
DDRC = DDRC | 0x08;
//Setting PORTC 3 as output
PORTC = PORTC & 0xF7;
//Setting PORTC 3 logic low to turnoff buzzer}
void port_init (void)
{
buzzer_pin_config ();
}
void buzzer_on (void)
{
unsigned char port_restore = 0;
port_restore = PINC;
port_restore = port_restore | 0x08;
PORTC = port_restore;
}
void buzzer_off (void)
{
unsigned char port_restore = 0;
port_restore = PINC;
port_restore = port_restore & 0xF7;
PORTC = port_restore;
}
void init_devices (void)
{
cli (); //Clears the global interrupts
NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

21

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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.

2.5 Debugging the code in AVR studio


After successful compilation of the code we can debug the code by AVR Debugger provided by
AVRStudio. Here is the illustration of debugging of code given in Exp1 (buzzer ON-OFF
folder).
Click on Debug tab in the menu and click on Start Debugging.

Figure 2.26

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

23

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

2.6 Loading your code on ATMEGA2560 Development Board 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 dont need any
external hardware to load the .hex file on the microcontroller.

2.6.1 Boot loader operating principle


If Bootloader firmware is loaded on the microcontroller then it can be programmed directly via
serial port or USB (using USB to Serial converter) using PC. In the boot loading method a small
piece of code is loaded on the microcontroller in the configurable boot memory section. When
signaled using external switch while resetting the microcontroller it gets active and waits for
communication from the PC. Bootloader software from NEX Robotics, which is installed on the
PC, communicates with the microcontroller. Boot loader software loads the .hex file on the
microcontroller. After the boot loading process is complete, newly loaded code can be executed
by pressing reset. Once the code is loaded on the microcontroller UART is free and can be used
for other applications. Bootloader get invoked only if boot switch is kept pressed while
microcontroller is reset using reset switch.

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

25

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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.

2.6.2 Boot Loading Techniques


The .hex file is loaded on the ATMEGA2560 via bootloader. ATMEGA2560 has 4 UART Ports
from UART0 to UART3. The Bootloader is designed to support only UART0. For bootloading
we can use either Serial port or USB port. Board is shipped with UART0 connected to the serial
port. The following section describes Bootloading via serial port and USB port. For bootloading
we have to use boot switch along with the reset switch. To enable the boot switch you need to
connect jumper J1. Jumper J1 connects boot switch with the PORTE 7. For more details refer to
figure 2.30.
2.6.2.1 Boot loading via serial port
To use Serial RS232 module for boot loading, we have to short the RXD0 and TXD0 jumpers to
connect TXD and RXD of MAX232 RS232 to serial TTL converter to RXD and TXD of
UART0. For connection details refer to figure 2.30.
Note: When you use Serial Port for Boot loading connect UART0 jumper and remove USB
jumper near the POWER PORT as shown in figure below.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

2.6.2.2 Boot loading via USB port


To do bootloading via USB port we need to connect TXD and RXD of the FT232 IC (USB to
serial converter) with RXD and TXD of the UART0. For connection details refer to figure 2.31.
Note: When you use USB Port for Boot loading remove UART0 jumper below the
ATMEGA2560 socket, if connected and connect USB jumper as shown in figure below.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

The following window will appear.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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.

2.6.3 Installation and Demonstration of AVR Bootloader


For AVR Bootloader application, kindly refer manual of Installation and Demonstration of AVR
Bootloader which is provided inside a Documentation CD\Manuals\Installation and
Demonstration of AVR Bootloader.
Otherwise, download Installation and Demonstration of AVR Bootloader Manual from the
following link:
http://www.nex-robotics.com/resources/avr-bootloader.html

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

33

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

AVR Studio (CDC)


YES
X
X
Table 2.1

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

2.7.1 Driver Installation


Case 1: Installing drivers for STK500 CDC Mode
Download software package from NEX Robotics website and unzip the contents on your local
drive. This zip file is containing documentation, driver files and Avrdude software. You can also
copy it from documentation CD.
1. If connected, disconnect programmer from PC and remove HID/CDC jumper (J2). Now
reconnect programmer to PC and observe the task bar for Found New Hardware message.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

5. In the next window click Continue Anyway to proceed.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

Figure 2.65: Fuse settings of ATmega2560


microcontroller

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

2.8 Loading your code on the ATMEGA2560 Development Board using


ATMELs 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.

Figure 2.72: AVRISP mkII


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 2.13.
Start AVR Studio
Go to Tools tab and click on Program AVR. Select connect option.
Following window will open.

Figure 2.73

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

45

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

Figure 2.76: Changing ISP frequency


if required

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

46

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Step 5: Go to Program tab.


Check on Erase device before programming and Verify device after programming check box.
Browse and select the desired hex file in the flash section
Press Program button
Look at the comments at the bottom to verify that hex file is loaded in the flash.

Figure 2.77

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

47

ATMEGA2560 DEVELOPMENT BOARD MANUAL

2.8.1 Fuse settings for ATMEGA2560 microcontroller


Correct Fuse settings are done in the ATmega2560 microcontroller before shipping out
ATmega2560 Development Board. 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.78

Figure 2.79: Fuse settings of ATMEGA2560


microcontroller

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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.

3.1 Power and IO Port Configuration

Figure 3.1 Power and IO Port configuration

3.1.1 Power section


ATMEGA2560 Development board can be powered by 9 to 14V AC /DC supply. You can use
any AC adaptor or SMPS which can supply 9V to 14V DC and at least 1Amp current. Board has
on-board bridge rectifier, filter capacitors and 7805 voltage regulator with heat sink which can
supply up to 1Amp current at regulated 5V. Power of the board can be turned on or off using
power switch.

3.1.2 I/O PORT FRC connector pin connections


ATMEGA2560 has many 8 bit ports. To make interfacing simple all the ports are taken out on
standard 10 pin FRC connector. While pin number 1 to 8 represents bit 0 to bit 7 of the port and
pin no. 9 and 10 represents 5V and ground.
Pin No.
Pin Function
1
Pin 0 of PORT X
2
Pin 1 of PORT X
3
Pin 2 of PORT X
4
Pin 3 of PORT X
5
Pin 4 of PORT X
6
Pin 5 of PORT X
7
Pin 6 of PORT X
8
Pin 7 of PORT X
9
5V-1A output of 7805 voltage regulator
10
Ground
Table 3.1 I/O Port Header Configuration

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

49

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Note: X corresponds to any port name from PORTA to Port J.

3.1.3 Power Port pin connections


Development board has a dedicated power port which is common in all the development boards
of the NEX Robotics. It can give regulated Vin, 5V to the external device.
Pin No.
1
2
3
4
5
6
7
8
9
0

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.

3.2 LED Interface


ATMEGA2560 Development Board has 8 LEDs connected to 10 pin FRC header for display /
debug purpose. Each LED has 4.7K ohm series resistor for current limiting. 10 pin LED header
can be connected to any port header using FRC cables provided with the board.

Figure 3.2 LED Schematic

Figure 3.3 LEDs configuration

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

50

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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.

3.3 Switch Interface


ATMEGA2560 Development Board has 8 Switches connected to 10-pin FRC Header. Each
Switch has 4.7K ohm Pull-Up resistor as shown in Figure 3.4. The switch header can be
connected to any port of the microcontroller using 10 pin FRC cables provided with the board.

Figure 3.4 Switch Schematic

Figure 3.5 Switch configuration


When switch is not pressed it gives logic 1 output because of 4.7K ohm pull-up resistor. When
switch is pressed it gives logic 0 output.
Switch Connections
For connecting a single switch, connect 1-1 cable between a single pin of switch header
and I/O pin.
For using entire eight switches connect the 10-pin FRC cable between switch 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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

3.4 RC Servo Motor Interface


The ATMEGA2560 Development board allows independent control of 8 RC servo motors. The
RC servo motor requires (Pulse Width Modulation) PWM signal, VCC and GND for its
operation. The servo connector as shown in Figure.3.6 provides these connections, where you
can connect the servo motors directly. The PWM inputs are obtained from servo header which in
turn can be connected to any IO port using FRC cables. The power for the servo motors should
be provided from the external supply through the terminal block as board will not be able to
supply sufficient current to the servo motors. The connection details are shown in Figure 3.7.

Figure 3.6 Schematic of the servo motor

Figure 3.7 Servo configuration


Servo Connections
For connecting a single servo, connect 1-1 cable between a required pulse input pin of
servo header and I/O pin. Also give 5 to 6V DC for powering up servo motor via the
terminal block connector.
For using all eight servos, connect the FRC cable between servo and the 8-bit IO port
header. Also connect the +Ve pin terminal block connector to 5V with the external
supply and give 5 to 6V DC for powering up servo motor via the terminal block
connector.
Application Example:
Refer to the experiment Servo Control which is located in the experiments folder in the
documentation CD.

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

52

ATMEGA2560 DEVELOPMENT BOARD MANUAL

3.5 RS232 Serial Communication


ATMEGA2560 development board has onboard MAX232 (RS232 to serial converter) IC for
RS232 serial port interfacing. ATMEGA2560 has 4 serial ports. You can connect MAX232 to
any of the serial port by shorting UART jumpers. Board is factory shipped with UART2
connected to MAX232. For connection details refer to Figure 3.8.

Figure 3.8 Basic Schematic of the RS232 Interface

Figure 3.9 RS232 communication configuration on board


RS232 communication Connection
You need to do the following connection for running the example experiment given in the
Documentation CD,
Insert the 2-pin jumpers on the RXD2 and TXD2 connector below the ATMEGA2560
socket.
Insert the DB9 serial cable between the PC and the serial DB9 port of Development
board.

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

3.6 USB Communication


ATMEGA2560 development board has onboard FT232 based USB to serial converter. It gives
out and accepts serial signals at the TTL / CMOS level. To connect FT232 USB to serial
converter to any serial port use 1 to 1 connector. You can also use all the other serial pins of the
FT232 such as DTR, DSR etc. to implement flow control. You can also connect USB to Serial
converter to the UART 0 and use bootloader to load the hex file.

Figure 3.10 Schematic of the USB communication

Figure 3.11 USB communication configuration on board


Prior to use the USB Module, we need to install the USB to RS232 Driver on the PC. Refer the
Section 2.6.2.2 and 2.6.2.3 for Driver Installation and Identify and changing the COMPORT
Number.
In the terminal program select the COMPORT that is assigned by the PC and you are ready for
USB communication.
USB to Serial Converter Connection
You need to do the following connection for running the example experiment given in the
Documentation CD,
Insert the 2-pin jumpers on the RXD0 and TXD0 connector near the Power Port header.
Insert the USB cable between the PC and the USB port of Development board.
Note: Remove the 2-pin jumpers on the RXD0 and TXD0 connector below the ATMEGA2560
socket if inserted.

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

54

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Application Example:
Refer to experiment UART0_USB from Experiments folder from the documentation
CD

3.7 XBEE Wireless Communication


XBee wireless module from the Digi International is an easy to use module for wireless serial
communication. 2.4GHz XBee wireless module has 16 frequency separated channels. On each
channel you can have many simultaneous communications by giving different PAN ID to each
device. You can do lots of things with this device. It can be configured by XCTU software from
Digi. For more details, read the XBee wireless module documentation from the documentation
CD which is located in the datasheet folder.
The ATMEGA2560 Development Board has standardized 20 pin socket for the XBee wireless
module along with the 3.3V supply for the module. You can connect TXD and RXD pins of the
XBee module to the any RXD, TXD pins of the microcontroller. It is also possible to connect
FT232 USB to serial converter to XBee module directly and use it as XBee USB wireless
module.

Figure 3.12 Schematic of the Xbee communication

Figure 3.13 XBee communication configuration

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

55

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

3.8 SD/MMC Card Interface


ATMEGA2560 development board has onboard SD/MMC card holder. SD/MMC card can be
used as external removable storage media for the data logging purpose. The SD/MMC card is
accessed in two modes, as SD/MMC mode or SPI mode. For the Simplicity we are using SPI
mode. The SPI signals are taken on the SD/MMC header (10pin FRC) and a SD/MMC socket is
provided to insert the MMC card or SD with MMC adaptor.
SD/MMC card pin configuration:
Pin No.(10pin FRC)

Pin Function

1(CS)

Chip select input for SD/MMC card

2(SCK)

Clock signal input for SD/MMC card

3(MOSI)

Serial Data input for SD/MMC card

4(MISO)

Serial Data output for SD/MMC card

5 to 10

Not connected

Table 3.3: SD/MMC card connections

Figure 3.14. Schematic of SD/MMC card interfacing

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

56

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Figure 3.15 SD/MMC configuration on board


SD/MMC card Connections
Connect 10 pin FRC wire between SD/MMC header and Port B
10 pin FRC wire connects the SD/MMC card with the uC in the following way
CS pin of SD/MMC SS pin of the PORTB
SCK pin of SD/MMC SCK pin of the PORTB
SDI pin of SD/MMC MOSI pin of the PORTB
SDO pin of SD/MMC MISO pin of the PORTB
Application Example:
Refer to experiment SD card interface from Experiments folder from the documentation CD

3.9 Motor Controller Driver IC L293D Interface


L293D dual DC motor driver can drive 2 DC motors with up to 4.5V to 36V and up to 600mA
current rating each or a single bipolar stepper motor. To change the direction of the motor,
appropriate logic levels (High/Low) are applied to L293D direction control Pins. Velocity
control is done using the Pulse Width Modulation (PWM), the motor power supply is separated
from the logic supply. The input and control signal are taken from the L293D motor driver IC on
L293D Header (10pin FRC). Output from motor driver and the motor power supply are taken on
seven pin berg-strip.

Figure 3.16 L293D Motor driver configuration

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

57

ATMEGA2560 DEVELOPMENT BOARD MANUAL

L293D logic input header:


Pin
No.
3
4
5
6
7
8
10
1,2&9

Pin Name.

Pin Function

Input4
Inhibit1
Inhibit2
Input3
Input2
Input1
GND
NC

Direction Control Logic input pin B2


Driver 1 Enable Pin
Driver 2 Enable Pin
Direction Control Logic input pin B1
Direction Control Logic input pin A2
Direction Control Logic input pin A1
Ground pin
Not connected
Table 3.4

L293D output connector:


Pin
N0.
1
2

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

Figure 3.17 Schematic of L293D Motor Driver interfacing


L293D Connections
Interface logic connections:
Logic supply and Ground pin of L293D are already connected to the 5V and ground. We need to
connect the logic input pins with the microcontroller. 1 to 1 connectors are used for the logic
connections.

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

58

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

3.10 High Current Driver ULN2003 Interface


ULN2003 can drive 7 different loads, each with up to 500mA current. It can be used for driving
external inductive and resistive loads such as relays, solenoids, bulbs, heating elements, unipolar
stepper motor etc.

Figure 3.18 ULN2003 High current driver configuration

Figure 3.19 Schematic of ULN2003 interface


Connections:
Input logic signals to drive ULN2003 are connected to standard 10 pin FRC connector. Table 3.8
shows the connection diagrams.

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

60

ATMEGA2560 DEVELOPMENT BOARD MANUAL

ULN2003 logic input header:


Pin No.
1 to 7 (IN- IN7)

Pin Function
Logic input signal for channel 1 to 7
Table 3.8

ULN2003 output connector:


Pin Name.
Pin Function
1 to 7
Channel output from 1 to 7 to drive the load (With respect to
(OUT1-OUT7) VINE)
VINB
Regulated supply from the bridge rectifier with current rating
of the AC adaptor / SMPS used.
VINE
Power supply to the ULN2003 and cathode of the built-in
flyback diode. ( Connect the supply 5V to 50V)
GND
Ground
Table 3.9

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

3.11 RTC Interface


ATMEGA2560 development board has DS1307 RTC (Real Time Clock) for time keeping. It has
battery backup for continues clock operation in absence of external power. RTC can be used in
embedded applications like Utility Metering, hand held devices GPS, Spying gadgets, vending
machines, consumer electronics etc. RTC can be interfaced with the microcontroller over I2C
bus. For more details on the RTC, refer to DS1307 datasheet which is located in the datasheet
folder for the documentation CD.

Figure 3.20 Schematic of RTC interfacing

Figure 3.21 RTC configuration on board


RTC Connections
Connect SCK and SDA pins of the DS1307 with the uC by shorting jumpers as shown in the
Figure 3.21. Make sure that RTC battery has sufficient charge level.
The SQW pin on the RTC header is used to indicate the alarm condition, if the respective control
bits are properly set in the RTC chip.
Application Example:
Refer to experiment RTC demo from Experiments folder from the documentation CD

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

62

ATMEGA2560 DEVELOPMENT BOARD MANUAL

3.11 LCD Interface


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. 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.

Fig 3.22 LCD configuration

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

63

ATMEGA2560 DEVELOPMENT BOARD MANUAL

Fig 3.23 Schematic of LCD interfacing


Pin No.
1(RS)
2(R/W)
3(E)
4(Buzzer i/p)
5-8(DB0-DB3)

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

3.13 Buzzer Interface


The buzzer can be used as attention seeker or to indicate any event. Input pin of the buzzer is
connected to the Pin no. 4 of the LCD header.

Fig 3.24 Buzzer connections

Fig 3.25 Schematic of Buzzer interfacing


Buzzer Connection
The Buzzer is connected to LCD header pin no. 4. For interfacing the buzzer, either use 1 to 1
connector wire or use 10 pin FRC connector.
Application Example:
Refer to experiment Buzzer_test from Experiments folder from the documentation CD.

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

65

ATMEGA2560 DEVELOPMENT BOARD MANUAL

3.14 ADC Interface


ATMEGA2560 has 16 ADCs connected to PORTF and PORTK. To test ADCs, three
potentiometers are connected on the board. They can be connected to ADC 0, ADC 1 and ADC 2
by shorting jumpers on the ADC connection header as shown in the Figure 3.26.

Fig 3.26 Potentiometer & ADC Header

Fig 3.27 Schematic of ADC interfacing


ADC Header (3 pin 2 line Berg strip):
Pin No.
Pin Function
1
(POT no.0) variable analog output
2
ADC0 input of ATMEGA2560
3
(POT no.1) variable analog output
4
ADC1 input of ATMEGA2560
5
(POT no.2) variable analog output
6
ADC2 input of ATMEGA2560
Table 3.11
Note: You can also connect output of the potentiometer to any other microcontroller pin by
using 1 to 1 connector wire.
Application Example:
Refer to experiment ADC LCD from Experiments folder from the documentation CD.

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

66

ATMEGA2560 DEVELOPMENT BOARD MANUAL

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

ATMEGA2560 DEVELOPMENT BOARD MANUAL

4.9 UART0 USB


In this program Microcontroller receives data from the PC, adds one to the ASCII value and
echoes back to the PC through USB port.
4.10 RTC demo
This program demonstrate the interfacing of External RTC (DS1307) in I2C interfacing mode,
we utilise the TWI module of 640microcontroller, in master mode with freq of 100 KHz.
4.11 Servo control
In this program we demonstrate the servo motor interfacing.
Six servos will be controlled with TIMER1 interrupts to get the better resolution. Servo motors
move between 0 to 180 degrees proportional to the pulse train with the on time of 1 to 2 ms with
the frequency between 40 to 60 Hz. 50Hz is most recommended.
4.12 SD card interface
This application is for SD card interfacing.
It will first initialise the SD card and write at 1st block of 512 bytes, and then it read the same
block. Finally compared for valid read.

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

68

ATMEGA2560 DEVELOPMENT BOARD MANUAL

5 Schematics

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

69

ATMEGA2560 DEVELOPMENT BOARD MANUAL

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

70

ATMEGA2560 DEVELOPMENT BOARD MANUAL

NEX Robotics Pvt. Ltd. and ERTS Lab IIT Bombay, INDIA

71

Potrebbero piacerti anche