DrvModbusReadWrite23
(FB)
FUNCTION_BLOCK DrvModbusReadWrite23
Function block DrvModbusReadWrite23 reads and writes one or more parameters of the drive via DriveData connected to Modbus Tcp / Modbus RTU communication blocks with Modbus function code FCT = 23. This block internally calls DrvModbusWrite to execute Read Write job with FCT = 23, used along with structure for Fct23, DrvModFct23Type.
The number of parameters to be read is specified at the input NvarRead. The first address for read operation is specified at the input PrmNumRead. The values of the data is stored in the PLC memory area, defined at the input DataRead.
The number of parameters to be written is specified at the input NvarWrite. The first address for write operation is specified at the input PrmNumWrite The values of the data that should be written must be stored in the PLC memory area, defined at the input DataWrite.
The values in the PLC memory area are updated when the Read Write job is performed without error. A successful Read Write operation is indicated by output JobDone = TRUE and output ModMastErrorAct = FALSE
To initiate a Read Write job the input Execute must be given a rising edge. (FALSE -> TRUE).
After termination of this job, even if it was not successful, a next Read Write job can once again only be started with a rising edge at input Execute.
The Modbus job is started from the modbus communication function block DrvModbusTcp/ DrvModbusRtu which is connected to the same inout variable DriveData.
The modbus server address (IPAdrServer for ModbusTCP) of the drive to which the Read Write job is to be sent is specified at the communication function block DrvModbusTcp/ DrvModbusRtu.
If the input values are valid, a request to perform a Modbus job is send to the DrvModbusTcp/ DrvModbusRtu block via the DriveData variable.
If at least 1 input is invalid, no job is generated and the error is displayed at the outputs Error and ErrorID instead.
Note
This block should not be used in parallel with ModRtuMast FB for the same drive. The function block must be used in same PLC task than other function blocks using the same inout variable DriveData
- InOut:
Scope
Name
Type
Initial
Comment
Input
Execute
BOOL
FALSE
1: A rising edge starts the operation, the output Busy goes to TRUE. In the first cycle all other inputs are read and stored, afterwards they are ignored. A falling edge does not stop the operation. After Done = TRUE or Error = TRUE and Execute = FALSE all outputs will be reset.
Prio
BOOL
FALSE
2: Reserved - not used
NvarRead
UINT
1
3: Number of parameters to be read. valid range is: 1 .. 125
PrmNumRead
UINT
1
4: Parameter number to read = 100 x Group + Index. e.g. Par 20.06 -> PrmNum = 20 * 100 + 06 = 2006 . Valid range: 1..65535. For 32 bit parameters see function DrvModPara32Bit
DataRead
DWORD
0
5: First operand address of an operand area in the AC500, to which data read from the drive should be stored
NvarWrite
UINT
1
6: Number of parameters to be written. valid range is: 1 .. 121
PrmNumWrite
UINT
1
7: Parameter number to write = 100 x Group + Index. e.g. Par 20.06 -> PrmNum = 20 * 100 + 06 = 2006. Valid range: 1..65535. For 32 bit parameters see function DrvModPara32Bit
DataWrite
DWORD
0
8: First operand address of an operand area in the AC500, from which data should be written to the drive
Inout
DriveData
9: Drive reference variable to connect to all function blocks of this drive
Output
Done
BOOL
FALSE
1: Operation is completed without error (while outputs Busy and Error are FALSE). This output is TRUE for atleast one cycle or until Execute is set to FALSE.
Busy
BOOL
FALSE
2: Operation is running (while outputs Done and Error are FALSE).
Error
BOOL
FALSE
3: Operation is stopped with error (while outputs Busy and Done are FALSE). This output is TRUE for at least one cycle or until Execute is set to FALSE. The output ErrorID gives more details about the error.
ErrorID
4: Error codes
ModMastErrorAct
BOOL
FALSE
5: Active error in ModMast. Operation is running with error . This output is TRUE for at least one cycle or until Execute is set to FALSE. The output ModMastErrorIDLast gives more details about the last error.
ModMastErrorIDLast
WORD
0
- 6: Error code of last active error in ModMast. For error code description when used with DrvModbusTcp block, refer to error codes in Modbus TCP library, “AC500_ModbusTcp.ERROR_ID”,
For error code description when used with DrvModbusRtu block, refer to error codes in Modbus RTU library, “AC500_ModbusRtu.ERROR_ID”.
WarnAct
BOOL
FALSE
7: Operation is running with warning . This output is TRUE for at least one cycle or until Enable is set to FALSE. The output WarnIDLast gives more details about the warning.
WarnIDLast
8: Warning code of last active warning
JobDone
BOOL
FALSE
9: Read Write job finished
JobBusy
BOOL
FALSE
10: Read Write job active