Go Down

Topic: Programming without Arduino (Read 6824 times) previous topic - next topic

aaroncm

Hey guys, I went out and bought an Atmega328p chip that contains the Uno Bootloader. I didn't have enough for an Arduino board or anything, I have it in the Breadboard at the moment with the two caps and crystal. Is there any way to play with it, program it, with a few jellybean parts and the serial/parralel port? I don't know if it would help at all, but I have a Picaxe serial->3.5mm Jack programmer. But yeah, dunno when I can get my hands on a programmer board, so if I could get it programmed by any means now, that would be awesome.

Any ideas?

Thanks,

Aaron  ^_^

majenko

All you need is some way of connecting a serial (RS-232) signal to the chip.

Most people use a cheap USB->TTL RS-232 dongle (about $2.50 on eBay).  The other option is an RS-232 to TTL converter, which consists of a DB9 connector, a MAX232 chip, and some capacitors.

Do not connect the chip directly to an RS-232 port on a computer.  Those ports can generate up to +/- 12V which will blow up your chip.

aaroncm

Thanks for the reply.

So there's no way to program it with jellybean parts? I was kind of hoping I could just hook it up via serial directly with a resistor or two, but I guess not. How about the parallel port?

Or will I just have to wait until I purchase a Uno bored?

Thanks! :)

majenko

You can make an RS-232 to TTL converter with "jellybean" parts, but it's not a simple task.

The RS-232 protocol uses -5 to -12V for a HIGH, and +5V to +12V to +12V for a LOW.  TTL uses +5V for a HIGH and 0V for a LOW1.  So you'd need to invert the signals somehow, and limit the voltages.  Tricky to do properly, which is why the MAX232 chip exists.

I would suggest hitting eBay and getting a USB->TTL dongle.  There's millions of them out there and they're dirt cheap.  Basic ones just provide the TX and RX signals, so you will have to manually reset the chip at programming time to enter the bootloader (takes practice to get the timing right).  More expensive ones based around the FT232 chip can have the DTR signal available, which you can connect to the reset pin of the ATMega328p chip through a 100nF capacitor to auto-reset the chip to make programming easier.

----
1 Yes, I know, <0.8V for LOW and >1.2V for HIGH is the real TTL values, but 0V and 5V is enough for most people on this site to know.  Terry Pratchett calls this "Lies To Children"

aaroncm

Could I just build something like this:




majenko

If you have the parts, yes, that might work.

I have seen these circuits sold by (I think it was) sparkfun, and they "just" work, if your serial port is up to the job.

Try it and see.

But still, do yourself a favour and spend your sweety money on a USB->TTL adapter - it'll save you so much hassle in the long run.

aaroncm

haha thanks. I will save up for one, but I'll build this circuit now!

Could you maybe give me a quick summary of programming it? I know how to write my first program, I assume I just connect the Tx and Rx up to the chip, and hit program on the PC?

I'm downloading the IDE now, I've never even used that. Do I just ground the reset pin or something to initiate programming?

I know these answers are probably available, but I'm not sure if it would be the same for the method I'm using, and just wanted to be sure. Any help appreciated.

Thanks majenko :)

majenko

Connect chip TX to PC RX, and chip RX to PC TX.

Connect RESET to +5V through a 10K? resistor, and to ground through a pushbutton.

Press the button to reset the chip and enter the bootloader at the right time just after pressing the "upload" button in the IDE (as soon as it tells you how big your sketch is).

Oh, and don't forget the 100nF decoupling capacitors on the power pins of the chip.

pito

#8
Jun 07, 2013, 01:41 pm Last Edit: Jun 08, 2013, 11:54 am by pito Reason: 1
Looong time back I used similar circuit with one exception (and maybe an issue with your above design): the -12V for transmitting (or better to say something around -6V) was generated from PC's side Tx signal  via a diode and a 100uF capacitor.. So the Tx signal from the interface towards PC was +5/-6V. I think you may still google it somewhere..
Yea - still alive: http://www.uchobby.com/index.php/2007/06/11/ttl-to-rs232-adaptor-explained/
Edit typos


aaroncm

Awesome thanks guys. Pito, I'll look into that for sure also =)

I've created the cable, had to find some old female pin headers and cram them over the serial pins. Really scavenging here...

But got that all good, now it's time to build the circuit. Right. Now.

Will update you guys soon on progress, hopefully it'll work =)

Thanks!

aaroncm

Ok I have completed the circuit... As expected, I can't seem to get it to upload. I'll continue to check things, but do I have to configure the IDE for serial at all?

I just opened the blinking LED example program, and I get:

Code: [Select]
avrdude: stk500_getsync(): not in sync: resp=0x30

I'll continue to look for issues with the circuit, but yeah... Hmm..

Any help appreciated, thanks =)

Aaron

PeterH

For uploading you only actually need the Rx part of the serial circuit.

Have you confirmed that your circuit correctly converts the RS232 active and inactive states to the corresponding TTL states?

Do you know what frequency the 328p is running at? (Do you even know for sure that your circuit is complete? If it's configured to use an external clock and you don't provide one, you're wasting your time.)

aaroncm

Yeah I know but I figured I might as well add the Tx part as well...

I'm running it off a 16Mhz Crystal

nickgammon

You may have a 16 MHz crystal but is it configured to use it? Plus it may have the "divide by 8" clock fuse set.

If and when you get a Uno you can use the sketch here to answer such questions:

http://www.gammon.com.au/forum/?id=11633
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

GoForSmoke

Building an Arduino on a Breadboard

http://arduino.cc/en/Main/Standalone

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Go Up