Atmega32 communicating using rs-485 modbus protocol

atmegamodbusrs485

I am trying to read values from a meter (WDM303FDWA1) through ATmega32. The communication to the meter has to be done by RS-485 modbus protocol. I would like to know what IC do I have to use to connect the Atmega32 and meter, sample codes for Modbus RS-485 protocol.
I am trying to communicate only with one meter and its Slave Id is 1, Baud rate could be anything (default is 9600)

Best Answer

The WDM303FDWA1 uses RS485 as the line interface connection and this means you need to interface the Atmega to an RS485 chip such as a MAX485. Here is a link to Maxim's offerings on that device and here's the chip: -

enter image description here

  • RO is received data out from the 485 and connects to your Atmega
  • RE (bar) is read enable driven from your Atmega - it defines data direction along with DE
  • DE - tie this to RE (above) and you have one pin that controls direction of data on the 485 line.
  • DI - this connects to the data output line designated for your Atmega.
  • A & B are the 485 line connections

If you look on page 8 of this document it details all the codes you need to send to talk to the device. It appears that you must send the "password" first followed by a function code, then the specific address of the data you want to read. The pdf file has that data.

As for the format of what comes back I can't help you with that - the document doesn't go into too much detail on this but, it does appear to be between 1 word and 3 words.

Neither can I help you with samples of modbus codes for use in the Atmega.