Hi gurus
I am about to put on my big boy pants and start using atmega328pu chips off my arduino uno.
I bought some of these breadboard kits because they suited my design for my project. http://allgaiershops.com/product_info.php?products_id=32
I am going to use a breadboard power supply which outputs 5v or 3.3v.
Can someone confirm for me please that I connect ground to pins 8 and 22 and 5v to 7,20 and 21
Also I have successfully hacked a gps-500 from a streets and trips recently and it came with a usb to serial cable. The post I used to hack it said you can use the cable as a usb to serial(ttl) as well so I am going to use it if I can.
The pinout for the gps is as follows and the colours are the cable colours
Pin 1: black looped inside the cable to pin 4.
Pin 2: brown Ground
Pin 3: red Data out, 4800 baud RS-232 NMEA format
Pin 4: black looped in the cable to pin 1. Cable communicates with computer TxD, but is not used (can be safely omitted).
Pin 5: yellow Power in. 5V is supplied by USB, but the device claims to accept 3.3V.
Pin 6: not connected
So can I connect the red to rxd, black to txd,yellow to xck and brown to gnd on the 6 pin header and use it to program my breadboard atmega328pu?
I have already successfully set up my uno as an isp and programmed each of my chips with the bootloader.
Sounds like you're making good progress.
Minimal wiring:
Doesn't sound like you have a DTR line in there - you'll need a reset switch then. Press & hold it until the IDE says "downloading xxxx of 32xxx bytes) so the bootloader gets synced up.
Cable pinout sounds plausible - try just power, gnd, and a signal out from what you think is the atmega tx out back to the PC, see if you can get good data out.
If not, try the other line for serial.
The breadboard kit if you have a look at that link I provided has a reset button on it already. It also states it has power supply caps, however if I connect the power and ground directly to the pins I mentioned then the caps will be bypassed?
When you say to push and hold the reset button to sync the bootloader, I am guessing you mean after I have successfully connected the usb to serial connection?
It also has an isp header on it, is that of any use to me?
Ok, I couldn't open that link before.
The electrical design will be what I showed in my schematic, with the power supply caps across the power & ground pins.
Use a multimeter & confirm the ATMega pins connect to the header pin right next to them.
The Serial port connector doesn't show a DTR pin - so, when you're ready to download a sketch serially, you can press & hold the reset button, and when the IDE says "loading xxxx bytes of 32xxx" let go - that will sync the bootloader up with the IDE.
Thanks CrossRoads
The sda,scl,vcc and gnd pins all match up with the atmega328 pinout. The vcc and Avcc and gnd and Agnd are all ties together so I only need to run 2 wires and you were correct about the cap, the gnd and vcc run to each pin so it is a smoothing cap.
I have pulled my cable apart and its pretty basic. There are only 4 wires really because 2 of them just loop.
I have identified the 5v and gnd so that only leaves 2. One will be rx and one will be tx.
Do you know of any simple sketch I could upload to it to verify which is which?
Try something like this, compile & upload it. Should be pretty close.
byte toggle = 0;
void setup(){
Serial.begin(9600); // set IDE serial monitor to match
}
void loop(){
if (Serial.available)()>0){
digitalWrite(13,(toggle)); // every time a byte is received from serial monitor, change the state of the LED on pin 13
serial.print(toggle); // send the same back to the serial monitor
toggle = 1-toggle; // flip the bit: 1-0 = 1, 1-1 = 0 (neat tip from retrolefty? pauls? coding badly? - one of those guys 8)
}
}
I have soldered up a header for it and I am trying to find which wire is which.
I have managed to do a loopback test by wiring the rx and tx together and typing in serial monitor and it writes back whatever I send so I definately have the correct wires.
I have also set up an led on pin 13 and a resistor from ground to the led and that is lighting up so I have 5v power and rx and tx to the board.
However I get an odd message when I try to upload a sketch.
Firstly, I should add that the cable comes up as a microsoft gps cable and installs the drivers for it, I am not sure if that is ideal. I read something about the chip inside it being a prolific one, perhaps there are better drivers available for it.
Secondly when I hit the upload button, it says could not convert "Serial.HardwareSerial::available' to 'bool'
No amount of holding the reset button down does anything.
I have checked it is using the correct port and I have tried changing the board to all the ones available, mini pro with 328 seemed the most logical because it is usb to ttl programmed also.
Did you compile it first?
I just tried now, found 2 small errors, had an extra ) and was missing a capital S.
byte toggle = 0;
void setup(){
Serial.begin(9600); // set IDE serial monitor to match
}
void loop(){
if (Serial.available()>0){
digitalWrite(13,(toggle)); // every time a byte is received from serial monitor, change the state of the LED on pin 13
Serial.print(toggle); // send the same back to the serial monitor
toggle = 1-toggle; // flip the bit: 1-0 = 1, 1-1 = 0 (neat tip from retrolefty? pauls? coding badly? - one of those guys 8)
}
}
I must not have because it compiles fine now and instead I am getting an avrdude error.
I don't think it is receiving the serial signal back or something.
I did the loop test okay though so the data must be there.
I have tried switching the rx and tx cables over and still get the same result.
What is required exactly to program this way? I mean can the chip be programmed from the 5v from the usb cable only or does it need external power and if so to what connection points?
/What I have done as I was having no luck with just the usb cable is use a 5v breadboard supply and run a wire to pin 7 for the vcc and pin 8 for the ground. As the internals of this breadboard adapter are connected I should only need the one wire to each.
An externally placed led and resistor lights up when I power it up so that is all good.
Sorry for the late reply, been rather busy lately renovating
"What is required exactly to program this way? I mean can the chip be programmed from the 5v from the usb cable only or does it need external power and if so to what connection points?"
If the chip has a bootloader, then yes it can. I've programmed tons of promini's that way. FTDI Basic provides power, gnd, and the 3 signals; Rx, Tx, DTR to drive the reset pin.
So you need VCC, GND, Rx, Tx, Reset, xtal/caps hooked up.
Basically what I show in reply #1.
If you don't have a DTR source, then you have to press the reset button at the right time to get that performance.
Well I have exactly that hooked up, obviously without the DTR but the reset button should be connected correctly according to the specs so I do not see what else it could be.
The bootloader is okay because I pulled my uno chip out and replaced it with one of those I burnt and uploaded a sketch to it fine and it worked.
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51
Which apparently means the computer isn't communicating with the arduino