The most common way is to define a global variable and then bind it to the corresponding variable. For
example, I defined a variable of type SINT named ControlWord with a value of 8. After compiling, I found
that this variable was added to the PLC program (MAIN.ControlWord is the output variable we defined.
Note that AT%Q* represents output type and AT%I* represents input type).ControlWord AT%Q*:SINT:=8;
Then I double-clicked on this variable and found the variable to bind in Linked to (you can see that only a
few types are displayed, as TWINCAT only presents SINT-type variables of the same type)
The disadvantage of the previous method is not the "method", a more standard approach is to write
the parameters into the ADSWrite function, rather than binding them together. Using the function
block ADSWRITE, the previous parameter NETID can have two single quotes, and if PORT is written
as NC, it is 500, and if it is written as PLC, it is 801. The address group and address offset are described
below, and SRCADDR is the value to be written. You can use the ADR address function to place the
PLC variable name corresponding to the MAIN function.
Place the mouse in the corresponding variable text box to prompt the current variable's IndexGroup
and IndexOffset to view the address group and address offset
After clicking on Write, you can see that Online Value has been written as 123