I wrote to adafruit asking a number of questions to which I could not find answers on the forum, but was told to ask here, so I am. I'll have many questions but will ask them one at a time, or two at time if the questions are closely related. And I will greatly appreciate the help!
Though my example is specific, I am looking for answers that will apply to ANY sketch. It's the process I need to know about. I have done well so far in building things, but seem to have a blind spot where I want to take the next step.
I have a sketch (Hello World to a 16x2 LCD) running on an Arduino Uno and a breadboard. (Using Arduino IDE on Linux.)
Can I get the same sketch to run using JUST the LCD and an ATmega328 chip on a blank board with wiring and a Power Supply?
(NOTE: I have the AVR ISP Shield Kit, but have not put it together yet, as I'm unsure if this the best method to achieve the above, if I can in fact achieve the above! lol If it is, then you can see where my next questions will come from!)
The whole point of all of this is that as I learn, I want to preserve some of the more interesting projects for future reference and for demonstration purposes.
Thanks much, anyone -
Putting an Arduino sketch on an ATmego328
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- clair
- Posts: 25
- Joined: Sun Nov 27, 2011 5:04 pm
Re: Putting an Arduino sketch on an ATmego328
Should have explained why I'm so confused -- here's the adafruit sentences that prompt my above question:
This is on the page of description for the AVR ISP Shield Kit:
"If you want to program Arduino bootloaders onto chips, using the IDE, check out our simple tutorial which shows how to solder up the kit and the sketch for bootloading. If you want to create a stand-alone AVR ISP programmer, we have a tutorial for that as well"
Since I think from adafruit, the ATmega chips come with the bootloader on them, I'm not worried -- and I don't even know if I need to have the bootloader on the chip that I use for a sketch if it will be a standalone project!
But, anyway, you see my problem. I want to have a chip with MY sketch on it. The explanation doesn't go there. I don't necessarily want to make a stand-alone AVR ISP programmer either. I DO want to make a stand-alone project!
This is on the page of description for the AVR ISP Shield Kit:
"If you want to program Arduino bootloaders onto chips, using the IDE, check out our simple tutorial which shows how to solder up the kit and the sketch for bootloading. If you want to create a stand-alone AVR ISP programmer, we have a tutorial for that as well"
Since I think from adafruit, the ATmega chips come with the bootloader on them, I'm not worried -- and I don't even know if I need to have the bootloader on the chip that I use for a sketch if it will be a standalone project!
But, anyway, you see my problem. I want to have a chip with MY sketch on it. The explanation doesn't go there. I don't necessarily want to make a stand-alone AVR ISP programmer either. I DO want to make a stand-alone project!
-
- Posts: 295
- Joined: Sat Dec 11, 2010 1:17 am
Re: Putting an Arduino sketch on an ATmego328
Hello Clair,
Perhaps the easiest way you can do this -- if your Uno is the kind with the 28pin DIP chip on it -- is to simply remove the ATMega328 chip from your Uno once the sketch is on there and working the way you like.
You can get a new ATMega328 from Adafruit that has the bootloader on it, and pop that into your Uno to continue using it for development.
Cheers!
Perhaps the easiest way you can do this -- if your Uno is the kind with the 28pin DIP chip on it -- is to simply remove the ATMega328 chip from your Uno once the sketch is on there and working the way you like.
You can get a new ATMega328 from Adafruit that has the bootloader on it, and pop that into your Uno to continue using it for development.
Cheers!
- clair
- Posts: 25
- Joined: Sun Nov 27, 2011 5:04 pm
Re: Putting an Arduino sketch on an ATmego328
Wahooo -- an answer that is clear and to the point.
The day after that post I found on the arduino site a pin diagram of the chip. But a pin diagram that tied the
chip pins to the the pin numbers on the Uno board. When I saw that I realized that I could do that.
Now -- Stephanie -- a follow on question ===
Do I always have to use 328s == even if I have a really small program -- how can I use 8s or 168s -- or is
that possible?
Thanks so much again.
Clair
The day after that post I found on the arduino site a pin diagram of the chip. But a pin diagram that tied the
chip pins to the the pin numbers on the Uno board. When I saw that I realized that I could do that.
Now -- Stephanie -- a follow on question ===
Do I always have to use 328s == even if I have a really small program -- how can I use 8s or 168s -- or is
that possible?
Thanks so much again.
Clair
-
- Posts: 295
- Joined: Sat Dec 11, 2010 1:17 am
Re: Putting an Arduino sketch on an ATmego328
Hello Clair,
I'll say, definitely probably... there are some issues you would have to address. First, in order to use those other chips in the Arduino in lieu of the 328, you would have to burn a bootloader onto them. I don't know about the 8s but the 168 definitely will work (there are options in the IDE for that chip).
Another potential issue is that the other chips have differences greater than just their flash & ram sizes. I know they have differences in the PWM pins and interrupts. There could be other differences I am unaware of.
Ultimately, my suggestion -- if you are sticking within the Arduino IDE -- is that unless you have a stock of the other chips already on-hand, you're probably better off to stick with the 328 even if it is overkill for a particular application. The other chips might be a few cents cheaper, but there would be less hassle to stick with the 328 chip.
I'll say, definitely probably... there are some issues you would have to address. First, in order to use those other chips in the Arduino in lieu of the 328, you would have to burn a bootloader onto them. I don't know about the 8s but the 168 definitely will work (there are options in the IDE for that chip).
Another potential issue is that the other chips have differences greater than just their flash & ram sizes. I know they have differences in the PWM pins and interrupts. There could be other differences I am unaware of.
Ultimately, my suggestion -- if you are sticking within the Arduino IDE -- is that unless you have a stock of the other chips already on-hand, you're probably better off to stick with the 328 even if it is overkill for a particular application. The other chips might be a few cents cheaper, but there would be less hassle to stick with the 328 chip.
- clair
- Posts: 25
- Joined: Sun Nov 27, 2011 5:04 pm
Re: Putting an Arduino sketch on an ATmego328
Thanks again !
I have 4 of the 168s - and one 328 (came with the AVR-ISP programmer kit.
In the context of our conversation here, what does the AVR-ISP kit make possible
that I cannot do by lifting out my project 328 from the Uno board and wiring it
up on a protoboard?
In other words, what else can it be used for?
I very much appreciate your patience.
I have 4 of the 168s - and one 328 (came with the AVR-ISP programmer kit.
In the context of our conversation here, what does the AVR-ISP kit make possible
that I cannot do by lifting out my project 328 from the Uno board and wiring it
up on a protoboard?
In other words, what else can it be used for?
I very much appreciate your patience.
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: Putting an Arduino sketch on an ATmego328
the AVR-ISP kit is much faster - ideal for workshops or when you need to make 10 chips
-
- Posts: 15
- Joined: Mon Dec 12, 2011 6:36 pm
Re: Putting an Arduino sketch on an ATmego328
Perhaps I am misunderstanding it, but if you upload a sketch to the Atmega328 in the UNO and then remove it to put in another board, isn't the sketch gone then (coz of the powerloss)? Or do I unederestimate the powers of the Arduino?Stephanie wrote:Hello Clair,
Perhaps the easiest way you can do this -- if your Uno is the kind with the 28pin DIP chip on it -- is to simply remove the ATMega328 chip from your Uno once the sketch is on there and working the way you like.
You can get a new ATMega328 from Adafruit that has the bootloader on it, and pop that into your Uno to continue using it for development.
Cheers!
-
- Posts: 15
- Joined: Mon Dec 12, 2011 6:36 pm
Re: Putting an Arduino sketch on an ATmego328
Hmm, I tried this. The uploaded sketch indeed resumes after a power interruption. I never realised that (have my arduino for about a week). This solves a lot of problems for me. Definitely an eye opener.ed1960 wrote:
Perhaps I am misunderstanding it, but if you upload a sketch to the Atmega328 in the UNO and then remove it to put in another board, isn't the sketch gone then (coz of the powerloss)? Or do I unederestimate the powers of the Arduino?
Thanks
- clair
- Posts: 25
- Joined: Sun Nov 27, 2011 5:04 pm
Re: Putting an Arduino sketch on an ATmego328
Wow, I actually knew something -- but only by accident ed! When I leave my worktable, I always unplugged the USB to the Uno. When I would come back and plug it in, the LCD would light up with the same message, so I knew it kept it's memory.
BUT, my follow-on question from Stephanie's reply and the one from adafruit, is . . .
I want to use my 168s. Then I will go on using 328s.
What's the best way to get the bootloader onto the 168 chips?
(And I have researched enough to know they will work just fine for the projects I'm working on now.)
Thanks, again. I'm getting there, I really, really am!
BUT, my follow-on question from Stephanie's reply and the one from adafruit, is . . .
I want to use my 168s. Then I will go on using 328s.
What's the best way to get the bootloader onto the 168 chips?
(And I have researched enough to know they will work just fine for the projects I'm working on now.)
Thanks, again. I'm getting there, I really, really am!
Please be positive and constructive with your questions and comments.