Tuesday, June 24, 2014

Parallel port Arduino programmer.

Notice: try this at your own risk. If you have a pre-usb computer system, you can still program your Arduino (with built in boot-loader). Stand alone Arduino chips are much cheaper than purchasing the retail board. There are two ports to consider. First is the parallel port and the second is the pin-out on the arduino.


You will need three resistors. Two 470 and one 220 ohm resistors go build the circuit. Parallel connector with a 470 ohm resistor soldered to pin 1. Solder a 220 ohm resistor to pin 11 of the connector. Solder, in order, the three wires of one of the cables to the resistor on pin 11 (which goes to pin 18 on the Atmega8), to the resistor on pin 1 (which goes to pin 19 on the Atmega8), and directly to pin 16 (which goes to the reset, pin 1).  Parallel connector with two of the three wires of a cable soldered to pins 11 and 1, respectively.  Solder the middle wire of the second cable to the resistor on pin 2 (which goes to pin 17 on the Atmega8), and one of the other wires to pin 18 (which goes to ground). (The third wire is not used and may be cut short).






Once you have your circuit built, you will need to find the hex file (we used the blink demo for compiling) for sending to the Arduino. If you use the gui environment, the file will be in a build directory under tmp.




After you install uisp, you should be able to install the binary file with:

$ uisp -dprog=dapa -dpart=ATmega8 if=Blink.cpp.hex -dlpt=0x378 --erase --upload

-----------------------

Update: Talked about this before.
Once you have programmed your Arduino then you can use your own stand alone circuit. Two ways to do it. either with a crystal and two capacitors (more accurate) or with a resonator (cheaper).


------------------

The way some one else did it.Try at your own risk.

Components required

9V Battery                     - 1
7805 Voltage Regulator   - 1
ATmega8                       - 1
DB-25 Female                - 1
Crystal Oscillator 4MHz  - 1
Resistor 10K                  - 1
Resistor 1K                    - 8
Capacitor 27pF               - 2
Capacitor 10uf                - 1
Capacitor 1 uf                 - 1

Softwares To Be Installed

1. avr-libc
2. binutils-avr
3. avrdude
4. gcc
5. gcc-avr
6. uisp

Software Installation
Now open your terminal and execute the following commands to install the softwares.
          
sudo apt-get install avr-libc binutils-avr avrdude gcc gcc-avr
sudo apt-get install uisp


Now create your first program.

Execute the following command to create the program file.

nano first.c

Now copy the following code to this file.

#include <avr/io.h>

#include <util/delay.h>

void sleep(uint8_t millisec)

{
while(millisec)
{
_delay_ms(1);/* 1 ms delay */
millisec--;
}
}

int main()

{
DDRC |=0b11111111;   //Declare PORT C as an output
while(1)
        
{
PORTC |=0b11111111;
PORTC &=0b00000000;  //turn off PORT C 
sleep(1000);

PORTC |=0b11111111;

PORTC &=0b11111111; //turn on PORT C
sleep(1000);
  }
return 1;
}

Next is to save the file. Press CTRL + O  to save the file. Now exit from the file. Press CTRL + X to exit from the file.
Next is to compile the code. Execute the following command to compile the code. Compiling will generate an object file.

avr-gcc -mmcu=atmega8 first.c -o first

Now generate the hex file from the object file. Execute the following command to generate the hex file.

avr-objcopy -O ihex first first.hex

Now upload the hex file to your microcontroller using the following command. Before executing the following command connect the programmer circuit to your parallel port.

sudo uisp -dprog=dapa -dpart=ATmega8 if=first.hex -dlpt=0x378 --erase --upload

Now you will get the following result in terminal. Then programming ATmega8 is successfull.






No comments:

Post a Comment