Go Down

Topic: Modbus 1/7/N/1 (Read 551 times) previous topic - next topic

Weller

Hi, i'm trying to communicate with a MODBUS slave device.  The data sheet shows the protocol to be:

  Modbus ASCII
  RS-485
  9600 bps baud rate
  1 start bit, 7 data bits, no parity, 2 stop bits
  LRC (Longitudinal Redundancy Check)

Presumably I will need a RS485 breakout to convert the Arduino's UART serial to RS-485?

What about the frame format?  I think the Arduino is set to 8N1, so I need to somehow change that to 1 start bit, 7N1.

How do I go about changing this?  Can it even be done?

Louis Davis

You can simulate 7N2 with 8N1 by always setting the most significant bit to 1 for each byte sent.

Weller

Thanks Louis, how do I set the MSB to 0?  Is that really all I need to do?

For 25 LEDs you only need 4 shift registers.

Nick Gammon

Where did 25 LEDs get mentioned? Or shift registers?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Graynomad

Quote
For 25 LEDs you only need 4 shift registers.

That was another thread :)

Quote
how do I set the MSB to 0?

He said "setting the most significant bit to 1" BTW.

For every byte you send OR it with 0x80. Eg

Code: [Select]
send_modbus_byte (my_byte | 0x80);

Quote
Is that really all I need to do?

Should be.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

zabaat

Did you find a library you liked for modbus communication yet?

Go Up