Go Down

Topic: How to choose the chip I need? (Read 11496 times) previous topic - next topic

dave84


A much better way is to include a 6-pin ICSP header on your PCB, then you can (re)program the chip in-situ.


Thats an excellent suggestion, thanks.

I also thought it useful for anybody else with my dilemma to look at this:

http://www.instructables.com/id/Standalone-Atmega328-for/

It details what I need to do to upload a sketech onto a atmega328, basically the barebones uno  but obviously if physical space is an issue you aren't stuck with someone else's board

dc42

Some comments on that instructable:

- if you are going to program via ICSP, then you can get the atmega328p without the bootloader installed and save a small amount of money;

- if in addition you do not need accurate timing and are happy to run the chip at 8MHz (or even lower), then you don't need the resonator, because you can use the built-in oscillator.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

dave84


if in addition you do not need accurate timing and are happy to run the chip at 8MHz (or even lower), then you don't need the resonator, because you can use the built-in oscillator.


I had read this, though I don't really know what it means.  Can you explain the relationship between the crystal, oscillator, and timing please? Why is 8Mhz not accurate but 16Mhz is accurate timing?

dc42

#18
Sep 16, 2013, 05:29 pm Last Edit: Sep 16, 2013, 05:33 pm by dc42 Reason: 1

I had read this, though I don't really know what it means.  Can you explain the relationship between the crystal, oscillator, and timing please? Why is 8Mhz not accurate but 16Mhz is accurate timing?


The atmega328p requires a clock. This is a timing signal that controls the internal workings of the device and how fast things happen. The maximum supported by the atmega328p is 20MHz using a 5V supply.

To generate the clock, you have three options:

1. Use an oscillator built-in to the chip. Its frequency is nominally 8MHz, with an accuracy of +/-10%. A blank atmega328p will have the fuses set to divide this by 8 (so you get a 1MHz clock), but you can reprogram the fuse to get the full 8MHz. There is a calibration mechanism you can use to improve the accuracy at a particular supply voltage.

2. Connect a crystal or ceramic resonator to the chip. This uses up 2 pins, which are no longer available as inputs or outputs. This is the standard configuration of an Arduino. The clock accuracy is around +/- 0.5% if you use a ceramic resonator, and 0.05% if you use a crystal.

3. Supply a clock signal yourself, for example from a temperature-controlled oscillator if you need very precise timing, or from some oscillator that you need for other reasons. This uses up 1 pin.

So if timing accuracy of 10% is good enough for your application and you don't need to do serial comms (which require better accuracy than that), and 8MHz is fast enough, then you can use the internal oscillator. Otherwise, if 0.5% is accurate enough, then a 3-terminal ceramic resonator is simple and cheap. Otherwise, use a crystal and 2 capacitors.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

DroidDr

The pro-mini is very small. I have 2.
When I first saw the 'box' it was sooo small, I thought it was a mistake!


- if you are going to program via ICSP, then you can get the atmega328p without the bootloader installed and save a small amount of money;


If you want to make your own board, I have recently made a board to program/bootload blank 328P chips, and that sort of board can serve for small projects as well. I have an oscillator & caps, power button, reset, power led, led for a blink style program, wallwart cylindrical plug, voltage regulator. I intend to add headers, but that is optional for me.
I made the board with a 5cmx7cm perfboard and it can be optimized smaller too. If you don't need the regulator, it can be even smaller.
I have bought some blank chips and successfuly programmed them using an USBASP ( can use Atmel's programmer as well I suppose)

I have a hand-written schematic if you want it, and can send pics of the board too if desired.
Keep in mind I am a bit of a newbie still :)

Cheers!

dave84



I had read this, though I don't really know what it means.  Can you explain the relationship between the crystal, oscillator, and timing please? Why is 8Mhz not accurate but 16Mhz is accurate timing?


The atmega328p requires a clock. This is a timing signal that controls the internal workings of the device and how fast things happen. The maximum supported by the atmega328p is 20MHz using a 5V supply.

To generate the clock, you have three options:

1. Use an oscillator built-in to the chip. Its frequency is nominally 8MHz, with an accuracy of +/-10%. A blank atmega328p will have the fuses set to divide this by 8 (so you get a 1MHz clock), but you can reprogram the fuse to get the full 8MHz. There is a calibration mechanism you can use to improve the accuracy at a particular supply voltage.

2. Connect a crystal or ceramic resonator to the chip. This uses up 2 pins, which are no longer available as inputs or outputs. This is the standard configuration of an Arduino. The clock accuracy is around +/- 0.5% if you use a ceramic resonator, and 0.05% if you use a crystal.

3. Supply a clock signal yourself, for example from a temperature-controlled oscillator if you need very precise timing, or from some oscillator that you need for other reasons. This uses up 1 pin.

So if timing accuracy of 10% is good enough for your application and you don't need to do serial comms (which require better accuracy than that), and 8MHz is fast enough, then you can use the internal oscillator. Otherwise, if 0.5% is accurate enough, then a 3-terminal ceramic resonator is simple and cheap. Otherwise, use a crystal and 2 capacitors.


Excellent thank you, I have no reason to believe that the oscillator wouldn't be fast enough, and 10% accuracy is good enough for my needs. Thanks again you've been a great help

