How to Write a Value to an Output Channel

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

  1. 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.

  2. In the Formula tab, add the VariableWriteIndexBased function to the formula field.

    VariableWriteIndexBased(DestinationVariableWriteAccessIndex+1;SourceValue)

    1. 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.

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

  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.

Using test.con

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.

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