Electronic – arduino – Selecting the right microcontrollers for this project (Arduino based)

arduinoattinymicrocontroller

I'm thinking about buying some Arduino development kits to migrate from my actual development platform (picaxe) to Arduino. I want to buy just what I need to develop my next project, but taking in consideration that I am a total ignorant of the Arduino capabilities I have some issues trying to decide what to buy. So I decided to explain you what I want to do and what I think I need (in terms of hardware) hoping to have some feedbacks.

Ok the idea is simple, over the serial cable my computer (or USBtoserial) I will send some commands to my Arduino Uno board: these commands are composed of several bits (defined in my own protocol); anyway, after my Arduino has received this commands it will take some actions, at the moment the only action that matters is to send a word to other Arduinos connected to a communication bus (need to decide if I2C, serial or TTL). This word is composed of 1000 bits, the firsts 8 bits are just the header (containing the address of the chip that will receive the data) and rest is just data (the actual length of this word is always fixed to 1000 bits).

So in summary this is what I will do:
enter image description here

For example, from the PC, I send the command over the serial cable: 110110111010101010011…….01101.
This goes to the Arduino board who resend it to the communication bus where all the other micro controllers are always listening to the bus, they will read the first 8 bits and compares them to their own address: if it matches the micro controller address (stored in a variable), it will store the next bits on memory (if the power goes off I don’t need to save the informations, so it could be a volatile memory).

After that the micro will be waiting for a future command that will eventually tell him to output the data bits over an output pin. All the micro will only save one word of 1000 minus 8 bits at the time, so the memory is fixed for just 9992 bits.

I'm having problems to decide which small microcontroller to use, which communication protocol to use and some issues with the software. Taking is consideration that the distance between the first micro and the last one could be up to 7 meters I think that I2C is not the way to go, serial will be great but that means that I will need a serial to ttl converter on each micro (take in consideration that they could be up to 128 micros) so that can make the project to go out of my budget, TTL will be great but I never tried a communication via TLL over 7 meters, what do you think? I think a good cable will not drop so much voltage in 7 meters, also the speed I thinking to use is max 19200bits/s.

About the micros, my biggest concern is to choose the cheapest alternative because they will only receive data in one pin (serial data) saved in a volatile memory, and then output that data at a fixed rate over an output pin (to light up and off a led for example). I saw on internet that you could program the ATtiny with the arduino board, is this chip capable of doing what I need? Do I need an external memory to store the data? Or I can save it on a variable? (what memory you suggest?)

enter image description here

And my final question is about software, when I was using PicAxe, a very simple development kit for microcontrollers when I need to store a word over a serial input I just make this:

serin serpin,N2400,(27),seraddr, b4,b5 

Where serin is the command to begin the serial acquisition, serpin is the number of the input pin I want to use and b4 and b5 are four bits variables so using they two I have a 8 bits word. The PicAxe platform is fixed with 10 4 bits vars (b0,b1…….b9) so it will be imposible to store a 1000 bits word without passing the information to an external memory. With the Attiny I can store that amount of data on a program var? What is the maximum I can store? At the point do you still think the attiny is the way to go?

Thanks so much for any feedback and suggestion!

Best Answer

Most small microcontrollers will be capable of doing what you need. You could even ditch the Arduino "wrapper" and use a USB capable micro in it's place.

Microchip, Atmel, TI, ST, etc all have 8, 16, 32-bit uCs of varying RAM/FLASH/EEPROM sizes to pick from. All the modern uCs come with at least UART, SPI, I2C peripherals that can be used for your communications.
There is not a lot in them really, I'd just pick one and see how you like it.
I (currently) use ST's 32-bit ARMs and Microchip 8, 16 ,32-bit PICs.
I'd probably use a few PIC12F or 16Fs for the slave uCs and a PIC18F or PIC24F for the master.

You mention needing ~10kbits of memory (not quite clear what type or which uC needs it from your description to me though)
It's easy to determine what is suitable though, just check the RAM/ROM/EEPROM specs of each uC you look at.
For example the PIC16F1938 has:

 Parameter Name          Value
 Program Memory Type     Flash
 Program Memory (KB)     28
 CPU Speed (MIPS)        8
 RAM Bytes               1,024
 Data EEPROM (bytes)     256 

So 28KB of program memory is more than enough to store non-volatile data if your program is small enough (on the newer PICs you can also read/write to program memory at run time) 10kbits will not quite fit into the RAM though, at 1024 * 8 = 8192 bits.
The 16F1527 has 1536 bytes of RAM though, so you could use this if necessary.

For the master (alternatives to Arduino) there is something like the 18F25J50 or similar, which has a USB 2.0 peripheral. Microchip provide a USB stack an plenty of example firmware to get you started with USB.
If you need something more powerful for the master, have a look at the PIC24 series with up to 256K of Flash and 96K of RAM. Or even the PIC32 which is 32-bit and up to 80MIPS. The PICKit3 is a low price programmer that will program all the above mentioned PICs, and MPLAB (or MPLABX) is a free IDE for firmware development.

Communication can be done with I2C, which deals with the master/slave configuration and addressing easily. All you have to worry about is sending the data. 7 meters should be no problem with a reasonably quiet environment and the right setup (low value pullups - say 2.2k, low capacitance cable)

Related Topic