Thursday, March 11, 2010

Tiny 2313 Project Development Board
Tahan Prahara,  




This is my first time using the AVR. I like to learn using the ATTiny 2313, because it is faster than MCS-51, cheap and the circuit is very simple. The chip has only 20 pins. I was interested because I want to build a simple line follower robot controlled by this MCU.
The circuit has built in voltage regulator, the LM7805 and the ISP Header for program loading. The DC input circuit also has protection diode 1N4002.
DOWNLOAD EXPRESS PCB FILE: AT-Tiny2313.zip
Tiny2313
Figure 1. Hardware Schematic
Notes:
1 The XTAL can be 4MHz, 8MHz, or 11.0592MHz.
2 DC input voltage using the AC adapter can be 6V-15V.
layout pcb
Figure 2. Component placement. 
ISP Programmer
The ISP loader cable can be made easily from the circuit shown in Figure 3. The connector is DB25 male type. The cable length should be less than 1m. This loader is compatible with most of the desktop LPT port.
isp
Figure 3. ISP Programmer Cable (STK200)
Using the CodeVision AVR

1.      Create New Project by click File -> New
 1
2.      Click Yes to use The CodeWizardAVR.
2

3.      Set the Wizard like this. (for XTAL 11.0592 MHz). Then Click File -> Generate, Save and Exit

53 4

4.      Insert your program (Bold text) 
This program was produced by the
CodeWizardAVR V1.25.9 Evaluation
Automatic Program Generator
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : Tahan Prahara Test
Version :
Date    : 5/11/2008
Author  : Freeware, for evaluation and non-commercial use only
Company :
Comments:
Chip type           : ATtiny2313
Clock frequency     : 11.059200 MHz
Memory model        : Tiny
External SRAM size  : 0
Data Stack size     : 32
*****************************************************/

#include
#include

// Declare your global variables here

void main(void)
{
// Declare your local variables here

// Crystal Oscillator division factor: 1
#pragma optsize-
CLKPR=0x80;
CLKPR=0x00;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif

// Input/Output Ports initialization
// Port A initialization
// Func2=In Func1=In Func0=In
// State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;

// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0xFF;

// Port D initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0A output: Disconnected
// OC0B output: Disconnected
TCCR0A=0x00;
TCCR0B=0x00;
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// Interrupt on any change on pins PCINT0-7: Off
GIMSK=0x00;
MCUCR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// Universal Serial Interface initialization
// Mode: Disabled
// Clock source: Register & Counter=no clk.
// USI Counter Overflow Interrupt: Off
USICR=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;

while (1)
      {
      // Place your code here
                PORTB=0b00000000;          
                delay_ms(2000);                   // Delay 2000 mS = 2 S
                PORTB=255;
delay_ms(3000);
PORTB=0x00;
delay_ms(2000);
PORTB=1;
Delay_us(10)                         // Delay 10 uS
      };
}

5.      Click Project -> Configure, click tab After Make then,
 6

Mark the Program the Chip, after that click OK!
7

6.      If this is your first time using CodeVision AVR you need to setup the programmer. Just click on Setting -> Programmer.
8

Click on Kanda Systems STK200+/300, then click OK.
9

7.      To compile and programming the chip, click Project -> Make or just click on red arrow buttom!
10

If you get no error and no warning. You can just click Program the Chip buttom. The hex code will be programmed automatically.
  
Tahan Prahara and Pujo at Line Follower Competition, Galelobot 2008.

Single-Side PCB for Easy Downloader V1.1

Daniel José Viana, danjovic@hotmail.com
I have designed a small single side PCB for the Easy Downloader V1.1. The board size is only 10.5 x 3.75 cm. It can make easily using toner transfer method. The component placement is shown below. Please notice that a DB9 connector can be soldered out of the board, so the PCB can be cut, the board size will be 9.2 x 3.75cm.

The prototype board with completed components.

The diode was placed on the copper layer.

Another feature is two extra holes to allow the use of a miniature crystal instead of the HC-49 type. See both crystals at the picture below.


I have made a bit modifications on the design of VPP switch and replace the MAX232 with two transistors as shown below..


Download
The Layout and schematic are available in several formats: Eagle Layout Editor and PNG.
Layout, 300dpi, PNG; 600dpiPNG
Schematic, PNG format, (also PDF format)
Board and ComponentsMask, in Postscript format

Data Acquisition System using ATmega8


