Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Troubleshooting modbus communication (YSI optical dissolved oxygen sensor)


Rasmus Ringgaard Jun 3, 2024 01:30 PM

Does anyone have experience with YSI modbus sensors and CR350 dataloggers? (or any other RS485 capable Campbell logger). Do you have any code examples and wiring diagrams to share?

So far I can't get communications to work at all. When using the ModbusClient() function no data is returned and ResultCode is ncremented by 1. This indicates a communication failure (no response).

Wiring

According to the YSI manual wiring is as follows:

Red: Power
Green: Ground
White: Modbus A
Black: Modbus B

I've connected the sensor to Com2 usinge this wiring:

Red: SW1
Green: G
White: Com2 TX
Black: Com2 RX

Any obvious errors in wiring? (I have made sure to turn on SW1 on program start)

Code

The sensor is fresh from the factory and should have default settings for adress and serial communication. According the YSI manual default serial configuration is:

ODO RTU operates over RS485. The serial configuration can be modified, including the baud rate, parity, and Modbus slave address. By default, the baud rate is 9600, slave address is 0x01, and parity is even. As per the Modbus serial specification, there is one stop bit when parity is set, and two stop bits when there is no parity. All values are big-endian byte ordered.


To network multiple ODO RTU probes on the same network, each probe needs a unique Modbus address. The factory-default Modbus address for all ODO RTUs is: 0x01.

I read that as: 9600 baud, even parity, one stop bit, 8 data bits (Format 2). Modbus adress 1.

I use the following code to read the sensor:

SerialOpen(Com2,9600,2,100,100,4)

ModbusClient(Ilstonde_ModBus_Status,Com2,9600,1,04,Iltsonde(),0,4,3,10,2)

No data is returned to results array Iltsonde() and Iltsonde_ModBus_Status is incremented by one each time the program calls the ModbusClient function.

Anything obviously wrong with the code? Is serial configuration OK?

I would appreciate any feedback or suggestions for troubleshooting steps to try :)

Log in or register to post/reply in the forum.