PM851/COM3 - Modbus RTU - ACS580
I have found the Modbus library.
Are there any program examples for communicating with drives via Modbus? Function blocks for drives?
Modbus RTU and communicating with drives in AC800M is new to me.
I have 6 drives in a multidrop configuration. I want to send two words, ControlWord + Speeref. to the drives, receive two words, StatusWord + Current.
Can I MBConnect to all 6 drives in parallell, or do I need a sequence program.
In this .pdf dokument both MBRead and MBWrite Request is activated in parallell, is that possible?
Regarding to your last question - for 6 multidrop slaves, connected to one COM port of AC800M controller, you have to place 6 MBConnect blocks in your logic, one for each slave. That is why MBConnect block establish a separate connection to each slave - slave address is defined here.
Then you can connect multiple MBRead and MBWrite blocks to each MBConnect block - that depends on how many data you need to read/write to the slave.
In your case it could be only 1 MBRead block with 2 parameters (for two words to read) and 1 MBWrite block with 2 parameters to write.
You also have to take in consideration the size of words, you need to transfer trough Modbus. In case it is 16-bit size, you have to use word_to_int / int_to_word blocks, in order to connect INT variables to MBRead and MBWrite parameters.
In case of 32-bit words, you need to transfer each of them with 2 consequent INT variables, and then to unpack them in the CPU in proper way. In this case the number of parameters to each MBRead/MBWrite block will be 4
The type of one or more variables does not match the requirements of the procedure.What type of variables do you connected to Rd parameters of MB blocks?
They can be simple variables of the BOOL, DINT, UINT and INT type - in your case should be INT or DINT.
Also Poll Time in Modbus settings usually should be set = 0
Could you provide a screenshot
Source: CBM help = General Status Codes
For SP41xxx variables ! No WORD format is allowed here, that is why you have -5 error code
For your case I could recommend to set in the drive 16-bit format for control and status words.
Then put INT variables in Read/Write blocks
Then use translations in AC800M :
INT_TO_WORD for read variables (SP4_SW...)
WORD_TO_INT to write variables (SP4_CW...)
In summary: Read/Write with MB blocks using only INT. Then in application, transfer that INT to WORD or vice versa, depends on read or write function