Communication - Bernecker & Rainer PLC

How is it possible to communicate with Bernecker & Rainer PLCs? One option is to use the built-in B&R OPC UA server, which is found in newer PLC types. But in the case of fast events, there is a problem. The B&R OPC UA Server is limited to a 50 millisecond "Publishing Interval".

If we set a smaller value of the "Requested Publishing Interval" parameter in the OPC UA protocol, the B&R OPC UA Server will increase it to 50 milliseconds when establishing a connection. This means that it will report changes in object values only with such periodicity.
In addition, older B&R PLCs do not yet contain B&R OPC UA. So - how about them?
The solution is to use the PVI (Process Visualization Interface) communication interface. It can be used to communicate with B&R control units.
Therefore, we implemented the B&R PVI Interface protocol in the D2000, which accesses the PVI using the PVICOM interface.
PVICOM interface is delivered in the form of an installation package with a size from 45 to 60 MB depending on the version - we used and tested the following versions:

  • Automation Net PVI V4.0.exe
  • Automation Net PVI V4.2.exe
  • Automation Net PVI V4.7.exe

After installation, the PVICOM interface services published through the functions contained in the PviCom.dll dynamic-link library (or PviCom64.dll for 64-bit programs) are used.
PVI is not limited to just one protocol, but supports the whole set (several of the protocols are proprietary and the use of PVI is the recommended way to use them):

  • ANSL (Automation Network Service Link) protocol – communication with SG4 series PLCs via Ethernet using TCP connection
  • INA2000 (Industrial Network Architecture) – communication with the SG3, SGC and SG4 series PLCs via Ethernet using UDP packets
  • NET2000 – communication with the SG3 and SG4 series PLCs using the NET2000 protocol
  • DCAN – communication with devices via CAN bus
  • SNMP – communication with SG4 series PLCs using SNMP protocol and mapping of SNMP variables to PVI variables
  • ADI - communication with B&R industrial PCs (Automation PC, Mobile Panel, Panel PC and Power Panel series) - e.g. LED control, brightness adjustment, CMOS status of battery, fans, etc.
  • Modbus – communication with Modbus TCP client
  • MININET – communication with B&R PLC series MULTI/MIDI/MINI and compact (SG2) using MININET protocol

The PVI interface defines a hierarchy of objects (Line, Device, Station, CPU, Module, Task, Variable). Each of these protocols uses some of them. For the INA2000 protocol, the situation is as follows:

Figure 1 - Object hierarchy for INA2000 protocol.

The hierarchy is similar for the NET2000 line, the Module object is not used and the Station object is used instead of the CPU:

Figure 2 - Object hierarchy for the NET2000 protocol.

How to map this hierarchy to D2000 line - station – I/O tag hierarchy?
The configuration of the Line and Device objects concerns the parameters of the line and the device that is used to access it (e.g. the serial port is specified). Therefore, we placed the configuration of these two types of objects at the level of the D2000 line protocol parameters:

Figure 3 - B&R PVI Interface protocol parameters at the line level.

The configuration of Station, CPU, Module and Task objects is similar in the station protocol parameters.

Figure 4 - B&R PVI Interface protocol parameters at the station level.

The last type of object - Variable - corresponds to the I/O tag. The address of the I/O tag is therefore text, it is in the form
Parameter1 = value1 [Parameter2 = value2] ...
similar to protocol parameters defining Line, Device, Station, CPU, Module, and Task objects.

All details are described in the protocol documentation, but a few indicative information is enough for a standard user. Specifically:

  • Mandatory parameters are CD=variable_name and VT=typ_hodnoty.
  • For strings with a single-byte character representation (VT=string) as well as with a double-byte character representation (VT=wstring), the VL=element_length parameter specifying the string size in bytes, including the trailing zero, is also mandatory. So the variable VT=wstring VL = 12 is 12 bytes long, of which 2 bytes are a trailing zero and the remaining 10 bytes will fit 5 double-byte characters.
  • The parameter VN=number_of_elements is mandatory for arrays of values. This parameter specifies the number of elements in the array we are reading (the number can be equal to or less than the actual number of array elements). If we want to read the whole array using one I/O tag, it is necessary to configure the destination column of a structure, in which the individual elements of the array will be stored. However, if we also need to write to the array items, it is necessary to configure a separate I/O tag for each item.

In reality, however, the situation is even simpler. The B&R PVI Interface protocol supports obtaining a list of Task and Variable objects, so browsing could be implemented! The user thus configures the I/O tag with a few clicks - all he needs to do is know the name of the variable.

Figure 5 - Text I/O tag configuration. Below the address is a browse button.

Browsing returns a list of all global variables as well as a list of local variables for the Task object that is configured in the station parameters. The following figure shows the browsing dialog - the Task column contains the name of the Task (it is empty for global variables). The Variable column contains the name of the variable (the value of the CD parameter). The other parameters of the variable, obtained from PVI, are in the Parameters column. The last column, Point, contains information on whether an I/O tag with such a variable name is already configured.

Figure 6 - B&R PVI Interface protocol browsing dialog.

In the previous figure, the attentive reader will notice the local variables belonging to the Program task, which have names e.g. Controll.cmd.Name, Controll.cmd.Run, Controll.cmd.SetPoint. In fact, these are individual items of the structured variable Control, which contains a nested cmd structure that has the elementary items Name, Run, and SetPoint. Although we cannot work with the whole structured variable at once, we can map individual items (of elementary types) to I/O tags.

And speaking of elementary types - what types of variables exist in the B&R PVI protocol? Our documentation also answers this:

  • "i8", "i16", "i32", "i64": 8 to 64-bit signed integer
  • "u8", "u16", "u32", "u64": 8 to 64-bit unsigned integer
  • "f32", "f64": 32/64-bit floating point
  • "boolean": Flag with element length of 1 byte
  • "string": String with 8-bit character size
  • "wstring": String with 16-bit character size
  • "struct": Structure
  • "time": 32-bit time in ms since midnight
  • "dt": 32-bit date and time in seconds since 1/1/1968
  • "date": 32-bit date
  • "tod". 32-bit time of day
  • "data": General variable type with 1-byte element length

All types are supported except the data type (if necessary, it will be mapped to a text variable in the future).

Conclusion
The B&R PVI Interface protocol will delight our customers and OEM partners who need to communicate with various types of PLCs and industrial PCs manufactured by Bernecker & Rainer. These devices are quite common in Slovakia (and I suppose not only here). So far, we have used other protocols to communicate with them, such as OPC UA and IEC-104. Native support will simplify and speed up their integration into SCADA and MES systems based on D2000 real-time application server technology.