Modbus help please

#1

Hi there, new to Node-red and have a project I have embarked on that I am running on an IOT2040 using Node-Red

I have a modbus sensor (eventually 6) that I can't get working. I have succeeded in using a modbus program and connecting it directly, using a gauge in node red to display the value. Problem comes when I attach the sensor and deploy the node. I have set all the settings I can think of related to the device I am using, including baud rate, added delays etc but nothing. I receive errors such as this

"FSM Reset On State ACTIVATED"

my sensors datasheet is as follows

Commands
The device supports the following commands:
 ReadHoldingRegister (0x03)
 ReadInputRegister (0x04)
 WriteSingleRegister (0x06)
 WriteMultipleRegisters (0x10)
 ReportSlaveID (0x11)
All other commands sent to the device will be answered with exception code 0x01.
Address configuration: address 1..247 via control device, broadcast requests are not decoded.

Attached screenshots.
Any help much appreciated!!!

#2

#3

Can you share the datasheet of the sensor you are using? The address 1000 appears to be a very high value. The sensor modbus address on the hardware would need to be set to 1

#4

I had a hard time to make node Red on a Pi talk to a PC running a MODBUS device emulator app. 90% of the problem was the RS-485 interconnection. The winning combination was, on PI and PC: USB to serial dongle connected to a DTECH RS232-to RS485 converter (bus powered). The two converters connect to each other using 1 twisted wire pair + one wire for Common voltage. AND I had to add a 120 OHM resistor on one end of the RS485 wire, even to operate at 9600 baud.

There are a few Modbus nodes to chose from repository. Only package I was able to use was "node-red-contrib-modbus". The modbus-read function works fine provided the address and data size returned by the modbus device matches what Modbus read is especting.

Dont use long connection delays or have a poll interval too short like you have now. use Poll interval of at least 5 seconds (5000 ms) and delay of 2 ms, max.

good luck!

#5

Siemens IOT2040 right?

Are you using one of the main serial ports? X30 and X31, with the DB9 connectors? Those are /dev/ttyXR0 and /dev/ttyXR1, not /dev/ttyS2.

Did you set up the port with the switchserialmode command?

#6

Wow, thanks for the help so far!

I've attached the datasheet of the device. Ideally I'm wanting to read 6 of these devices around 4 times a second. Hoping this is possible 8f the sensor can do it.

I have set up s2 as 19200 baud and also double checked it after reboot. I've not heard about them being designated at xr rather than s. I'll have to look into that. Currently away from the setup.

As for wiring, I'm concerned about the power supply. The data sheet states 12-24v but it's funny that no power supply is needed to read the sensor when connected to pc via USB-rs485 converter. My wiring of the sensor is the same as if I were to plug it into the 485 adapter. The sensor can run 2 protocols and modbus has to be flashed to it using a configuration tool. I've set the modbus address to 1.

Thanks people!

#7

@camo200sx I looked a little deeper, it seems that the very first versions were /dev/ttyXRn, but you are correct, these are now /dev/ttyS2 and 3.

I bought an IOT2040 when they first came out but quickly moved on once I found out how terribly slow the Intel Quark CPU is compared to comparable hardware with ARM chips. The Quark's segfault bug was a big dealbreaker too.