ModRtuWrite
(FB)
FUNCTION_BLOCK ModRtuWrite EXTENDS AbbETrig3
Function block ModRtuWrite writes n data to the Modbus server device. The number of data to be written is specified at the input Nb. The first address is specified at the input Addr. The values of the data that should be written must be stored in the PLC memory area, defined at the input Data. A successful writing is indicated by JobDone = TRUE, ModMastErrorAct = FALSE and WarningAct = FALSE.
To initiate a write job the Execute input must be given a rising edge. (FALSE -> TRUE) The values at the inputs will not in any case be stored in the moment of the rising edge of the Execute input. The input values will be stored when the corresponding ModRtuToken function block has the modbus line token and the instance of this ModRtuWrite function block has the internal server token. If the rising edge of Execute is given e.g. with the JobDone output of the previous programmed ModRtuRead or ModRtuWrite or ModRtuReadWrite23 function block, these events occur in the same time and the values are stored immediately. The values that should be written must be kept stable for one more PLC cycle in the same PLC memory area, defined at the input Data.
After termination of this job, even if it was not successful, a next writing can only be started with a rising edge at Execute input. If the Execute input is kept to TRUE the outputs Done, JobDone, any Warning or Error message be kept until the Execute input is set to FALSE.
The Modbus job is started from the ModRtuToken function block which is connected to the same ServData variable. To trigger the write job user must Enable the ModRtuToken function block with the same ServData IN_OUT configured.
The Modbus server address of the device to which the data is to be written is specified at this ModRtuToken function block.
If the input values are valid, a request to perform a Modbus RTU job is send to the ModRtuToken function block via the ServData 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
The function block must be used in same PLC task than other Function blocks using the same variable on IN_OUT ServData
- InOut:
Scope
Name
Type
Initial
Comment
Input
Prio
BOOL
FALSE
2: Reserved - not used
Fct
BYTE
16
3: Modbus function code. 5 = write one bit; 6 = write one word; 15 = write n bits; 16 = write n words; 22 = Mask Write ; 23 = Read / Write multiple register
Nb
UINT
1
4: Number of variables to be written. valid range is: 1 .. 1968 - see general description, about when the value is stored in the function block
Addr
UINT
0
5: Address to write to in modbus server device, valid range is 0..65535 - see general description, about when the value is stored in the function block
Data
DWORD
0
6: First operand address of an operand area in the AC500, from which data should be written to the modbus server - see general description, about when the data written. Use ADR operator to connect the input.
Inout
ServData
7: Modbus server device reference variable to connect to all Modbus server function blocks.
Output
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
6: Error code of last active error in ModRtuMast, For error code description, refer to error codes in ERROR_ID.
WarnAct
BOOL
FALSE
7: Operation is running with warning . This output is TRUE for at least one cycle or until Exceute 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: Write job finished
JobBusy
BOOL
FALSE
10: Write job active
Methods:
A_StartAction
D_ResetAction
B_CyclicAction
C_CleaningAction
Structure: