Sample program 2
Reading and interpreting time telegrams
This example shows a way to process and interpret the most diverse serial time protocols in the PLC. To this end, IEC61131-PLC blocks will be presented that interpret the bit stream arriving at the PLC and, if necessary, extract the time/place information. This information can be used, for example, to synchronize controllers or record movements.
In this example, it is assumed that the data is delivered via a 22-byte interface by a Beckhoff EL/KL60xx serial data exchange terminal.
Background information
Not only in maritime applications is time and place information transported via serial buses: In the majority of cases an existing source distributes its information to lower level listeners/listeners cyclically or after a trigger via RS232 / RS485, USB or Ethernet.
A very large number of telegram formats exists worldwide for the distribution of time and place information; these are also known as ‘sentences’. Such a telegram consists of n bytes of data and is characterized by:
- Start and end characters STX, ETX for telegram recognition, possibly more than one end character
- a defined and fixed length
- a defined structure
- checksum (not necessary)
- type designations in the sentence if necessary
The most diverse organizations and companies have developed open or proprietary formats for specific purposes of use. Therefore, two sample implementations will be presented in this example that can easily be adapted to other specific protocols. The telegram formats in the example are the Meinberg Standard and NMEA0183 v2.3 type RMC.
Sources of information
GPS or radio controlled clock gateways are used as data transmitters in the serial sector. These devices receive the respective time signal (GPS via satellite or radio controlled clock via long wave) and convert it to the serial, wire-bound transmission e.g. RS232 with 8N1. The gateway often contains a local clock source in order to be able to continue distributing reliable time information for a certain time in the event of a short-term failure of the reference signal (GPS, radio transmitter). In Central Europe, the German DCF77 transmitter can be used.
If necessary, further information from the reference signal can be used:
- GPS: location information (W/N and height), upcoming clock change DCF77: weather information, major incidents
- DCF77: weather information, major incidents
Synchronization of lower level time slaves
In general, lower level slaves should be adjusted to the time gateway, i.e. they should synchronize their time. The following are necessary for this:
- Offset: the absolute deviation of the slave’s own clock from the gateway reference time – this information can be transmitted, for example, acyclically and serially if it is known when the time information is to be considered valid. Gaining these offset-information is possible via the serial transport route from this example.
- the frequency ratio: a high-precision cyclic signal from the gateway to the slaves allows drift processes to be compensated and might state the time when the above absolute offset is valid. One example of such a signal is the widespread PPS (pulses per second).
If the serial telegram from the gateway is placed cyclically to the bus, the time of the first bit can often be interpreted as a PPS signal. In the block in this example, this information would be lost; only the absolute time information is evaluated.
Time formats
Time telegrams conforming to the NMEA0183 standard are widespread. Please note:
- there are currently (as of 2009) 8 versions of NMEA0183 1.5 to 4.00 within the NMEA0183 standard – the structure of telegrams may have changed between the versions.
- 70 different formats are defined in NMEA0183 v2.30 alone; device manufacturers can create their own formats in addition.
- The telegram is called a sentence
- A TalkerID (2 characters) and a TypeID (3 characters) at the start define the type of sentence used.
- A checksum is calculated for the telegram.
- Information can be found online at www.nmea.org or elsewhere.
Furthermore, many proprietary formats exist, such as Meinberg Standard, Siemens SINEC H1 and SAT 1703, or military formats, such as the IRIG codes (USA).
Using the sample program
The PLC project contains 2 function blocks (FBs), which must be linked exclusively with an EL/KL600x. Then collect the received bytes from the terminal and interpret the contents as far as possible. The FBs cover:
- Meinberg Standard
- NMEA0183 v2.3 type RMC
For other time formats, you can create your own interpretation FBs on the basis of a known telegram structure; contact your device manufacturer regarding this.
Hardware used in the example: EK1100 and EL6001 (also EL600x, KL600x)
The FB to be tested must be linked with its process data to the terminal in the System Manager (22-byte process image and control/status word).
The NMEA block is linked in the example. The baud rate of the terminal must be set to match your transmitter.
References
- www.beuth.de, IEC61162: based on NMEA2000
- http://gpsinformation.net private, via NMEA, many formats: http://www.gpsinformation.org/dale/nmea.htm
http://www.nmea.de/nmea0183datensaetze.html - http://www.meinberg.de/german/info/irig.htm, IRIG codes