Raspberry PI connect to RS485

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

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:
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:
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.

Thank you for all the help. I get it working now. The following is my flow to turn on/off and set frequency for the first controller.

[{"id":"1362989f.2b4cb7","type":"debug","z":"76d2f80e.a06eb8","name":"fan1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":370,"y":60,"wires":[]},{"id":"7fba4baf.61bbb4","type":"modbus-read","z":"76d2f80e.a06eb8","name":"Read Fan1","topic":"","showStatusActivities":true,"logIOActivities":false,"showErrors":true,"unitid":"1","dataType":"HoldingRegister","adr":"4097","quantity":"5","rate":"10","rateUnit":"s","delayOnStart":true,"startDelayTime":"2","server":"782a4491.d4e49c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":150,"y":80,"wires":[["1362989f.2b4cb7"],["c2b737df.145e58"]]},{"id":"c2b737df.145e58","type":"modbus-response","z":"76d2f80e.a06eb8","name":"","registerShowMax":20,"x":400,"y":120,"wires":[]},{"id":"4e46567.f7c03a8","type":"modbus-write","z":"76d2f80e.a06eb8","name":"TurnOn fan1","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"4096","quantity":"1","server":"782a4491.d4e49c","x":310,"y":220,"wires":[["b2e5c3a.166704"],["9a23ceff.113aa"]]},{"id":"b8d3e2e6.54d91","type":"inject","z":"76d2f80e.a06eb8","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":220,"wires":[["4e46567.f7c03a8"]]},{"id":"9a23ceff.113aa","type":"modbus-response","z":"76d2f80e.a06eb8","name":"","registerShowMax":20,"x":510,"y":220,"wires":[]},{"id":"b2e5c3a.166704","type":"debug","z":"76d2f80e.a06eb8","name":"fan1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":490,"y":180,"wires":[]},{"id":"382e597b.cc9d06","type":"modbus-write","z":"76d2f80e.a06eb8","name":"Frequency","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"1","quantity":"1","server":"782a4491.d4e49c","x":250,"y":280,"wires":[["19d380ba.82b28f"],["e9dabafa.7e0988"]]},{"id":"acc75bfa.f34f68","type":"inject","z":"76d2f80e.a06eb8","name":"","topic":"","payload":"5000","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":280,"wires":[["382e597b.cc9d06"]]},{"id":"e9dabafa.7e0988","type":"modbus-response","z":"76d2f80e.a06eb8","name":"","registerShowMax":20,"x":490,"y":300,"wires":[]},{"id":"19d380ba.82b28f","type":"debug","z":"76d2f80e.a06eb8","name":"fan1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":470,"y":260,"wires":[]},{"id":"5428f4dc.d6338c","type":"modbus-write","z":"76d2f80e.a06eb8","name":"TurnOff fan1","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"4096","quantity":"1","server":"782a4491.d4e49c","x":270,"y":340,"wires":[["cf829dcd.26896"],["bcbe64fb.e57838"]]},{"id":"9547ebe6.6afcc8","type":"inject","z":"76d2f80e.a06eb8","name":"","topic":"","payload":"5","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":340,"wires":[["5428f4dc.d6338c"]]},{"id":"bcbe64fb.e57838","type":"modbus-response","z":"76d2f80e.a06eb8","name":"","registerShowMax":20,"x":450,"y":380,"wires":[]},{"id":"cf829dcd.26896","type":"debug","z":"76d2f80e.a06eb8","name":"fan1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":450,"y":340,"wires":[]},{"id":"782a4491.d4e49c","type":"modbus-client","z":"","name":"","clienttype":"simpleser","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.