Reading & Writing External Registers In A Macro - Maple Systems Silver Series Installation And Operation Manual

Operator interface terminal
Hide thumbs Also See for Silver Series:
Table of Contents

Advertisement

256
The above example code defines a sub-function called SQR(). This sub-function allows one variable to be passed
into it. The function then takes the value passed to it, multiplies its value by itself and then stores the result back
into the same variable. The result is returned back to the calling function.
Reading & Writing External Registers in a Macro
A macro program can communicate with external PLC data registers and I/O. The function GetData() receives data
from the PLC (or the OIT's local LW and LB memory). The function SetData() sends data to the PLC (or the OIT's
local LW and LB memory).
The GetData() or the SetData() can be hand typed according to the format listed below, or the "PlcCom" button
located at the bottom-left of the macro editor dialog box allows the user to generate the GetData() or SetData()
function code by selecting the appropriate responses within the PlcCom dialog box. Be sure to declare all variables
before using the 'PlcCom' option. To set up the following functions, place the cursor after the declarations, and
then press the PlcCom button. This way, all variables will be available in a drop-down menu list within the
'PlcCom' dialogHIDD_MACROPLCCOM.
GetData() Func tion
This function reads data from a register location in the OIT or PLC memory, and stores it into a variable.
The format for the GetData() function is:
GetData(DestVariable, Addr_Tpe, Address, NumElements)
Parameter
DestVariable
Addr_Type
Address
NumElements
SetData() Func tion:
SetData( DestData ,CString strAddr_Type , int iAddr_Off , int iDataCount )
Description: Writes data from a variable to a location in the PLC memory.
Parameter
DestData
StrAddr_Type
1010-1001a, Rev 02
End Sub
Macro_Command main( ) // This main function calls the SQR()
function.
int I = 5
I = SQR(I)
SetData(I, LW_Binplc, 1,1)
End Macro_Command
Description
The name of the variable to store the
data that is captured
The device type and encoding method
(binary or BCD) of the PLC data.
The address offset in the PLC (must be
written as a constant whole number – no
decimals – no variables)
Number of elements to read/write (must
be at least 1 and it must be a constant
number) If the number of elements is
more than 1, the 'DestVariable'
parameter must be declared as an array.
Description
The name of the variable to retrieve the
data from
The device type and encoding method
(binary or BCD) of the PLC data
Sil ver Se ries In stal la tion & Op er a tion Man ual
// Write the result to a LW
Example(s)
MyVar, InputArray[0]
LW_Binplc, 4x_Binplc,
0x_Binaux, RW_Bcdplc
0, 100,
(an address that
has a decimal point is
written here without the
'.' So 1.03 is written as
103
1, 16, 100
Example(S)

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents