Difference between revisions of "OPCServer:Variable Syntax"
(→Common Syntax for S5 and S7:) |
|||
(4 intermediate revisions by one other user not shown) | |||
Line 7: | Line 7: | ||
− | Addressing of variables with absolute addresses in the '''''IBH OPC Server''''' is done by using the | + | Addressing of variables with absolute addresses in the '''''IBH OPC Server''''' is done by using the Simatic Step7 or Simatic Step5 syntax. Please note that REAL values (Double Word Format ) in S7 must be declared symbolic in order to have the correct format information. If this is not the case, the SCADA application must do the conversion of the "Long variable in the REAL format" into the correct "REAL format". |
Line 13: | Line 13: | ||
* Symbolic from the PLC project (Variables are selected via the '''''IBH OPCEditor''''') | * Symbolic from the PLC project (Variables are selected via the '''''IBH OPCEditor''''') | ||
− | * | + | * SIMATIC S7 notation |
− | * | + | * SIMATIC S5 notation |
Line 140: | Line 140: | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DWn,nr</td> | <td align="left">DWn,nr</td> | ||
− | <td align="left">Dataword, DB | + | <td align="left">Dataword, DB (1)</td> |
<td align="left">Unsigned Word (VT_UI2)</td> | <td align="left">Unsigned Word (VT_UI2)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DSn,nr</td> | <td align="left">DSn,nr</td> | ||
− | <td align="left">Dataword, DB | + | <td align="left">Dataword, DB (1)</td> |
<td align="left">Signed short Integer (VT_I2)</td> | <td align="left">Signed short Integer (VT_I2)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DDn,nr</td> | <td align="left">DDn,nr</td> | ||
− | <td align="left">Datadoubleword, DB | + | <td align="left">Datadoubleword, DB (1)</td> |
<td align="left">Unsigned DWord (VT_UI4)</td> | <td align="left">Unsigned DWord (VT_UI4)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DVn,nr</td> | <td align="left">DVn,nr</td> | ||
− | <td align="left">Datadoubleword, DB | + | <td align="left">Datadoubleword, DB (1)</td> |
<td align="left">Signed long integer (VT_I4)</td> | <td align="left">Signed long integer (VT_I4)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DFn,nr</td> | <td align="left">DFn,nr</td> | ||
− | <td align="left">Datadoubleword, DB | + | <td align="left">Datadoubleword, DB (1)</td> |
<td align="left">Float (VT_R4)</td> | <td align="left">Float (VT_R4)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DTn,nr[Stringlength]</td> | <td align="left">DTn,nr[Stringlength]</td> | ||
− | <td align="left">Text from a datablock | + | <td align="left">Text from a datablock (3)</td> |
<td align="left">Character Array (VT_BSTR)</td> | <td align="left">Character Array (VT_BSTR)</td> | ||
</tr> | </tr> | ||
Line 185: | Line 185: | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DXWn,nr</td> | <td align="left">DXWn,nr</td> | ||
− | <td align="left">Dataword, DX | + | <td align="left">Dataword, DX (1)</td> |
<td align="left">Unsigned Word (VT_UI2)</td> | <td align="left">Unsigned Word (VT_UI2)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DXSn,nr</td> | <td align="left">DXSn,nr</td> | ||
− | <td align="left">Dataword, DX | + | <td align="left">Dataword, DX (1)</td> |
<td align="left">Signed short Integer (VT_I2)</td> | <td align="left">Signed short Integer (VT_I2)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DXDn,nr</td> | <td align="left">DXDn,nr</td> | ||
− | <td align="left">Datadoubleword, DX | + | <td align="left">Datadoubleword, DX (1)</td> |
<td align="left">Unsigned DWord (VT_UI4)</td> | <td align="left">Unsigned DWord (VT_UI4)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DXVn,nr</td> | <td align="left">DXVn,nr</td> | ||
− | <td align="left">Datadoubleword, DX | + | <td align="left">Datadoubleword, DX (1)</td> |
<td align="left">Signed long integer (VT_I4)</td> | <td align="left">Signed long integer (VT_I4)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DXFn,nr</td> | <td align="left">DXFn,nr</td> | ||
− | <td align="left">Datadoubleword, DX | + | <td align="left">Datadoubleword, DX (1)</td> |
<td align="left">Float (VT_R4)</td> | <td align="left">Float (VT_R4)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DXTn,nr[Stringlength]</td> | <td align="left">DXTn,nr[Stringlength]</td> | ||
− | <td align="left">Text from a DX datablock | + | <td align="left">Text from a DX datablock (3)</td> |
<td align="left">Character Array (VT_BSTR</td> | <td align="left">Character Array (VT_BSTR</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">Sn.n</td> | <td align="left">Sn.n</td> | ||
− | <td align="left">S-Flagbits | + | <td align="left">S-Flagbits (2)</td> |
<td align="left">Bool (VT_BOOL)</td> | <td align="left">Bool (VT_BOOL)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">SYn</td> | <td align="left">SYn</td> | ||
− | <td align="left">S-Flagbytes | + | <td align="left">S-Flagbytes (1)</td> |
<td align="left">Unsigned Byte (VT_UI1)</td> | <td align="left">Unsigned Byte (VT_UI1)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">SWn</td> | <td align="left">SWn</td> | ||
− | <td align="left">S-Flagwords | + | <td align="left">S-Flagwords (1)</td> |
<td align="left">Unsigned Word (VT_UI2)</td> | <td align="left">Unsigned Word (VT_UI2)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">SSn</td> | <td align="left">SSn</td> | ||
− | <td align="left">S-Flagwords | + | <td align="left">S-Flagwords (1)</td> |
<td align="left">Signed short Integer (VT_I2)</td> | <td align="left">Signed short Integer (VT_I2)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">SDn</td> | <td align="left">SDn</td> | ||
− | <td align="left">S-Flagdoublewords | + | <td align="left">S-Flagdoublewords (1)</td> |
<td align="left">Unsigned DWord (VT_UI4)</td> | <td align="left">Unsigned DWord (VT_UI4)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">SVn</td> | <td align="left">SVn</td> | ||
− | <td align="left">S-Flagdoublewords | + | <td align="left">S-Flagdoublewords (1)</td> |
<td align="left">Signed long integer (VT_I4</td> | <td align="left">Signed long integer (VT_I4</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">SFn</td> | <td align="left">SFn</td> | ||
− | <td align="left">S-Flagdoublewords | + | <td align="left">S-Flagdoublewords (1)</td> |
<td align="left">Float (VT_R4)</td> | <td align="left">Float (VT_R4)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">STn[Stringlength]</td> | <td align="left">STn[Stringlength]</td> | ||
− | <td align="left">Text from the extended flag area | + | <td align="left">Text from the extended flag area (3)</td> |
<td align="left">Character Array (VT_BSTR</td> | <td align="left">Character Array (VT_BSTR</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
− | |||
− | |||
− | |||
== Syntax for S7: == | == Syntax for S7: == | ||
Line 269: | Line 266: | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DBn.DBXn.n</td> | <td align="left">DBn.DBXn.n</td> | ||
− | <td align="left">DB, Databits | + | <td align="left">DB, Databits (2)</td> |
<td align="left">Bool (VT_BOOL)</td> | <td align="left">Bool (VT_BOOL)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DBn.DBBn</td> | <td align="left">DBn.DBBn</td> | ||
− | <td align="left">DB, Databyte | + | <td align="left">DB, Databyte (1)</td> |
<td align="left">Unsigned Byte (VT_UI1)</td> | <td align="left">Unsigned Byte (VT_UI1)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DBn.DBCn</td> | <td align="left">DBn.DBCn</td> | ||
− | <td align="left">DB, Databyte | + | <td align="left">DB, Databyte (1)</td> |
<td align="left">Signed Byte (VT_I1)</td> | <td align="left">Signed Byte (VT_I1)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DBn.DBWn</td> | <td align="left">DBn.DBWn</td> | ||
− | <td align="left">DB, Dataword | + | <td align="left">DB, Dataword (1)</td> |
<td align="left">Unsigned Word (VT_UI2)</td> | <td align="left">Unsigned Word (VT_UI2)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DBn.DBSn</td> | <td align="left">DBn.DBSn</td> | ||
− | <td align="left">DB, Dataword | + | <td align="left">DB, Dataword (1)</td> |
<td align="left">Signed Word (VT_I2)</td> | <td align="left">Signed Word (VT_I2)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DBn.DBDn</td> | <td align="left">DBn.DBDn</td> | ||
− | <td align="left">DB, Datadoubleword | + | <td align="left">DB, Datadoubleword (1)</td> |
<td align="left">Unsigned DWord (VT_UI4)</td> | <td align="left">Unsigned DWord (VT_UI4)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DBn.DBVn</td> | <td align="left">DBn.DBVn</td> | ||
− | <td align="left">DB, Datadoubleword | + | <td align="left">DB, Datadoubleword (1)</td> |
<td align="left">Signed DWord (VT_I4</td> | <td align="left">Signed DWord (VT_I4</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DBn.DBRn</td> | <td align="left">DBn.DBRn</td> | ||
− | <td align="left">DB, Real | + | <td align="left">DB, Real (1)</td> |
<td align="left">Real (VT_R4)</td> | <td align="left">Real (VT_R4)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DBn.DBLn</td> | <td align="left">DBn.DBLn</td> | ||
− | <td align="left">DB, LongLong (64 Bit) | + | <td align="left">DB, LongLong (64 Bit) (1)</td> |
<td align="left">LONGLONG (VT_I8)</td> | <td align="left">LONGLONG (VT_I8)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DBn.DBUn</td> | <td align="left">DBn.DBUn</td> | ||
− | <td align="left">DB, ULongLong (64 Bit) | + | <td align="left">DB, ULongLong (64 Bit) (1)</td> |
<td align="left">ULONGLONG (VT_UI8)</td> | <td align="left">ULONGLONG (VT_UI8)</td> | ||
</tr> | </tr> | ||
<tr class="even"> | <tr class="even"> | ||
<td align="left">DBn.DBZn</td> | <td align="left">DBn.DBZn</td> | ||
− | <td align="left">DB, S7 - DATE_AND_TIME | + | <td align="left">DB, S7 - DATE_AND_TIME (1)</td> |
<td align="left">Date (VT_DATE)</td> | <td align="left">Date (VT_DATE)</td> | ||
</tr> | </tr> | ||
<tr class="odd"> | <tr class="odd"> | ||
<td align="left">DBn.DBTn[Stringlength]</td> | <td align="left">DBn.DBTn[Stringlength]</td> | ||
− | <td align="left">Text from a datablock | + | <td align="left">Text from a datablock (3)</td> |
<td align="left">Character Array (VT_BSTR)</td> | <td align="left">Character Array (VT_BSTR)</td> | ||
</tr> | </tr> | ||
Line 340: | Line 337: | ||
The 'signed' datatypes also exist for the S7. Normally, we assume that the type will be set via the configuration tool '''''IBH OPCEditor'''''. | The 'signed' datatypes also exist for the S7. Normally, we assume that the type will be set via the configuration tool '''''IBH OPCEditor'''''. | ||
− | |||
Latest revision as of 13:30, 19 September 2013
Contents
Variable Syntax
One of the special features of the IBH OPC Server is to allow direct use of the absolute PLC Variables without declaration. It is also possible to use symbolic addressing as defined in the PLC program (Symbolic Table). Even variables used in S7 Data Blocks can be accessed via the IBH OPC Server with their symbolic names. These features eliminate the need of double declarations.
To do so, the PLC program is assigned with the IBH OPCEditor to the PLCName and the required variables are selected within the user interface.
Addressing of variables with absolute addresses in the IBH OPC Server is done by using the Simatic Step7 or Simatic Step5 syntax. Please note that REAL values (Double Word Format ) in S7 must be declared symbolic in order to have the correct format information. If this is not the case, the SCADA application must do the conversion of the "Long variable in the REAL format" into the correct "REAL format".
The IBH OPC Server supports 3 notations for variables.
- Symbolic from the PLC project (Variables are selected via the IBH OPCEditor)
- SIMATIC S7 notation
- SIMATIC S5 notation
When using absolute addresses from the OPC client, also a mixed S5/S7 notation is possible.
The syntax is always PLCName.VariableName respectively PLCName.DataBlockName.StructureElement.VariableName. A Variable must always begin with the PLCName. If the variables have been selected individually via the IBH OPCEditor, the variables can be conviniently browsed from the OPC client.
The configuration of the PLC itself must always be done via the IBH OPCEditor, regardless whether absolute or symbolic addressing is to be used. A shortcut to the IBH OPCEditor is installed on your PC.
Common Syntax for S5 and S7:
Operand | Bereich | Datentyp |
En.n | Inputbits (2) | Bool (VT_BOOL) |
EBn | Inputbytes (1) | Unsigned Byte (VT_UI1) |
EWn | Inputwords (1) | Unsigned Word (VT_UI2) |
EDn | Inputdoublewords (1) | Unsigned DWord (VT_UI4) |
ETn[Stringlength] | Text from the input area (3) | Character Array (VT_BSTR) |
An.n | Outputbits (2) | Bool (VT_BOOL) |
ABn | Outputbytes (1) | Unsigned Byte (VT_UI1) |
AWn | Outputwords (1) | Unsigned Word (VT_UI2) |
ADn | Outputdoublewords (1) | Unsigned DWord (VT_UI4) |
ATn[Stringlength] | Text from the output area (3) | Character Array (VT_BSTR) |
Mn.n | Flagbits (2) | Bool (VT_BOOL) |
MBn | Flagbytes (1) | Unsigned Byte (VT_UI1) |
MWn | Flagwords (1) | Unsigned Word (VT_UI2) |
MDn | Flagdoublewords (1) | Unsigned DWord (VT_UI4) |
MTn[Stringlength] | Text from the flag area (3) | Character Array (VT_BSTR) |
Syntax for S5:
Operand | Bereich | Datentyp |
Dn.n,nr | Databits, DB | Bool (VT_BOOL) |
DRn,nr | Right Databyte, DB | Unsigned Byte (VT_UI1) |
DLn,nr | Left Databyte, DB | Unsigned Byte (VT_UI1) |
DWn,nr | Dataword, DB (1) | Unsigned Word (VT_UI2) |
DSn,nr | Dataword, DB (1) | Signed short Integer (VT_I2) |
DDn,nr | Datadoubleword, DB (1) | Unsigned DWord (VT_UI4) |
DVn,nr | Datadoubleword, DB (1) | Signed long integer (VT_I4) |
DFn,nr | Datadoubleword, DB (1) | Float (VT_R4) |
DTn,nr[Stringlength] | Text from a datablock (3) | Character Array (VT_BSTR) |
DXn.n,nr | Databits, DX | Bool (VT_BOOL) |
DXRn,nr | Right Databyte, DX | Unsigned Byte (VT_UI1) |
DXLn,nr | Left Databyte, DX | Unsigned Byte (VT_UI1) |
DXWn,nr | Dataword, DX (1) | Unsigned Word (VT_UI2) |
DXSn,nr | Dataword, DX (1) | Signed short Integer (VT_I2) |
DXDn,nr | Datadoubleword, DX (1) | Unsigned DWord (VT_UI4) |
DXVn,nr | Datadoubleword, DX (1) | Signed long integer (VT_I4) |
DXFn,nr | Datadoubleword, DX (1) | Float (VT_R4) |
DXTn,nr[Stringlength] | Text from a DX datablock (3) | Character Array (VT_BSTR |
Sn.n | S-Flagbits (2) | Bool (VT_BOOL) |
SYn | S-Flagbytes (1) | Unsigned Byte (VT_UI1) |
SWn | S-Flagwords (1) | Unsigned Word (VT_UI2) |
SSn | S-Flagwords (1) | Signed short Integer (VT_I2) |
SDn | S-Flagdoublewords (1) | Unsigned DWord (VT_UI4) |
SVn | S-Flagdoublewords (1) | Signed long integer (VT_I4 |
SFn | S-Flagdoublewords (1) | Float (VT_R4) |
STn[Stringlength] | Text from the extended flag area (3) | Character Array (VT_BSTR |
Syntax for S7:
Operand | Bereich | Datentyp |
DBn.DBXn.n | DB, Databits (2) | Bool (VT_BOOL) |
DBn.DBBn | DB, Databyte (1) | Unsigned Byte (VT_UI1) |
DBn.DBCn | DB, Databyte (1) | Signed Byte (VT_I1) |
DBn.DBWn | DB, Dataword (1) | Unsigned Word (VT_UI2) |
DBn.DBSn | DB, Dataword (1) | Signed Word (VT_I2) |
DBn.DBDn | DB, Datadoubleword (1) | Unsigned DWord (VT_UI4) |
DBn.DBVn | DB, Datadoubleword (1) | Signed DWord (VT_I4 |
DBn.DBRn | DB, Real (1) | Real (VT_R4) |
DBn.DBLn | DB, LongLong (64 Bit) (1) | LONGLONG (VT_I8) |
DBn.DBUn | DB, ULongLong (64 Bit) (1) | ULONGLONG (VT_UI8) |
DBn.DBZn | DB, S7 - DATE_AND_TIME (1) | Date (VT_DATE) |
DBn.DBTn[Stringlength] | Text from a datablock (3) | Character Array (VT_BSTR) |
1) For these operands the suffix [Count] may be added to read/write arrays. Example: PLCName.DB10.DBB2[5] reads 5 bytes starting from DBB2. PLCName.MW4[7] reads 7 Words starting from the MW4.
2) For bit operands also the suffix [Count] may be added to read/write arrays. Arrays of boolean must always start with Bit 0 within the byte. Example: PLCName.DB10.DBX2.0[5] reads 5 Bits starting from DBX2.0. PLCName.M4.0[7] reads 7 Bits starting from M4.0. A variable like PLCName.M4.3[4] is not permitted. When writing boolean arrays, always the entire byte is written.
3) If strings are entered in absolute notation, there is no verification whether it is a declared string. In S7 PLCs, strings have 2 leading bytes with additional information regarding the string, the declared length and the current length. Since this information lacks in absolute notation, strings are treated as pure character arrays of the length entered in [Stringlength]. If in a write operation the text is shorter as the length enterd in [Stringlength], the rest is filled up with zeroes.
The 'signed' datatypes also exist for the S7. Normally, we assume that the type will be set via the configuration tool IBH OPCEditor.
Addressing the DB of a S7-200:
The syntax for the 200 equals the S7-300 syntax. To access a variable byte of the data block in S7-300 syntax you need to type: VB 2 (S7-200) = DB1.DBB2 (S7-300). The data block is always the DB1. A variable word VW 2 (S7-200) = DB1.DBW2 (S7-300). A variable doubleword VD 2 (S7-200) = DB1.DBD2 (S7-300).