Modbus via microcontroller

E

Thread Starter

Ed

Hello all.

Firstly, apologies if I've not followed the correct posting etiquette by creating this thread.

I'll explain my setup. I need to communicate with a device (turbine) which follows Modbus RTU protocol. I need to extract one piece of data from the turbine and log it over time.

I am hoping to use a microcontroller (arduino etc.) to communicate via RS232 serial with the turbine to extract the data I want.

First of all, my understanding of Modbus is very new and likely very limited. As far as I can see, I am required to send my request to the turbine from the microcontroller over serial in 8N2 format (6 data bytes + 2 CRC16 bytes) and it should reply with the corresponding data.

I wrote code onto my microcontroller that performs said operation but when I've connected it to the turbine no serial communication eventuates.

I suppose my question is, have a underestimated the complexity of Modbus protocol and does anyone here have an idea where my knowledge of it is lacking?
 
If it were me, I'd connect a PC with a serial port running a generic Windows Modbus 'test' master, like Modscan32 or SimplyModbus, and confirm that the slave device, the turbine, does indeed, speak Modbus and under what settings/connections it does so. Sometimes electrical connectors have nothing substantive behind them, or the protocol that the connector talks isn't Modbus.

Although the Modbus spec calls for 2 stop bits with no parity, there are otherwise fully functional Modbus RTU devices that can not do 2 stop bits. So yours would not be the first to only handle 8-N-1.

So you don't know whether your problem is on the slave end, master end or in-between.

Your problem could be a lot of things- cable/wiring, baud rate, functionality of the port you plugged into, wrong slave ID, wrong function code, wrong syntax, the list goes on.

Divide and conquer. Make sure the slave isn't deaf and dumb with a cable and a master that is known to work.
 
L

Lynn August Linse

The "try a PC" option is always a wise first-step ... make sure you can trust your tools and cable.

The problem could be as simple as the turbine using 'DCE' naming, so MAYBE the pin/terminal it calls RX data is actually the TX/transmit pin! That is hard to troubleshoot if you don't fully trust your own code or PCB design.

So try the PC route - likely the maker documents how to do this in fine detail. Use a tool (modpoll, modscan, opc, etc) and if it works, you also can see the exact HEX bytes being sent. I do this all the time for cheap/dirty CRC calcs for anytime I want to treat the Modbus/RTU request as a pure constant repeated forever.
 
Top