Arduino UNO talking to a attiny44 via RS-485

Hi folks,

Sorry if this question has already been asked (I haven't found the answer on the forum).

I did some small tests with the arduino and some teensy boards and now, I want to go a bit bigger.

On this new project that i'm working on, I need to make a arduino UNO and a attiny44 talk to each other using a RS485 converter (2 wires serial transceiver). The arduino side is OK because I can use the RX and TX pins to connect the RS485 chip. My trouble is on the attiny side. there are no such pins. I've seen on the forum "TinyISP" but my understanding is that its only to connect a serial motor (so only TX from the attiny). I need both RX and TX from the chip.

Anyone has some pointers on how I can achieve TX and RX communication ?

if anyone needs details, just ask. :wink:

Jeff.

December 12, 2010 ... been a while since you were last on the forum. Welcome back.

Tiny Tuner if you're using the internal oscillator. SoftwareSerial (the newer version) for serial communications. Communications will be half-duplex. Run the ATtiny44 (t44) at 8 MHz (or higher if you're using a crystal or resonator). Pay close attention to the buffer size of SoftwareSerial; you may need to reduce it for the t44.

SoftwareSerial will also work on the Uno allowing you to use the USART for other things (like debugging).

I highly recommend including a CRC with your data.

TinyISP is a drop-in replacement for the ArduinoISP sketch that includes some goodies for development. It may help with troubleshooting the RS485 communications but will not help with the actual communications.

Why does it have to be RS232?

If you've got two lines then a simple data/clock interface will be far more likely to work (plus both the Uno and the Tiny84 have hardware support for it).

Thanks its been a while since my last visit XD

I can't use a crystal in this setup beacause i've used up all of the pins already so I have to use the internal one.
My communication (in theory for now) is : the UNO always initiate the communication. there will be no init from the attiny44.
Do I need to use "tiny tuner" AND SoftSerial or I can just use the later ?
Could I use the internal up to 8Mhz ?

For now, I could use the hardware USART for the RS485 chip be SoftwareSerial will be handy to setup a debug console :slight_smile:

Could you explain a bit more on this part, i'm not sure how this could be done :blush:

Great, I'll keep that in mind XD

fungus:
Why does it have to be RS232?

If you've got two lines then a simple data/clock interface will be far more likely to work (plus both the Uno and the Tiny84 have hardware support for it).

The reason is that the final project will go into my woodshop and there will be some big motors in there. 1HP - 2HP+ So those motors could introduce some noise on the lines.
The other reason is that, the attiny portion will be (the maximum length for now) about 20 feets (~7 meters) from the controller (UNO). At first, I though of using simple I2C communication but the distance and reason #1 made me change my mind.

That is why RS485 (in my opinion, feel free to give another one, i'm open to suggestions) in this case is better, the way that the transport layer is made is not affected as much from EMF XD

Rigor_M:

fungus:
Why does it have to be RS232?

That is why RS485 (in my opinion, feel free to give another one, i'm open to suggestions) in this case is better, the way that the transport layer is made is not affected as much from EMF XD

I get why it's RS485 ... I was asking why you need RS232 :slight_smile:

You mean, I dont have to use RS232 with RS485 ?

I assumed that was the case because that is what i was seeing on other people's project.

could I use data/clock with the RS485 and if true, is it that hard to add to my project ?

thanks XD

That depends on your RS485 converter…and my crystal ball is in for its yearly service this week.

What do you mean, I lost you there ?!

Rigor_M:
What do you mean, I lost you there ?!

I can't see what hardware you have from over here.

oh heheheh, that makes sense XD

I havent tested everything yet, i'm still brewing this in my head and a bit on the breadboard.

the RS485 are SIPEX Half Duples RS485 5Mbps Transceiver chips datasheet:[http://www.exar.com/Common/Content/Document.ashx?id=643&LanguageId=1033]

on both ends with a simple ATMEGA368 with optiboot bootloader couple with a crystal and some capacitors (I dont have a Arduino board) and I use a teeny programmed with UsbSerial so I can program the atmega (that part works great).

Maybe I could pass a I2C signal with those transceivers ?

Rigor_M:
Maybe I could pass a I2C signal with those transceivers ?

Don’t know but I do know there are I2C line drivers available that would probably work.

But I really don’t see a problem with using RS-485.

Rigor_M:
My communication (in theory for now) is : the UNO always initiate the communication. there will be no init from the attiny44.

Excellent. One problem solved.

Do I need to use “tiny tuner” AND SoftSerial or I can just use the later ?

Tiny Tuner is just used during development to more accurately tune the internal oscillator. It really is a necessary step for RS-XXX communications.

Could I use the internal up to 8Mhz ?

Yes. Up to and including 8 MHz.

[quote author=Coding Badly link=topic=155916.msg1168677#msg1168677 date=1364022230]I highly recommend including a CRC with your data.

Could you explain a bit more on this part, i’m not sure how this could be done :blush:[/quote]

CRC is a mathematical operation and a value that identifies all one-bit errors (plus a long list of other types of errors). You feed the transmitted data into an algorithm. You get out a value; typically 32, 16, or 8 bit. I suggest using a 16 bit CRC. That value is also sent. The receiver essentially does the same thing. If the CRC values match, the odds are very high the data was successfully transmitted. If the values do not match, the data was corrupted during transmission.

I dont have to use RS232 with RS485 ?

Not only don't have to but can't, they are totally incompatible.

I think you are confusing RS-232 (an electrical standard) with serial communications using a UART (or bit banging or whatever).


Rob

It could be the case. Then, i mean serial communication over rs485.

YOu have any recomendations ?

You haven't really described what you're communicating. If you're just sending small messages every few seconds or so then the path you're on (RS-485 serial communication) is fine.

Might want to poke over and look at the EasyTransfer library. It is ATTiny compatible (or generally doesn't care what the hardware is) but the 4K of space on your ATTiny44 will make things extremely tight; a basic sketch is 3.7K. You might need to jump to an ATTiny84.

Thank you everybody.

I think that I have a good base on to start with. :slight_smile: