The MODBUS Master package for W
package which allows the user to MODBUS Master function blocks for
Regent application programs. W
seamlessly integrated with the base WINTERPRET
MODBUS Master function blocks allow the Regent to use devices which
respond to MODBUS commands to collect and disseminate data for non
safety-related application.
hen installed on the PC, the package is
INTERPRET
W
INTERPRET
(T3837)
Issue 1, August, 96
is an add-in software
software.
-
Software Installation
The MODBUS Master package is installed on the PC running the
W
INTERPRET application software. The WINTERPRET
provides the necessary installation software to install this add-in package.
The package should be install
the W
INTERPRET
Installation Procedure
The files on the MODBUS Master package diskette are in compressed
form. You cannot simply copy the files to your hard drive — they must be
decompressed before they will run. You must have the W
package distribution disk in order to run the setup procedure to install the
MODBUS Master package.
To install the MODBUS Master package, use the following sequence:
1.
Insert the WINTERPRET base package distribution disk into drive A: or
B:
2.
Start Windows (if it isn’t already running).
3.
Choose Run from the Program Manager’s File menu.
base package.
base package
ed at the same time or after you have installed
INTERPRET
base
Industrial Control Services
(Issue 1)
1
MODBUS Master Package for
4. Type a:\
base package disk in drive B: type b:\
press ENTER.
5. In the WINTERPRET
which you have installed the W
that you have already installed W
6. In t
Master package box.
7. Choose
When the installation is completed, you can run the WINTERPRET
application and create MODBUS Master function blocks in your
application programs.
he W
setup.exe
INTERPRET
OK
in the text box. (if you inserted the WINTERPRET
Setup dialog box enter the name of the directory in
Installation dialog box check the MODBUS
to have the setup program install the package software.
W
INTERPRET
setup.exe
INTERPRET
INTERPRET
(T3837)
.) Choose OK or
base package (This assumes
). Choose
Continue.
Working with MODBUS Master Function
Blocks
MODBUS Master function blocks are created as part of an application
program which may also contain other types of function blocks. A single
application program is made up of as many as 50 function blocks of any
type or combination.
When you installed the MODBUS Master package, additional software
was added to W
function blocks. With this additional software you can create MODBUS
Master function blocks by opening a project, opening a program, and
opening (or creating) a function block.
The code generated by W
(MODBUS Master function block code) responds to control signals,
prepares MODBUS commands to be sent, decodes received MODBUS
responses, and in general performs the operations that are associated with a
MODBUS Master.
The MODBUS Master code is executed in the Regent in the same manner
as any other function block code. It is called once per application scan as
long as the program to which the MODBUS Master function block belongs
is in the run state. Instead of performing a complete MODBUS scan each
INTERPRET
INTERPRET
to allow you to work with MODBUS Master
for the MODBUS Master
PD-6048 August, 96
(Issue 1)
2
MODBUS Master Package for
time it is called, the MODBUS Master function block code splits up the
tasks so that it can be done a
a time. This allows the Regent system to remain responsive, as well as
eliminating the potential loss of time while waiting for MODBUS responses.
For an overview about Regent application programs and function blocks
and how to create them using W
with Programs and Function Blocks
little at
INTERPRET
W
INTERPRET
, refer to Section 5,
, in the Regent User’s Guide.
(T3837)
Working
Using MODBUS Master Function Blocks
The MODBUS Master function block allows the user to specify the
following Regent variables:
·
Variables to receive data from MODBUS slaves
·
Variables to be the source of data sent to MODBUS slaves
·
Variables to serve as control signals for the function block
·
Variables to receive the current status and other information about the
function block.
Each Regent variable used to send or receive data may be associated with a
different MODBUS node and address. The user may specify which port on
the Regent to use, including the s
configuration.
The MODBUS Master function block compiler may be invoked from the
File menu in the MODBUS function block editor when the editor is closed
and the changes have been saved for the current function block. The
compiler translates the user’s inputs from the source file into an object file to
be loaded into and executed in the Regent.
The compiler has two separate phases: registration and generation. In the
registration phase, the compiler registers t
from the project dictionary. The generation phase consists of parameter
validation followed by code and data segments generation. The registration
phase follows the conventions (and requirements) imposed by other
W
INTERPRET
each function block compiler, and is where MODBUS-Master-specific
code is introduced.
function block compilers. The generation phase is unique to
election of a secondary port for a dual-link
ag names and retrieves definitions
PD-6048 August, 96
(Issue 1)
3
MODBUS Master Package for
Name
Size Type
Description
E
NABLE
Coil Input
Enables execution of the function block. Energize to
execute the function block.
E
RROR
Coil
Output
Enunciates a MODBUS function block error.
Energized when an error occurs.
R
ESET
Coil Input
Resets the error information. Energize to reset the
information. While energized, no errors w
ill be
reported.
N
ODE
Word
Output
The MODBUS node associated with the error. 0 when
there is no error.
C
ODE
Word
Output
The MODBUS function block error code. 0 when there
is no error.
T
IME
Float
Output
The time it took to complete the last MODBUS scan in
ms. 0 until a scan has been completed.
T
OGGLE
Coil
Output
This control signal changes state at the beginning of
each MODBUS scan. (Its period it typically 2 *
Time)
W
INTERPRET
(T3837)
Operation
The MODBUS function block uses control signals to report information and
accept runtime control
used like normal Regent variables. Table 1 identifies these control signals.
Table 1 - Control Signals
E
NABLE
E
NABLE is de
and all other signals are invalid (exception: the RESET
honored).
E
RROR
enunciates any errors that the MODBUS function block code
encounters.
N
ODE
and
when
E
RROR is active. NODE
a zero [0] indicating the MODBUS master itself).
specific MODBUS exception code.
The
T
OGGLE
the initial scan,
T
OGGLE
desired instead of a toggle, external application code (in the same program)
may reset
directives. The signals are user defined, and may be
controls the execution of the function block at runtime. When
-
ener
gized (OFF), the function block code is not executed
input signal will still be
C
ODE
are used to further define an error. They are valid only
contains the MODBUS node that is in error (
C
ODE contains the
state changes each time a MODBUS
T
IME
contains the length (in ms) of the MODBUS scan.
is initialized to de-energized (OFF) for the initial scan. If a pulse is
T
OGGLE
to the de-energized state after a rising edge is detected.
scan is completed. After
PD-6048 August, 96
(Issue 1)
4
MODBUS Master Package for
Field Size
Description
Node Byte
The MODBUS node to broadcast this command to.
Function
Byte
The MODBUS function to broadcast.
Address
Word
The starting MODBUS address for this command.
Count
Word
The number of MODBUS variables to be returned.
CRC Word
The pre-calculated CRC for the MODBUS command.
Offset
Word
The index into the Read Var table for the initial MODBUS
variable.
Reserved
Word
Reserved for internal use.
Field Size
Description
Value
Word
The value of the regent varia
ble.
Note:
W
INTERPRET
(T3837)
Tables define the work that the MODBUS function block performs. The
primary table used is the ‘Read Command’ (RC) table. Each entry in the
RC table is eight bytes wide, with the first six bytes corresponding exactly
to the same fields in a MODBUS command. Each entry (starting with the
first) in the RC table sends a MODBUS command. When the response is
received, the Count field is used to decode the received data. The Index
field, in conjunction with the Read Variable table, is used to store the data in
its proper place. Tables 2 and 3 define the Read Command and Read
Variable Tables, respectively.
Table 2 - Read Command Table
Table 3 - Read Variable Table
When each entry in the Read Command table has been sent, the function
block code waits for all the replies to be returned. When all of the replies
have been received and processed, a single MODBUS scan has been
completed. At the start of the next MODBUS scan, the entire process
starts over at the beginning of the RC table.
Abstractly, the RC table can be thought of as a “Read” queue. This queue is
replenished at the start of each MODBUS scan, and is empty at the scan’s
completion. Future pseu
queue as the READQ.
PD-6048 August, 96
(Issue 1)
do code examples refer to the abstract RC table
5
MODBUS Master Package for
Field Size
Description
Node Byte
The MODBUS node to notify when the v
alue changes.
Function
Byte
The MODBUS function to use for notification.
MODBUS
Address
Word
The MODBUS address to use for notification.
Value
Word
The current value of the variable.
CRC Word
Placeholder for the run-time calculated CRC of the MODBUS
command.
Last Value
Word
The last known value of the variable.
Reserved
Word
Reserved for internal use.
Note:
W
INTERPRET
(T3837)
The ‘Write Command’ (WC) table is also used by the MODBUS master
function block code. In many ways, the WC table is similar to the RC table.
However, the WC table does not utilize a corresponding Write Variable
table because each “Write” only references a single variable. Table 4
defines the Write Command Table.
Table 4 - Write Command Table
Every application scan the function block code is executed, each variable
defined in the WC table is examined by comparing its current value to the
co
ntents of the Last Value field. If the two value differ, the Send Flag field is
set and the current value is copied into the Last Value field.
Each entry in the WC table, with the Send Flag set, causes a MODBUS
command to be sent. When the response is received, the Send Flag for that
variable is cleared. For the initial MODBUS scan, the Send Flag field is set
for every entry in the table. The WC table is processed from the initial entry
to the final entry in sequence. If no more MODBUS commands can be
sen
t, WC processing stops and resumes again on the same entry the next
time the function block code is executed.
PD-6048 August, 96
Abstractly, the WC table can be thought of as a “Write” queue. This queue
is full for the initial MODBUS scan. Future pseudo code example refer to
the abstract WC table queue as the WRITEQ.
The tasks performed each time the function block code is executed are as
follows:
· ENABLE
·
is checked to see if the function block should be executed.
A check is made to see if this is the initial MODBUS scan. If so, local
variables and tables are initialized.
(Issue 1)
6
MODBUS Master Package for
·
A check is made to see if this is the start of a MODBUS scan. If so, the
‘MODBUS Scan Time’ timer is reset.
·
Each “Write” variable is check to see if it has changed state (or value),
and those that have are added to the WRITEQ.
·
Outgoing packets are sent.
While !FULL(SENDQ)
If !EMPTY
(WRITWQ)
ENQ(SENDQ, DEQ(WRITWQ))
Else If !EMPTY(READQ)
ENQ(SENDQ, DEQ(READQ))
End If
End While
·
Incoming responses are received, and the appropriate actions are
taken.
·
While !EMPTY(RECVQ)
PROCESS(DEQ(RECVQ))
End While
A check is made to see if this is the end of the MODBUS scan. If so,
copy the timer and toggle the toggle.
·
RESET
is checked to see if the error signals should be cleared. This
occurs even if the function block is not executed.
W
INTERPRET
(T3837)
The MODBUS function block code keeps track of how many me
ssages
are outstanding by incrementing a counter for each ENQ(SENDQ,
DEQ(READQ)), and decrementing the same counter for each
DEQ(RECVQ) when the response is a “Read” response. A MODBUS
scan is considered complete when the counter is zero (0) and the READQ
is empty (COUNT == 0 && EMPTY(READQ)).
At the beginning of each MODBUS scan, a copy of the system millisecond
timer is made. At the completion of a MODBUS scan, this value is copied
into the T
IME
variable and the
T
OGGLE
signal is inverted.
Placing a MODB
US command on the SENDQ involves copying the
MODBUS command to a buffer, generating the appropriate error-check
code, and sending the command to the correct port (primary or secondary).
Internal variables are used to determine the port.
If a secondary port was defined, once each MODBUS scan the initial
MODBUS ‘Read Command’ for each node is sent via the secondary port.
The result of this command is ignored, it is used only to check for a valid
connection. The MODBUS Node table is used to track the status o
node’s response. Table 5 defines the MODBUS Node Table.
f each
PD-6048 August, 96
(Issue 1)
7
Loading...
+ 16 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.