How to write a value to an output channel

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

  1. Create a new virtual variable
    1. Right-click virtual variables > Add > Append Variables
    2. Double-click new variable to open variable settings
    3. In the General section, change type to Arithmetic
  2. In the Formula section, add the VariableWriteIndexBased function to the formula window

    VariableWriteIndexBased(DestinationVariableWriteAccessIndex + 1;SourceValue)

    1. 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)
    2. SourceValue: The variable where the value comes from





      V1 - Timestamp



      V2 - Setpoint1



      V3 - Setpoint2



      V4 - Setpoint3



      V5 - Setpoint4



      V6 - WriteOutputVar



      V7 - SourceValue




      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!)

  3. Click Apply to set formula, then OK to save changes to the virtual variable
  4. 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

  1. Run test.con software and create a new userspace or realtime project
  2. Go to Tools > Data point Administration
  3. Click Online Import Configuration
  4. Scan for the connected controller. Once found, select it and click OK
  5. 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.
  6. In a program or macro block, you can drag functions block from the libraries section on the right.
    1. 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.
    2. 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.

  1. 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.
  2. Once logged in it will download the program into the controller