Procedure to write the value from one variable to an output variable
It is possible to take the value from one variable and push it to another variable that has an output data direction (e.g. setpoint, analog output, digital output).
Arithmetic Function Method
- Create a new virtual variable
- Right-click virtual variables > Add > Append Variables
- Double-click new variable to open variable settings
- In the General section, change type to Arithmetic
- In the Formula section, add the VariableWriteIndexBased function to the formula window
VariableWriteIndexBased(DestinationVariableWriteAccessIndex + 1;SourceValue)
- DestinationVariableWriteAccessIndex+1: Access index of output variable, where a source value has to be written to (only variables with output-part as 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
test.con Method
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.
s- 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.
- Device Data Access Functions > Read/Write access
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.
- 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