DroidDr - I'd decided that's exactly what I'd be doing, turns out a lot of the stuff comes in a package from ebay, but per advice from dc42 I'll probably skip the crystal and use the lilypad bootloader as its 8Mhz, or I could build switched/logic gate based programming board to load either the lilypad or uno bootloader with crystal or without using transistors.  That way I can have the best of both worlds (See, this is what I like about electronics, the possibilities are endless :))

Then as suggested, I'll add a header to my projects boards so I can program in situ using USB TTL without having to risk damaging the chips constantly pulling them out of the socket for minor changes.

Sounds like a plan :)

DroidDr

Just making sure:

Are you aware of the difference between programming the chips through the ICSP header vs usb TTL?

Paul__B


Just making sure:
Are you aware of the difference between programming the chips through the ICSP header vs USB TTL?


Specifically that you cannot program using the USB (or any other serial) TTL adaptor unless you are clocking the chip with a resonator or crystal.

To program without the resonator or crystal, you need an ISP (which can include an Arduino running an ISP sketch) and you need an ISP to program the chip in order to select whether you are using a resonator/ crystal or not.

DroidDr

I am confused.

I thought you needed a bootloader to 'listen' to the tx and rx ports of the uC (USB to TTL) to receive the program and write it itself in its flash, and this did not depend on external or internal resonator. As long as the bootloader of the chip is 'listening', it does not matter? Am I missing something?



aarondc


I am confused.

I thought you needed a bootloader to 'listen' to the tx and rx ports of the uC (USB to TTL) to receive the program and write it itself in its flash, and this did not depend on external or internal resonator. As long as the bootloader of the chip is 'listening', it does not matter? Am I missing something?


My understanding, having gotten 1/4 the way through the digital design book is as follows:

Clock signals drive all digital processes. Without a clock signal, the processor does not know when the value is "ready" to be written, nor could it "understand" the signals being received as data. The bootloader itself won't even run without a clock signal.

The resonator / crystal supplies the clock signal source.

joshuabardwell


The pro-mini fits into a 24-pin wide (0.6") socket :D


Does this hold true if you are using the analog pins with the unusual "interior" locations? I've always wondered how one would use those pins if one was mounting the Pro Mini in a female header, vs. soldering direct to the Mini's PCB.

DroidDr


My understanding, having gotten 1/4 the way through the digital design book is as follows:

Clock signals drive all digital processes. Without a clock signal, the processor does not know when the value is "ready" to be written, nor could it "understand" the signals being received as data. The bootloader itself won't even run without a clock signal.

The resonator / crystal supplies the clock signal source.


I understand that part, but the quote below from Paul___B seems to indicate that you need an external resonator or crystal (is external implied here?) for the 328P to operate and use TTL serial, but the 328p comes with an internal resonator if you chose to use it (by setting the fuses appropriately I understand).... My question is really: can the chip run and read TTL by using the internal resonator?


Specifically that you cannot program using the USB (or any other serial) TTL adaptor unless you are clocking the chip with a resonator or crystal.
To program without the resonator or crystal, you need an ISP (which can include an Arduino running an ISP sketch) and you need an ISP to program the chip in order to select whether you are using a resonator/ crystal or not.


aarondc



The pro-mini fits into a 24-pin wide (0.6") socket :D


Does this hold true if you are using the analog pins with the unusual "interior" locations? I've always wondered how one would use those pins if one was mounting the Pro Mini in a female header, vs. soldering direct to the Mini's PCB.


i soldered the interior analog header pins on top, so yes, still fits in the header. clearly will have to use a cable to get them back to pcb level.

dc42


I understand that part, but the quote below from Paul___B seems to indicate that you need an external resonator or crystal (is external implied here?) for the 328P to operate and use TTL serial, but the 328p comes with an internal resonator if you chose to use it (by setting the fuses appropriately I understand).... My question is really: can the chip run and read TTL by using the internal resonator?


The chip cannot reliably do serial communications using the internal resonator. Serial comms requires that the clocks at either end of the comms link are accurate to within about 4% of each other. Therefore, if the clock of the external device (e.g. the FTDI cable you are using to connect the microcontroller to USB) is accurate, then the 328P clock needs to be accurate to within 4%. This is not guaranteed when using the internal oscillator, which is guaranteed to be within 10% at one particular supply voltage (I forget which voltage). Therefore, programming via serial comms and a bootloader is not recommended when using the internal oscillator.

However, when building a standalone device, programming is usually done via ICSP instead of via a bootloader (whether or not the internal clock is used). The clock timing is not critical when programming via ICSP.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

dave84



The chip cannot reliably do serial communications using the internal resonator. Serial comms requires that the clocks at either end of the comms link are accurate to within about 4% of each other. Therefore, if the clock of the external device (e.g. the FTDI cable you are using to connect the microcontroller to USB) is accurate, then the 328P clock needs to be accurate to within 4%. This is not guaranteed when using the internal oscillator, which is guaranteed to be within 10% at one particular supply voltage (I forget which voltage). Therefore, programming via serial comms and a bootloader is not recommended when using the internal oscillator.

However, when building a standalone device, programming is usually done via ICSP instead of via a bootloader (whether or not the internal clock is used). The clock timing is not critical when programming via ICSP.


Ah, I'd done some research on usb-serial connection and it hadn't been mentioned accuracy issues.  ICSP it will be then.  All the ICSP examples I have seen only upload a bootloader though, do you have a link to, or can you explain how a sketch is run without a bootloader?

Go Up