Configuration options allow for transferring values from one variable and pushing them to another variable with an output data direction (e.g., setpoint, analog output, digital output).
Using a controller virtual variable
-
Create a new virtual variable by right-clicking on Virtual Variables > Add > Append Variables. Double-click on the new variable to open the variable settings. In the General tab, change the type to Arithmetic.
-
In the Formula tab, add the VariableWriteIndexBased function to the formula field.
VariableWriteIndexBased(DestinationVariableWriteAccessIndex+1;SourceValue)
-
DestinationVariableWriteAccessIndex+1: Access the index of the output variable where the source value needs to be written. Only variables with an output data direction (OUTPUT or INPUT/OUTPUT) are possible.
-
SourceValue: The variable where the value comes from. Example:
Variable
DataDirection
VariableWriteAccessIndex
V1 - Timestamp
INPUT
V2 - Setpoint1
INPUT
V3 - Setpoint2
INPUT/OUTPUT
0
V4 - Setpoint3
INPUT
V5 - Setpoint4
OUTPUT
1
V6 - WriteOutputVar
INPUT
V7 - SourceValue
INPUT/OUTPUT
2
Example 1:
VariableWriteIndexBased(1;Var(“V7 - SourceValue”))
Value of “V7 - SourceValue” is written to “V3 - Setpoint2” (pay attention that index + 1 must be set!).
Example 2:VariableWriteIndexBased(2;Var(“V7 - SourceValue”))
Value of “V7 - SourceValue” is written to “V5 - Setpoint4” (pay attention that index + 1 must be set!)
-
- Click Apply to set formula, then OK to save changes to the virtual variable
- Write updates to controller.
Now when you change the source variable's value, it will be written to the defined output variable.
Using test.con
In a test.con project, you can connect input variables to output variables to transfer those values.
- Run test.con software and create a new userspace or realtime project.
- Go to Tools > Data Point Administration.
- Click Online Import Configuration.
- Scan for the connected controller. Once found, select it and click OK.
- The variables configured in the controller and modules will be loaded into the Data point administration window. Variables configured within the controller can be seen by highlighting the controller in the tree. Click OK to close window.
- In a program or macro block, you can drag functions block from the libraries section on the right.
- Device Data Access Functions > Read/Write access
When dragged into the window, it will prompt you to select a corresponding input/output variable to read from/write to. Connect a line between the read and write blocks or add additional function blocks in between. - Converter > Pin
Provides a pin where you can assign a parameter or variable. Right-click the pin and select Assign Variable, select the corresponding input/output variable. Connect a line between the read and write blocks or add additional function blocks in between.
If you don't see the library you need, make sure it is loaded by going to Project > Load Library. Select libraries needed and click Load.
- Device Data Access Functions > Read/Write access
- Go to Run > Download. It not done yet, it will prompt you to login to the target system. Select the appropriate user or realtime app and click Connect. Click OK to proceed.
- Once logged in it will download the program into the controller.