trouble Programming homemade arduino.

Last year i made a few different arduino layouts to be used in my college. the boards were working perfectly fine as far as the controller atmega328P part was concerned. but when it came to loading the program I initially used cp2102 and pl2303 usb ttl converters. they allowed me to directly load the program via serial interface. but the problem was that before loading the program i had to keep the reset pin pressed. to avoid that there was the option of using DTR on the pl2303 and it worked. I also tried via the rs232 interface. but my laptop doesnt have that serial port so i ditched that idea.

My Question: I wanted to try some other programming methods. after some research i found one option was using USBasp. but it uses the SPI pins of the atmega328 right?? when i checked the arduino schematic i found that the USB port was connected to the Atmega8 and the atmega8 communicated to atmega328 via serial interface.. I couldnt find much content explaining how that was done. could someone please tell me how does that atmega8 on the arduino UNO R3 actually load program onto the main controller. I wanted to make my own programmer using atmega8 which allows me to directly load program into the main controller using serial interface. (in USBasp i have to click "Upload using programmer"). i want to upload directly using the main upload button. also can anyone tell me whether there is any code preloaded into the atmega8 programmer that sends the USB data over serial interface to the atmega328???

The Arduino can work in two ways : with bootloader and without bootloader. When a sketch is uploaded via RX/TX, the computer talks to the bootloader, and the bootloader accepts the sketch and programs it into flash memory. Without bootloader, the sketch is directly programmed into the flash memory. In the menu is an option to upload a sketch with a programmer, that writes the sketch (and it also removes the bootloader). You need a programmer for that.

A programmer can be use to write a sketch (the bootloader is removed) or to burn the bootloader in the Arduino. Although it is not a SPI bus, I guess you could say that the SPI signals are used: the MISO, MOSI, SCK and reset.

There are many programmers. One of them is USBasp which uses the ATmega8. It didn't have the serial RX/TX in previous versions, it was added as a extra. As a programmer, the RX/TX pins are not used. Please forget that ATmega8. It is only used to act as a programmer.

A better way is to use a Arduino Uno or a ATmega328P and a ISP sketch. That makes also a programmer. Use either the ArduinoISP sketch, or have a look at this tutorial with its own ISP sketch : http://www.gammon.com.au/bootloader

stephing57: i found that the USB port was connected to the Atmega8 and the atmega8 communicated to atmega328 via serial interface..

Change "serial interface" for "ISP" (In System Programming).

And that preloader code you talk about on the USBasp atmega8 is the firmware of the usbasp. It is free, google it and you can download it. Making a homemade USBasp should not be hard.

ok so you are saying that usbasp is only used to load the program right.and it vil remove the bootloader. i dont think i vil be able to use the Serial.print() instruction with the usbasp.... since that instruction uses the rx/tx pins on atmega328.. but as you said the newer versions of the USBasp have the serial pins built in. So can i use the USBasp for serial communication?? like i vil load program through SPI but communicate through the serial port.... is there anyway i can use a device to both program the arduino as well as establish communication with the computer?? other than pl2303 or cp2102... you see i need to wire up the whole thing on eagleCAD such that only one wire(usb cable) goes from computer to the board. i cant use the arduino uno since i have added many extensions to the board(L293, LCD port and a few more).

There is the FTDI.

I use one of these to program all my custom-built Arduino compatible. I also place a 0.1uF cap in series between the DTR pin of the FTDI programmer and the 328p's (or whatever chip I am using) reset pin, which allows the auto-reset to work (as opposed to me having to push the button each time, like the OP mentions). Keeping the FTDI plugged in, Serial.print and such commands work as they do on an authentic Arduino.

So either use a USB-to-Serial converter (such as the FTDI - the authentic Arduinos use a reprogrammed 16u2 to do the same thing), or get an ISP programmer (which, yes, does kill the bootloader). You will still be able to use Serial.print commands with the latter, but you will still need a USB-to-Serial if you want those Serial comms to get to your computer. I find the FTDI adapter to be simplest for my uses, ymmv.

Yeah I have tried the FTDI option. it did work well. only i didnt try the auto reset part which i will... thank you for the quick helpful replies.....

madmattd: So either use a USB-to-Serial converter (such as the FTDI - the authentic Arduinos use a reprogrammed 16u2 to do the same thing), or get an ISP programmer (which, yes, does kill the bootloader). You will still be able to use Serial.print commands with the latter, but you will still need a USB-to-Serial if you want those Serial comms to get to your computer. I find the FTDI adapter to be simplest for my uses, ymmv.

hey do you know where I can find a way to do dat... atmega16u2 as USB to serial converter...

and for the ISP part you said that with ISP the serial.print commands work but i will need a separate USB to serial converter for the serial pins to communicate with the computer????? i thought the Serial.print commands communicate through the rx/tx pins only...

Peter_n: There are many programmers. One of them is USBasp which uses the ATmega8. It didn't have the serial RX/TX in previous versions, it was added as a extra. As a programmer, the RX/TX pins are not used. Please forget that ATmega8. It is only used to act as a programmer.

can i use the rx/tx in the newer version of usbasp to load program as well as communicate with my controller over serial interface??

stephing57:
hey do you know where I can find a way to do dat… atmega16u2 as USB to serial converter…

and for the ISP part you said that with ISP the serial.print commands work but i will need a separate USB to serial converter for the serial pins to communicate with the computer??? i thought the Serial.print commands communicate through the rx/tx pins only…

For the 16u2, see the Uno’s schematic. Honestly you are much better served using an FTDI though. Far less complicated.

Yes, Serial.print uses the Serial Port (tx/rx). Hence you need a USB-to-Serial (FTDI or similar) to convert the Serial signal to something your computer can understand. This is always the case, no matter how you got the program on the chip in the first place. ISP programming does NOT use the serial pins at all (SPI and Serial are 2 totally different beasts).