Raspberry PI connect to RS485

This is the python code that used to work for the controller: Code
I'm trying to adapt this code to nodered.
Any ideal?

@Bond This can be frustrating, just some comments
Does the python code still work? If it does (or even partially) this would give you some clues. I notice in the python code there is a setting for connection to an MQTT broker, if this code works you could setup a broker in Node Red and communicate through MQTT using the working python code.
The python code uses the minimalmodbus python library and only sets the baud rate so the remaining serial settings should be default based on the minimalmodbus docs which is 8N1 so in the modbus config you should try serial expert and set the config to 8 data bits none parity and 1 stop bit.
I used a modbus scanner to initially get the communications working and then scanned the likely registers to read some parameters. This enabled me to fault find towards a solution. The scanner is here

1 Like

@mtoko thank you for your comments
I have checked out the Modbus scanner. Unfortunately, it cannot be installed on Raspberry PI (or just because i don't know how to).
The python code should be working. However the project requirement stated that we do not need to use MQTT, and need to adapt everything from that python code to a browser-based editor, which is Nodered.

I have a lot of experience with using the FTDI rs485 cables to talk to yaskawa ac drives. I like the node-red-contrib-modbus package myself. It's very simple and has a lot of tweakables.

In your case, it looks like you should have everything you need in your python file to make this work. The biggest thing that messes people up with serial connections is the wiring. Does this controller have separate rs232 and rs485 ports? Most don't. On yaskawa drives, one must jumper the S+ to R+ and S- to R- for rs485, since it uses a differential signal. Also, don't forget the commond wire, which should bond both the Pi and the controller to the same ground potential.

@Bond
I used the Modbus scanner on a windows computer to get all the communications settings correct (9600, N81) and to ensure that communications with the controller were working including the USB to RS485 converter and confirming modbus registers. With all this working and confirmed it was only necessary to work with Node Red configuration knowing that all else was working

Thank you @gemini86 for your response. I think the wiring is correct now because the python can actually run the fans.
I think the problem now is just trying to get that python file to work in Nodered.
I'm trying to read the status of a working fan (i turned it on physically so it's spinning), but have an error of reading ('sequential dequeue command not possible') as shown in the picture:

This is my setting of the Modbus Read node from node-red-contrib-modbus"


can anyone please help?

What do you have in the 'optionals' tab?

link a Modbus response node to the bottom output and set quantity to less than 100 (it is requesting 100 registers)

The datasheet of your controller shows that the status word is at 1001H (hex), so in the modbus node, that would be 4097 decimal. It also shows the status being 5 words in length. I do not know what the data formatting is, if they're using ieee 754 floating point data words, integers divided by some factor to represent floats, individual bit flags, etc. That's going to be deeper in the drive's actual modbus spec.

optional tab just to show errors and activities. I think for debugging

it does not work, show me the same error. Should i write some command into the register before reading?

Hey Bond, this could likely be a simple issue, but we need the device manual (the full manual) to be able to help out. What did you change the modbus read node to now?

Hi @gemini86, I only changed the quantity to 10 from my previous post.
This is the full manual: Manual
Cheers

Try reading (function 3) word address 3000, quantity 3.

how did you work out the quantity to be 3?

From the manual you linked. Can't cite the PDF right now, I'm on mobile. Any luck?

i'm writing some command to read the controller status. But it give me some kind of none sense output.


Fan1 is ON
Fan 8 is OFF
But the two output are pretty similar.

So here I'm confused by the registers you're reading and writing to. The manual shows the command registers, and the status registers as:

Also, may I get more info on the equipment? Are these fan controllers separate drives? or are these fans all on one controller? The manual you sent is an AC inverter, which would only control one load at a a time.

I have 8 controllers controlling 8 fans. The address are from 1 to 8.
I turned on fan 1 and fan 2 manually.
I am trying to ready their frequencies now. Then i will set different frequencies for different controllers.

How are the controllers wired to the pi? Daisy chain on a single rs486 bus? "Address" refers to the register address you're trying to write, not the controller device ID. "Unit-id" if you're using node-red-contrib-modbus. So, you need to create 8 "server" configurations, one for each fan, then poll the same address on each fan, but select the needed "server".

Hopefully this makes sense.

1 Like