Pages: [1]   Go Down
Author Topic: Using empty UNO board to program external ATmega328  (Read 2466 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wasn't sure if this could be done, but apparently it can.

I pulled the atmega328 out of the UNO board. Put it into a circuit on a breadboard (with crystal and two caps) to drive a stepper motor circuit. Then I jumpered the reset pin on the ATmega328 to the reset pin on the UNO. I also jumpered the RX pin and TX pin similarly. Finally I also jumpered a ground to ground in the same way.

I did not use D0 or D1, so there was no conflict with external circuitry on those pins. The ATmega328 is powered externally at 5v and the UNO board is powered through the USB cable.

I was able to upload sketches just as if the ATmega328 was still in the UNO and it ran great. It never failed to upload new sketches or run them.

My question is, can I rely on this method, or is there a potential conflict between the UNO's crystal clock and the ATmega chip's external crystal clock?  In other words, if the two clocks were to be too far off in frequency, would longer sketches possibly fail to upload correctly?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 I would think you should be able on counting on it to work long term. There is always going to be slight speed variation between crystal to crystal and even more so between resonators. And the new Uno bootloader program works at yet a high baudrate then prior boards. However USART characters 'resync' their bit sample timing with each new start bit, so there is still tolerance for slight speed mismatch.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the reply.
Well, that is good news.

Also, I should mention in case anyone tries it...

If the UNO is unplugged from the computer, it has no power on it and tends to drag down the reset line, even with a 10k pull up on the Atmega328's reset pin, so I had to disconnect the reset line from the UNO to get the breadboard circuit working when the UNO is powered off.

It may even require powering off the ATmega328's circuit to get the reset to work again... not sure why, just something I noticed.
Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 6
Posts: 375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can this technique be used to program an ATmega328 with a non-Uno bootloader?
For example, can I use an Uno board (minus microcontroller chip) as a USB-to-Serial programming interface for something like the Arduino Pro-Mini?  (The Pro-Mini board uses the ATmegaBOOT, whilst the Uno uses Optiboot, AFAIK)
Logged

0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12525
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If the UNO is unplugged from the computer, it has no power on it and tends to drag down the reset line, even with a 10k pull up on the Atmega328's reset pin

That's possibly solvable by adding a 100nF in series, so that only fast downwards edges pull it down.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can this technique be used to program an ATmega328 with a non-Uno bootloader?
For example, can I use an Uno board (minus microcontroller chip) as a USB-to-Serial programming interface for something like the Arduino Pro-Mini?  (The Pro-Mini board uses the ATmegaBOOT, whilst the Uno uses Optiboot, AFAIK)


I also used this method (empty UNO board to program ATmega328 chip) to program a 328 chip which had the older Duemilanove bootloader on it. The only difference in programming was that I had to choose "Duemilanove and ..." as the board type (even though the actual board was an UNO).

One difference in the bootloaders is that at power-up, the optiboot loaded chip starts the sketch instantly.  The Duemilanove-bootloaded chip waits one second.  However, both boards wait a second after a reset press, before running the sketch.


I'm not sure what a Pro-Mini is, exactly. But if it doesn't have the USB port, there may be a way to use the UNO to communicate with it. At least the bootloader difference shouldn't be an issue.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If the UNO is unplugged from the computer, it has no power on it and tends to drag down the reset line, even with a 10k pull up on the Atmega328's reset pin

That's possibly solvable by adding a 100nF in series, so that only fast downwards edges pull it down.
Thanks for the heads-up.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am new to the whole arduino controller, but so far i enjoy it. So i can remove my ATmega328 from the UNO board and put it onto a bread board with my program loaded onto it and add the crsytal and two capacitors and have it work just like the UNO would work? Thank you
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 210
Posts: 13037
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, but I should add one note...

In one of the tutorials, it shows the Aref pin connected directly to 5v. You should not do that, it is dangerous. If you are not using the external reference for analog inputs, you should leave that pin unconnected. If you are using the external reference, you should use a 5k resistor to connect an external voltage to that pin. That will prevent the chip from burning in case the internal reference is selected accidentally in the sketch.

Look up the tutorial for external reference if you are going to use that feature.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the tip. What is a good FTDI programmer with USB to program an ATMega328 chip?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been using this one to program prominis since August.
http://www.gravitech.us/arliandpropr.html
Have seen complaints about the newer model and it surface mount connector cracking traces & stuff.
The thru-hole has been solid for me. I put mating 0.025" square pins on my prominis.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the link! I am trying to program a chip to read RFID card tags. I have an ATmega328 chip and also an UNO arduino. I dont understand the marking on the UNO. Does 1 on the UNO also correspond to 1 on the ATmega328 chip and so on? I cant seem to figure out out how each pin numbering on the UNO corresponds to the ATmega328 chip.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the 168/328 pin mapping to D0, D1, etc.
http://arduino.cc/en/uploads/Hacking/Atmega168PinMap2.png

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: