Raspberry PI connect to RS485

@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

Each controller has A, B and Ground terminals connected to USB to Serial converter as my first post in this topic. Then the USB plugged into the PI.
The server in the Write node, i have set that to serial input as:
image
And this is my string as input to the write node to read frequency (According to the manual):


Should i exclude the address from the string?

So you have 8 of these converters? If so, each of these addresses should be identical to access the same function (also assuming the inverters are identical). You just point to a different usb device for each. If these controllers are able to be configured with different device IDs (device address), then I would just use one usb-rs485 converter to communicate to all of them. But that's me.

Anyway, you don't need to be sending any string, message or anything to read a register. Just configure what register you want to read in the address field and what modbus function you need, and it will compose the modbus message for you. As far as reading the correct register address: Note that the manual shows these addresses in HEX format. register 1001H would need to be configured in as 4097 in decimal. Also note that some modbus devices are 1 indexed, which means they don't start at 0 (like they should) and instead everything is off by 1. So, the manual may say to read register #1, but this is at memory address 0 (the first memory address) I've run into this a few times. Looking again at your python code, it looks like that may be the case. So instead of trying to read address '1001' try reading '4096'. confusing, I know.

Also, per your python code; they're using the same usb device to communicate with all 8 fans, so this would suggest a common rs485 bus with each controller using a different device-id or unit-id.

Thank you for your response, it's very helpful for me.
Now as you say i don't need to send a string of command.
And I can set the device IDs and register address in the actual Write node.
So where would i put the 'value' then?
For example, from the manual:
image
This is to set the controller frequency. If i want to set it to full speed (50Hz). Where should i put the value of 10000?

You don't need to send a string command to read a register. Only to write.
If you are actually writing to the controller, to a write-only register, send in the required data in msg.payload. Read the info tab in "Modbus Write" node:

For FC 5, msg.payload must be a value of 1 or 0 or true or false. For FC 15, msg.payload must be an array[] of comma separated values true or false each. For FC 6, msg.payload must be a single value between 0:65535. For FC 16, msg.payload must be an array[] of comma separated values between 0:65535 each.

So, to set the motor to 100 percent speed, send "Modbus Write" node a msg.payload of 10000 (which would be 100.00% speed). This is very much the way yaskawa does it in their drives as well. I think the write node will also parse a string, but I would make it a good habit to use integers.

So, compare to the python code for setting the frequency on fan 1:

# set frequency # 10000 = 100%@50Hz
freq_1 = instrument_1.write_register(0x1000, 6000, functioncode =
6) # Register number, value, number of decimals for storage
print freq_1

So they're writing to register 0x1000 (which is register 1001 in HEX, 4096 in DEC) using function code 6 (preset single register) and setting it to 6000 (again, DEC) which is 60.00% speed. With the max speed being 50 Hz, 60% would be 30 Hz.

For fan 8, you would need another 'server' in the configuration with unit-ID set to 8. This would still communicate on the same RS485 as the other drives, but only fan 8 would respond.