Small microcontroller with UART

Hello everybody.

My new project is about a network of PIRs.
I'm looking for a small/cheap micro able to manage a 9600 bps communication and to read/write two 5v signals
The idea is to make a half duplex communication bus with 10 to 50 pirs sensors like this: Recommendations For You - DealeXtreme
One master (arduino) ask each slave getting its status.
Communication will be trough rs485 signals (max485)
I prefer a micro with no resonator/external components needed.

What micro do I need?
Can be that micro programmed with arduino ide?

Thank you very much.

The Atmel ATTiny2313 springs to mind. It is supported by several third party arduino cores and has a Hardware UART module along with an 8MHz internal oscillator.

It is larger than the ATTiny84 or ATTiny85 in that it has 20 pins, but it does have a hardware UART which the others don't.

Datasheet: http://www.atmel.com/images/doc2543.pdf

You could use an ATTiny85, but you would be limited by the fact that it requires a software based UART. This isn't a major issue as you are using Half duplex. The Attiny85 is an 8pin uC so is very compact. There are 5 digital pins which should be enough (TX, RX, Direction, and your two 5v signals)
My attiny core does have a software serial port built in which runs on an interrupt so fairly well represents the hardware UART with the limitation that it is half duplex, but that shouldn't cause you an issue. The core can be found here: GitHub - TCWORLD/ATTinyCore: ATTiny Core for Arduino 1.0+

Nice.
Thanks.

ATTINY2313V-10PU or ATTINY2313-20PU ?

MOD:
ATtiny85 with softserial??? Nicer!
Does it need external resonator?

Whichever you can get cheaper.

The forums are full of people who can't get it working. No AVR chip requires an external resonator, though it can fix a lot of problems with things that need accurate timing, eg. softserial.

Have a look at the ATtiny1634, still 20 pins but I2C, TWO serial ports and a 12-channel ADC, I suspect that the 2313 won't be used much in future :slight_smile:

All it's missing I think is real SPI.


Rob

Will I need external timing with attiny85?
Will I need external timing with attiny1634?

Thanks

No.

No, but it will be easier with external timing.

To operate reliably, the transmitter and receiver need to be using the same bit period within +/- 2% (see http://pdfserv.maximintegrated.com/en/an/AN2141.pdf). Your master is an Arduino, so assuming it uses a ceramic resonator (e.g. Uno) then its clock frequency tolerance will be +/- 0.5%. This means that your ATtinys must have a clock frequency that is accurate to within +/- 1.5%.

The easiest way to achieve this is to use a 3-terminal ceramic resonator on each ATtiny. However, this uses up 2 pins.

The other way is to use the internal clock in the ATtinys, but calibrate it using the OSCCAL register. The clock accuracy of the ATtiny as-shipped is guaranteed to be no worse than 10% @ 3V. You will need to use a regulated supply to feed the ATtinys, because the clock frequency is voltage-dependent. Also, the temperature had better not fluctuate too much, because the clock frequency varies with temperature.

An alternative is to use a self-clocking protocol instead of standard async protocol. if each transmission starts with several alternating 0s and 1s then the receiver can measure the bit length with respect to its internal clock, removing the need for an accurate clock frequency.

dc42:

[quote author=Jose Francisco link=topic=164988.msg1231792#msg1231792 date=1367922198]
Will I need external timing with attiny85?
Will I need external timing with attiny1634?

No, but it will be easier with external timing.
[/quote]

Yes. If the whole point of doing this is to use serial ports then you should plan for an external crystal. Anything else will most likely lead to pain.