Operation Principle Of Macro Block And Read/Write Variables - Omron NB Series Operation Manual

Nb-series programmable terminals
Hide thumbs Also See for NB Series:
Table of Contents

Advertisement

3 Functions of NB-Designer
(2) Perform the simulation, and the values displayed in Number Display components are same as the
assigned values in Macro.
3-9-2

Operation Principle of Macro Block and Read/Write Variables

In this part, we will start the description from the operating principle of Macro block in order to help you
understand it, and we will also describe the basic problems that should be noted when you use Macro
block.
Macro block can be regarded as a black box for input and output. Take the example mentioned in the
first part of this section as example, and the model is as follows:
Read variable
(Read only)
LW0_R
LW1_R
The operation principle is as follows: Before the block is executed, the value from the register for LW0
and LW1 will be assigned to Read variables LW0_R and LW1_R, then Macro block will be executed.
Later, after Macro block function returns, the value of variable LW2_W will be written into LW2.
Therefore, the variable in the Macro block is just like the copy of the register, and modifying the variable
value doesn't mean modifying the value of the register.
Note 1 Because Macro block doesn't read the value of the register in real time, and the read value is the value that
is read when Macro block starts to operate. Therefore, modifying the value of the register externally will not
affect the operation result of Macro block during its operation.
2 The value of Macro block is not written out immediately, so the value assigned to the variable during the
operation of Macro block can be written to Macro block only after the completion of Macro block.
3 Read Variable is read-only and Write Variable is write-only, so using Macro code to assign value for Read
Variable or read the value of Write Variable is invalid. Similarly, if one address is used for Read and Write
at the same time, it should correspond to 2 different variable names, such as LW0 corresponds to LW0_R
and LW0_W.
4 You can use Macro block to define any temporary variable or array at the inside of Macro block, even the
complicated combination, but global variable or static variable can't be set by using Macro block. If it needs
to use the global variable to save the data, please use the local address such as LW and LB etc.
5 The values must be assigned to the register for the output.
3-260
Macro block
int MacroEntry()
{
If(LW1_R!=0)
LW2_W=(double)(LW0_R)/LW1_R,
Return 0;
}
NB-series Programmable Terminals NB-Designer Operation Manual(V106)
Write variable
(Write only)
LW2_W

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents