Originally, I used PIC16F877 microcontroller to teach mechatronics class (see the page PIC & I/O Board). While most PIC compilers are expensive, AVR has WinAVR, which is a open source compiler, widely used and supported by a huge community. So I wrote example programs for AVR ATmega16 to use with ET EXP4 I/O board in the same way as I did for the PIC.
ET-CP-AVR v3 Board ET-CP-AVR v3 Board is developed by ETT company. It uses AVR ATmega16 with an 8 MHz oscillator. I chose this board because it is designed to conveniently connect with ET-EXP I/O Board through 34-pin IDC connectors. The board is shipped with AVR-ISP programmer via a parallel port with PonyProg program. For short, I will call this AVR board in the rest of this page.
ET-EXP4 I/O Board ET-EXP4 I/O Board is also developed by ETT company. It contains many input/output modules that is often used in mechatronic systems such as LEDs, 7-segment, dot-matrix LED, LCD display, matrix switches, stepper and dc motor, relay, speaker, and DAC. The AVR board is designed to conveniently connect with ET-EXP I/O Board through 34-pin IDC connectors. Because both boards were made by the same company, so the pin configurations are matched. This device will be later referred to as I/O board.
Wiring AVR and I/O Boards
The picture below shows the cable connection from AVR board to I/O board as follows:
Connect a 34-pin cable from both boards.
Connect a single wire from 5V pin on AVR board to VCC pin on I/O board (34-pin connector doesn't supply 5 volt to I/O board).
On I/O board, connect 14-pin cables from PORTA, B or C to I/O device(s), as instruct by each tutorial.
Connect 10-pin cable from AVR-ISP programmer to AVR board.
Software
WinAVR is an open source software development tools for the Atmel AVR microcontrollers on Window platform. It includes the GNU GCC compiler for C language. Since the compiler was built from GCC for AVR chips, the compiler alone is called AVR-GCC. WinAVR can be download at the WinAVR page.
PonyProg is a programmer software that can be used with parallel AVR-ISP programmer. It is important to setup fuse bits correctly, or the AVR chip cannot be programmed again. Read the instruction how to use PonyProg program with ATmega16 in the document below. See PonyProg page for more detail.
Procyon AVRlib is a library of easy-to-use C functions for a variety of common tasks (like LCD, I2C, SPI, etc) using AVR processors. The source code is available to download at Procyon AVRlib page. I install AVRlib manually and use makefile to compile the code without any problems.
Note: How to Compile Source Files on Command Line I find that using AVR-GCC with AVRlib library on command line is simpler and easier than with AVR Studio (Window GUI). However, we need to modify makefile (which can be obtained from AVRlib examples) manually. Here is what you need to modify in the makefile.
Put the name of target MCU. In my case, it is Atmega16.
MCU = atmega16
Put the name of the target file (the file which contains your main() function). For example if I have function main in file ex2_1.c, then I write
TRG = ex2_1
Put the name of the directory where you "installed" or unzipped the AVRlib files so the compiler can find them. The directory should not contain spaces in its name or path. For example,
AVRLIB = C:/Code/AVR/avrlib
List any C source files which are used by your target files. For example,
SRC = $(AVRLIB)/rprintf.c $(AVRLIB)/timer.c $(AVRLIB)/lcd.c $(TRG).c
Then, to compile, simply change directory to the source file. Then type command:
> make clean
> make
The following source codes are made in attempt the match the flow of the mechatronics lab with PIC. To use the source code, you need to download, modify the makefile (check the directory name where you install your AVRlib), and then compile with command make *Note that there are no lab documents for this page. Please use the lab documents in the page Mechatronics Lab with PIC16F877 and I/O Board for board and wiring setup. You can also find this information in the source code.