Direct variables

It is not always possible to configure all of them in a group or group. variables required by a PLC.
In such cases, the driver provides “PLC data”.

Such variables are characterized by the fact that they are not included in the configuration of that group, but instead contain their entire configuration in the name. The communication module and the driver recognize direct variables by the fact that their name begins with a double cross (”).’ The complete syntax describes the following rule:

#[([<AktZeit>][r][w][i])]<Adress>[<Typ>][<Length>|<Amount>]

The most important and the only non-optional specification is the address of the value in the PLC. This must also contain any information that may be necessary about the format of the value. Their syntax is the same as that that can also be specified in the variable table under operand and PLC format.

Unless you specify otherwise, the type of variable is derived from the type of value in the PLC.
If you want to explicitly specify the type, specify one of the following abbreviations according to the address and PLC format:

  • TB for Bool’s value
  • TG for integer
  • TF for floating point
  • TS for String
  • TD for data block

For strings and data blocks, you must then specify the length. There are two options for this:

  • Length in bytes as a decimal number, as in the editor of the “PLC Data” driver in the Byte Count field. You must ensure that the number of bytes is divisible to the size of the data item addressed by the operand
    (e.g. length 10 is not allowed for double words because a double word is 4 bytes long).
  • Number of elements in square brackets. The length of the string or data block is the number you specify multiplied by the size of the data item addressed by the operand in the PLC.

For example, in the case of a SPS Simatic S7, the following information is equivalent:

#DB 100.DBW 12 WORD TD 10

#DB 100.DBW 12 WORD TD[5]

Tip: You can easily check the correctness of operands, PLC formats, and lengths with the editor of the PLC Data driver by creating a test variable in them and entering the relevant information.
If you leave the line with this variable and the Check Immediately option is turned on, the editor also displays the preferred spelling in the status line (but without VisXpert type).

In general, direct variables are used only with synchronous read or write jobs, but information such as update time, access rights, or read strategy is not relevant.
If you also use direct variables for other purposes, you can enter this information in the address in parentheses:

  • Update time in ms as a simple decimal number. Zero means that the variable is actively sent by the PLC, otherwise the variable is read cyclically by the PC in the specified grid.
  • ‘r’ to set read access
  • ‘w’ to set write access
  • ‘i’ to specify 0 at update time, so that the variable should be read once by the PC when logging in.

Examples:

  • #MD 10 -> 4-byte signed integer as VisXpert integer
  • #MD 10 DWORD -> 4-byte unsigned integer as VisXpert integer
  • #MD 10 DWORD TF -> 4-byte unsigned integer as VisXpert floating point
  • #MD 10 REAL -> PLC floating point number as VisXpert floating point
  • #MB 10 BYTE TD 8 -> 8 bytes from MB 10 as VisXpert data block
  • #MW 10 WORD TD 8 -> 4 words (8 bytes) as VisXpert data block (bytes rotated in pairs)
  • #MW 10 WORD[4] -> The same as above.
  • #(350)MW 10 WORD -> 2-byte unsigned integer, update every 350 ms.
  • #(0i)MW 10 WORD TG -> 2-byte unsigned integer as VisXpert integer, once read on request, then update by PLC
  • #(0r)DB 121.DBB 58 TD 32 -> 32 bytes as data block, read only, update only by PLC
Print Friendly, PDF & Email