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.

Using values from the same module

Some modules like A106, A109, D101 and A192 have both Input and Output Channels. In those cases the Input can be directly fed to the output without having to use the controller or the UART.

Example for sending the information from the Bridge input of the A106 module directly to the Analog Output of the same module:

Analog Input (Source variable):

Analog Output (Target):

 

Inter Module connectivity

Choose External as the Source Type

and set the address and Byte Offset.

The Byte Offset works like a register offset, Offset 0 ist the first (FLOAT) channel and offset 2 ist the second Channel of the Source module.

 

Article about the inter module communication:

Inter Module Connectivity

 

Operation time of different options

Sorted from Fastest to slowest

Module internal communication is usually one measurement cycle of the module. A102 was used due to the SAR having very low signal propagation delays. The digital communication is the same for all modules.

Inter module connection uses the communication on the UART and depends on the sample frequency of the UART and will take at least one additional sample for the transfer between modules.

 

Via Controller at 10kHz Sample Rate is usually 400µs from Input to Output (Signal propagation Delays of the Modules need to be added to this time)

Result: (Ch1 = Din1; Ch2 = Aout)

EtherCAT master at 10kHz over a controller will take at least 900µs

EtherCAT master at 10kHz over Q.bloxx EC will show 1 ms