Early stage RS 485 with MAX485

Hi,

This is my tenative first step trying to recieve data from a sensor via RS485. So far I have wired my MAX485 up as per the attached diagram. So I have a couple of questions before I plug IN :slight_smile: Does this wiring look right? And would anyone be able to help me with some simple code to receive the data and print to serial so as to make sure its working - hopefully I can work out what to do after that?

I have a blog entry with how I wired up my RS485 PC interface.

You need to be able to control when you can TALK and Receive on the BUS. I much prefer Jan Axelson timer approach, which I used in my design.

The chip I used has the same pin out and roughly the same characteristics of the original MAXIM chip. You would just remove the MAX232 for interfacing with the Arduino... but without it... you need to remember that the MAX232 was "inverting" the TX/RX signals too.

There are only minor differences between the SN75176 and the MAX485

http://pwillard.com/?p=60

Does this wiring look right?

On the Arduino side of the wiring you show the Arduino pin 0 (rx) wired to ground, grounding out the signal. That can't possibly be correct?

Lefty

From what i gather you only want one-way communication by only receiving data.

Pin 1 (RO) should go to RX on the arduino
Pin 2 (RE) should go to ground on arduino this will enable Receiver mode

Pin 5 - Ground
Pin 8 - Vcc (5v from arduino)

Pin 6 (A) to A on other end
Pin 7 (B) to B on other end

A 150ohm resistor should be added between A&B at the start and end of the signal lines.

So looking at your diagram, theres no need for pins 3 and 4 to be connected, Rx should not be grounded, no need for a 100ohm resistor on ground pin and Tx does not need to be connect either if your just receiving.


If you want two way coms you will have to put pin 2 & 3 on the MAX485 to a digital pin and set it LOW for RX or HIGH for TX, since DE has a NOT gate.

Hope that helps.

The wiring has been corrected. I'm curious what protocol is the sensor using?

RS485 does only specify the "electric" layer. The definition of the protocol is up to the implementor.

So you need to cunsult the documentation for the sensor to see how it is implemented. And hope they actualy share this info in the docs...

Hi All - thanks for all the responses, very much appreciated - and I see I did get it pretty badly wrong !!! I have now rewired the circuit as per your diagram Bored123 (thanks again) and include the info I have on the RS485 output for mrmeval and anyone else who is interested. In theory I should be able to read 3 values from the sensor CO, Temperature and RH.... lets see if I can make an equally bad job of the code!... at this stage I need to work out what comes after #include <SoftwareSerial.h> :slight_smile:

You will need two way communication then

Connect DE/RE to D3(or any other pin)

What you will need to do is

Set D3 to HIGH (this will enable DATA IN)

Send the request protocol

Set D3 to LOW (this will enable RECEIVE)

Then listen to the response

I'm not that great on the software stuff but I'm sure someone will be able to help.

EDIT: I have not tried it but just came across this Lib, might be of use.
http://www.arduino.cc/playground/Code/ModbusMaster

Hi, Sorry for the slow reply - I'm making some slow progress here :slight_smile: so thanks again for your help.

I have put the hardware to one side at the moment to try and get to grips with the sesnor output - so I have the sensor conneceted to USB on my PC and have recieved data as expected every 3 seconds via a program called DockLight (anyone know if there a free software to do the same?).

I have looked at the data as hex & ascii but it makes little sense to me - do you know how should I be interpreting Modbus output?

eg:

13/04/2010 19:22:24.246 [COM11]

DD FD 95 AD 91 26 92 65 FD B1 1A 44 4C 2C FD E9 26 22 AA A5 F6 39 1A 24 CA D2 55 A7 A4 D5 A7 FF 49 44 A5 D2 29 26 29 A6 65 AD 6B 24 A6 AB 4D 55 EA 16

This is what it looks like in ASCII:

Ýý?¬'&'eý±_DL,ýé&?QJö9_¤åÒU§¤Õ§ÿID¥Ò)&)¦e¬kd©µ©eÝÅ

claims to be "free"

Your SAMPLE frame does not start with a ":" or end with a so it's hard to say it's modbus.

If you have not settled on a protocol yet... SNAP might be a little more "lightweight". \

http://www.hth.com/snap/

Modbus is a proprietary standard so it's difficult to get info on.
Here are two links from the playground

http://www.arduino.cc/playground/Code/ModbusMaster

Without your providing the sensor model and a datasheet helping you more is futile.

that's not so true, i found it very easy to get information about it.

here's a very nice tutorial: http://www.lammertbies.nl/comm/info/modbus.html

Hi Folks,

Thanks for the replies - I think I have enough to work it out now.... I will post back with news of progress - fingers crossed :slight_smile:

Cheers