Introduction We can use a PC for connecting the homemade data acquisition hardware and produce the GUI for user friendly graphical presentation easily. One of the project that uses Visual Basic is the Data Acquisition & Logging System using AT89C51 made by Abbas Raza. In this project we use a PC for GUI display and the homemade data converter board using the AVR microcontroller. The circuit is built with the ATmega8. The chip has the onchip 10-bit resolution A/D Converter. Temperature sensor are connected to the 6 channels ADC input. You can connect up to 8 sensors with the ATmega8 TQFP package. The analog inputs are captured by sending a command from PC. The readings will display graphically or text data. The data can also be recorded as the database.
Hardware The complete hardware schematic for the ADC board is shown in Figure 1. The board consists of the ATmega8, the temperature sensor (LM335), and the serial interface. The on chip firmware controls reading the ADC converter, receives commands from PC and sends the reading to PC. The microcontroller is running with 8MHz crystal oscillator, if we use the internal RC oscillator, the external crystal may be omitted. The ATmega8 DIP version has 6 channels analog input. If you need up to 8 ADC input, you can use ATmega8 in TQFP package, or you can use another AVR microcontroller with the on-chip ADC.
We use LM335 temperature sensor. It can measure the temperature using two wires remotely. The chip produces an output signal that is proportional to the Celcius temperature scale. The trimmer POT is used to calibrate the correct output voltage at known temperature, for example 2.98V @ 25° C.


Figure 1. Temperature Logger hardware schematic.
Software Features of the software are as follows.
  • Adjustable sampling interval,
  • Real time view in single graph or multiple graph,
  • Record the data, save, and open the recorded database,
  • Get statistically reading, print the record and graph (or export it as the metafile, JPG),
  • Serial control window for monitoring and manually data transfer.
The full version PC software is designed for capturing up to 16 channels. In this version, the PC software will read 8 channels. For the ATmega8 in DIP version, it can display only 6 channels.


Figure 2. Main screen of Data Acquisition program
Data transfering between ADC board and PC uses the following protocol .
  • For the first time connecting, after opening serial port, PC try to connect the ADC board. The PC send a character '>' (0x3E) and the board will echo it back.
  • After the connection has been established, we can send the command to the ADC board. For command read, PC sends character 'r' (0x72), and the board responses with ADC reading as: '\rD' + 2byte(ADC0) + 2byte(ADC1) + … + 2byte(ADC7), total 18 bytes length. The reading is 16-bit data, (10-bit resolution) with high byte send first followed with low byte.
Note :
For real time recording using fast sampling, for example 50ms or 100ms, better view in a single graph. The display performance depends on the PC speed.
I tested running with 700MHz CPU speed, 128MB RAM, it gives smooth view but for multiple view, it could not display fast enough.
Microcontroller Program The AVR program was written in assembly language. The main code running waits the serial command from PC. The speed is set to19200 8n1 format. If the board receives character '>', the AVR must echo the character '>' to the PC. This step is used to check the hardware is connected or not. Another command is 'r' (read), the microcontroller reads 8 channel ADC and sends them to PC serially.


Figure 3. ATmega8 Assembly code.
If you have only 6 channel, for last channel (ADC6 and ADC7), you can modify the source code so the microcontroller will send a dummy value. These values will be ignored by PC software. Or if you want to ignore another channel from PC logging, just fill ADC values with dummy into their field. The descriptions have been commented in the source code. You may modify the source code easily.
Download Software for PC Data Acquisition and  microcontroller

Atmel 89S and AVR Programmer(STK200)

For AT89Sxx and AVR
Tahan Prahara, prahara_satria@yahoo.co.id

If you are looking for an easy-build and useful programmer for the AT89Sxx, AVR MCU, and tiny AVR, here is my simple circuit. The board is signal compatible with the STK200 parallel programmer.
STK200 Parallel Programmer
Layout PCB
Sofware
The loader hardware can be used with many programs.
1.       AT89Sxx series, we can use Asim loader ISP flash programmer V 3.0a http://www.kmitl.ac.th/~kswichit/cheapcable/index.html
2.       The built-in programmer with CodeVisionAVR from http://www.hpinfotech.ro (or WinAVR (freeware)
How to use CodeVisonAVR please visit this http://www.kmitl.ac.th/~kswichit/tiny2313/tiny.htm
3.   AT89 and AVR u can try this http://www.lancos.com/prog.html

Download
The PCB file is ExpressPCB.
Schematic           : STK200.sch
PCB                   : STK200.pcb   
For cable length should be one meter or less.

Any questions please email me prahara_satria@yahoo.co.id

AT89Sxx Base Board

AT89Sxx Base Board


This is my second design of the AT89Sxx Base Board. The board is based on the AT89S51, AT89S52, or AT89S53. This board uses STK200 for program loading and includes the serial port at the STK200 header. When I need to program the MCU and need a serial comunication, I do not need to plug and unplug the connector. Because I am using the USB to Serial ISP programmer. Then with the STK200, we must built the parallel programmer STK200. This parallel programmer STK200 can also be use for AVR programmer. This is the reason for the new design.
The complete schematic is shown below.
STK200
The PCB layout.
Download the PCB file using Express PCBAT89Sxx.PCB .

How to make PCB? Please visit this link http://www.riccibitti.com/pcb/pcb.htm . I recomended to use the 190mg glossy photo paper.
How to use this board.
1.      Make parallel programmer STK200.

2.       Download asm and C-compiler MIDE-51 http://www.opcube.com
3.       Before program loading, you can test the code with the TopView Simulator. With this simulator you can learn how to interface the I/O devices, e.g. LED, Keypad, 4x4 keypad, LCD, and serial comunication.
4.       Please visit http://www.mytutorialcafe.com  for tutorial.
5.       Download Asim's Loader at http://www.kmitl.ac.th/~kswichit/cheapcable/index.html
If you got questions please contact me at prahara_satria@yahoo.co.id



AVR ATMega 8535/16/32Learning Kit

Eko Yulianto,eyulnt@yahoo.com

Build the AVR learning boards with I/O interfacing modules.

Mainboard Features
  • Pin compatible for 40-pin AVR Microcontrollers
  • Single sided PCB, header for 4 I/O ports, ISP port and RS-232 port
  • Built in +5V voltage regulator LM7805
  • Onboard In System Programmer header
Figure 1 Mainboard layout
I/O Modules:
LED Board
  • The LED board provides 8-bit dot LED. The board can tie to the main PCB easily with a 10 pin ribbon cable.
Figure 2 LED Module
Tact Switch Module
  • The switch module also for 8 bits input port. When the key was pressed, the logic will be '0'.
Figure 3 Tact SwitchModule
LCD Module
  • The LCD is HD44780 compatible 2x16 text LCD.
Figure 4 LCD Module
Keypad Module
  • The board is 4 matrix keypad. Student can learn how to write the code that scans the key.
Figure 5 Keypad Module
Figure 6 Signals of the ISP header 

Download the complete file here : kit_module.zip
The zip file contains all PCB boards, and the Atmel MCS-51 main board, RTC, Dallas Digital Thermometermodule.
Any question please contact: eyulnt@yahoo.com
Updated: 6 October 2009

AVR910 - AVR Programmer

By:
Prahlad J. Purohit, prahladp@gmail.com

INTRODUCTION
AVR910 is a very useful programmer. It can program almost complete range of AVR chips. The original version made by Klaus is here, http://www.mikrocontroller-projekte.de/Mikrocontroller/AVR-Prog/AVR-Programmer.html. The programmer uses ISP capability of AVR chips. AVR910 first appeared in AVR910 application note by ATMEL. It is one of the fastest programmers for AVR. We can use AVR PROG available in AVR Studio, AVR OSP or AVRDUDE for interfacing with this programmer. The programmer connects to PC using serial port. For the notebook PC, we can use the USB to serial converter.

HARDWARE
I have done some minor modifications in the original design by Mr. Klaus. Klaus's solution uses transistors for RS232 - TTL level conversion. I changed to MAX232. My experience with such transistor solutions is not good. This solution may not work for some computers. The MAX232 is a better solution. If your target board uses 3.3V, try the MAX3232 in place of MAX232. Second difference is the LED, Klaus's design uses bi-color LED, I found it difficult to get such LED so I changed to use two LEDs, RED for busy and Green for idle. Rest of the part is the same as Klaus's design. Here are the schematic (click on the image to enlarge the schematic), PCB layout files and component placement files.




CONNECTOR ON TARGET


SOFTWARE
The software has two parts. The first one is the FIRMWARE that you need to burn into the ATTINY2313 chip, and the second part is the PC software that used to send the object code to the programmer board.

FIRMWARE
For the 7.3728MHz XTAL frequency, with the baud rate of 115200 you can burn this hex file avr910_2313_v38b.hex into the 2313 chip.

If your XTAL is different frequency, or need to modify the baud rate, you can modify this assembly source file avr910_2313_v38b.asm and generate your own hex using a suitable assembler.

Please note that, the ATTINY2313 chip from the factory is configured to use internal oscillator. To use external crystal, we must set the fuse in your ATTINY2313.

PC SOFTWARE
You can use AVR PROG included in AVR Studio. However the AVR PROG works only with baud rates above 19200.

Alternatively you can use open source software like  ATMEL AVR-OSP or AVRDUDE.