How to choose the chip I need?

Hi,

I'm new to the whole arduino scene, and electronics in general and could use some advice please. I've got a couple of simple-ish projects that I would like to switch from the arduino to a more permanent and smaller micro-controller (atmel preferably) but I don't know how to pick which ones are suitable, or overkill etc.

As an example I've got an obstacle avoiding robot that uses 6 digital pins (5 output, 1 input) and 1 analogue pin, the sketch size is 6.5k. Does that mean I need a chip with a flash memory of 6.5k or less? How do I know the breakdown of a chips pins? ie: How many are digital, how many are analogue, and how many PWM? Could somebody recommend me a suitable chip for this robot and explain its attributes please?

e2a: I plan to only use chips I can program with the arduino and then transport into my projects

Many thanks

dave84:
Hi,

I'm new to the whole arduino scene, and electronics in general and could use some advice please. I've got a couple of simple-ish projects that I would like to switch from the arduino to a more permanent and smaller micro-controller (atmel preferably) but I don't know how to pick which ones are suitable, or overkill etc.

You don't say which Arduino you are currently using, but the ATmega328P as used in the Uno etc. has a lot to recommend it. It costs a bit more than some of the ATtinys but this hardly makes a difference unless dozens are involved. When you say "smaller", do you mean the physical size of the chip itself, or the entire board?

As an example I've got an obstacle avoiding robot that uses 6 digital pins (5 output, 1 input) and 1 analogue pin, the sketch size is 6.5k. Does that mean I need a chip with a flash memory of 6.5k or less?

A chip with more than 6.5K would be needed. An ATtiny84 might work, with 8K of flash, but not much room for growth. An ATtiny85 doesn't have enough pins for your requirements. If it were me, the question I'd be asking is what reasons would I have not to use an ATmega328P?

How do I know the breakdown of a chips pins? ie: How many are digital, how many are analogue, and how many PWM? Could somebody recommend me a suitable chip for this robot and explain its attributes please?

By reading the datasheet. Attributes are summarized on the first page.
ATmega328P et al
ATtiny84 et al
ATtiny85 et al

..the sketch size is 6.5k. Does that mean I need a chip with a flash memory of 6.5k or less?

You mean the size of sketch source (the text you see in the IDE), or the compiled binary size?
From the source size you cannot judge on the flash memory required, as a 6.5k source code may create binary of any size..

Thanks for the reply, I'm using the Uno, and I meant that the uno board is basically bulky and has a lot of features that the robot doesn't need so I wanted something physically smaller and near enough only has the capacity for its intended use.

I may well end up doing the ATMega328p route, but its also a large chip and I assumed it was overkill? They are very reasonably priced though so it will probably save all the agro. I also meant more flash than 6.5k not less, my bad.

By reading the datasheet. Attributes are summarized on the first page.
ATmega328P et al
ATtiny84 et al
ATtiny85 et al

Ah, thats much better thanks, I was looking at some comparison table on atmels website that didn't list everything I needed to know

pito:

..the sketch size is 6.5k. Does that mean I need a chip with a flash memory of 6.5k or less?

You mean the size of sketch source (the text you see in the IDE), or the compiled binary size?
From the source size you cannot judge on the flash memory required, as a 6.5k source code may create binary of any size..

I assumed it was compiled size as when you upload or verify code in the IDE the console window says at the end how large the code is out of a maximum of 32k (the UNO's flash size).

dave84:
I may well end up doing the ATMega328p route, but its also a large chip and I assumed it was overkill?

If you really want to make a physically small unit, then you will need to design a PCB using SMD components. In that case, you can use the atmega328p-au surface mount version of the chip, which is smaller than the -pu DIP version.

dave84:
Thanks for the reply, I'm using the Uno, and I meant that the uno board is basically bulky and has a lot of features that the robot doesn't need so I wanted something physically smaller and near enough only has the capacity for its intended use.

I may well end up doing the ATMega328p route, but its also a large chip and I assumed it was overkill? They are very reasonably priced though so it will probably save all the agro. I also meant more flash than 6.5k not less, my bad.

Oh come on now! Have you not done the basic searching?

It sounds as if you want a "Pro Mini" which is an implementation using the same Mega328 SMD chip but without the USB interface of which there are several versions available which you connect only when you need to program it.

It's not worth the bother to design or assemble your own version (at least in your case, for a "one-off").

Paul__B:
It's not worth the bother to design or assemble your own version (at least in your case, for a "one-off").

That depends on whether he needs a PCB to hold whatever other components he will be using.

the ATmega328P as used in the Uno etc. has a lot to recommend it.

The 328p is also enjoying (at least at the moment) a "cost blip" - it's cheaper (in small quantities, from the usual distributors) than processors with less memory.

This page may be useful, too.

This is essentially an UNO (same chip, pins, flash, etc..)...but about the size of a postage stamp. And costs only $10.

1ChicagoDave:
This is essentially a UNO (same chip, pins, flash, etc..)...but about the size of a postage stamp. And costs only $10.
https://www.sparkfun.com/products/11113

That would of course be the "Pro Mini" which I cited earlier.

dc42:
That depends on whether he needs a PCB to hold whatever other components he will be using.

Well, he is presently using a Uno and simply wishes to make it more compact. There would be few other PCB mounted components that would be required.

+1 to Pro mini. It'll easily fit on a strip board, allowing other components to be soldered in and wired up also.

Thanks everyone, I had no idea on the Pro-Mini. Whilst its not exactly what I’m looking for it is a good alternative and it’ll come in handy for something. The chap who mentioned PCB’s and other components had the right idea. As I want something more permanent I’ll either have a PCB or protoboard connecting the brain to the various components and devices and I’d planned to just solder a holder onto the board to be able to easily remove the chip for programming adjustments or if I wanted to use it in another semi-prototype for a brief time. In-Out, nice and compact, and basically cheap easily replaceable should it get damaged.

Plenty of options now though, thanks folks

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

dave84:
As I want something more permanent I'll either have a PCB or protoboard connecting the brain to the various components and devices and I'd planned to just solder a holder onto the board to be able to easily remove the chip for programming adjustments

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

dc42:
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:

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

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.

dc42:
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?

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.

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!

dc42:

  • 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 :slight_smile:

Cheers!