Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


Elsner P02-RS485 / P03-RS485 Weather Station communication example - Overview

Beckhoff Knowledge Base: Communication with Weather Station P02-RS485 / P03-RS485 from Elsner Elektronik GmbH

Introduction

This Beckhoff Knowledge Base article describes application examples between TwinCAT and the Elsner Elektronik weather station P02-RS485 respectively P03-RS485 (www.Elsner-Elektronik.de).
It only shows the basic functionalities necessary when integrating the weather station into own TwinCAT applications.

The weather station P02-RS485 uses the same communication protocol as the P03/1-RS485 or P03/3-RS485. Therefore, these weather stations are compatible to each other from the communication standpoint. The difference between the P03/1-RS485 and P03/3-RS485 is the number of available brightness sensors. The P03/3-RS485 uses 3 sensors (South, East and West). Instead, the P03/1-RS485 only contains 1 brightness sensor.

The named weather stations sense the following weather conditions: Outdoor Temperature, Brightness, Wind Speed and Rainfall. In addition, a DCF-77 receiver is integrated in the housing. All data gets transferred via RS485 protocol. This data stream can be received and evaluated with a terminal device (i.e. a PLC). The actual data gets transferred every second from the weather station. If the weather station doesn't detect a valid DCF-77 signal, the data gets transferred approximately every 1.35 sec. In case the receiving control unit is speed capacity-wise a little undersized, Elsner Elektronik also offers a version which transfers the data only every 3 seconds.

Requirements

  • Microsoft Windows with TwinCAT level PLC or higher (>= v 2.10) for programming and startup purposes
  • TwinCAT PLC Serial Communication Library
  • Typical setup like BK/BC fieldbus node (i.e. BK9100) + KL6041 and KL9010 or Embedded-PC (i.e. CX9000) with N031 interface (RS485)
  • Programming knowledge in IEC 61131-3 under TwinCAT
  • P02-RS485, P03/1-RS485 or P03/3-RS485 weather station from Elsner Elektronik GmbH

Overview

Application examples | Remarks
Application example 1: Elsner P02-RS485 / P03-RS485 communicates with KL6041 |
Application example 2: Elsner P02-RS485 / P03-RS485 communicates with CXxxxxx-N031 |
Protocol description Elsner P02-RS485 / P03-RS485 |


Connection of Elsner P02-RS485 / P03-RS485 Weather Station to KL6041

Connection of Elsner Weather Station to KL6041

The Elsner P02-RS485 respecitively P03-RS485 comes with four terminals on the connection block. For data transmission terminal (A) and (B )are used. The terminals (1) and (2 )are used for supplying power (24V DC) to the device. These terminals (1) and (2 )are not secured against reverse polarity connection. In case a reverse polarity connection happens, the RS485 communication driver IC gets destroyed! See www.Elsner-Elektronik.de for further information.

Note: Please follow the manufacturer's installation manual in any case of uncertainty!

In case a switching power supply unit is considered for powering the Elsner P02/P03 wheather station, the detection capabilities of the built-in DCF-77 receiver might be limited. There is the possibility of a radio signal interruption for a longer period of time. Therefore, please use the received time data only for synchronization purposes to the in parallel existing system time on your controller. For this synchronization, 'Second 0' should be used.

Please connect the weather station to a KL6041 as follows:

KL6041 connection point (1) and (2) [ Data +] as well as connection point (5) and (6 ) [Data -] have to be interconnected (see diagram on the left).

Settings of KL6041

Please configure the KL6041 to the following parameters (i.e. by using KS2000):

  • 22 Data bytes in process image
  • Half duplex
  • 19200 Baud
  • 8 Data bits
  • No parity
  • 1 Stop bit

Alternatively, you can configure the KL6041 via register communication between PLC and Control/Status bytes of the terminal (see sample program in Knowledge Base).

Example application

For your TwinCAT PLC application, you can use the weather station Function Block and and expressed serial background communication in below linked TcPlc sample project (Zip file):

SampleKL6041.zip


Connection of Elsner P02-RS485 / P03-RS485 Weather Station to CXxxxx-N031

Connection of Elsner Weather Station to N031

The Elsner P02-RS485 respecitively P03-RS485 comes with four terminals on the connection block. For data transmission terminal (A) and (B )are used. The terminals (1) and (2 )are used for supplying power (24V DC) to the device. These terminals (1) and (2 )are not secured against reverse polarity connection. In case a reverse polarity connection happens, the RS485 communication driver IC gets destroyed! See www.Elsner-Elektronik.de for further information.

Note: Please follow the manufacturer's installation manual in any case of uncertainty!

In case a switching power supply unit is considered for powering the Elsner P02/P03 wheather station, the detection capabilities of the built-in DCF-77 receiver might be limited. There is the possibility of a radio signal interruption for a longer period of time. Therefore, please use the received time data only for synchronization purposes to the in parallel existing system time on your controller. For this synchronization, 'Second 0' should be used.

Connection example CXxxxx-N031 (i.e. CX9000, CX9001, CX9010, CX1xxx, ... )

Please connect the weather station to the -N031 interface as follows:

COM interface (female):

Pin-out of D-Sub 9 COM interface:

PIN | Signal
2 | TxD+
3 | RxD+
5 | GND
6 | VCC
7 | TxD-
8 | RxD-

Pin (2) und (3) [ Data +] as well as pin (7) und (8) [Data -] have to be connected inside the DSUB-9 connector.

Configuration of the N031 interface (TwinCAT System Manager)

Please configure the N031 interface with TwinCAT System Manager as follows:

  • 64 data bytes in process image
  • RS485 as RS type (comm mode)
  • 19200 Baud as baudrate
  • 8 Databits
  • Parity = 'None'
  • 1 Stopbit

Example application

For your TwinCAT PLC application, you can use the weather station Function Block and and expressed serial background communication in below linked TcPlc sample project (Zip file):

SampleN031.zip


Protocol of Elsner P02-RS485 / P03-RS485 Weather Station

Communication protocol

All data bytes transmitted by the Elsner P02/P03 weather stations via the RS485 interface have to get interpreted as ASCII characters. That implies that every measurement value internally processed as Integer resp. Float / Real data types, gets separated into single digits plus possible period separators, converted into ASCII characters and then transferred to the controller. The controller then needs to convert those characters reversely to the original Integers and other numerical data types which can be processed by the application. The checksum gets created by adding all received data bytes from one dataset (up to byte 35) and then compared with the transferred checksum.

Byte no. | Description | Remark
1 | 'W' - Start |
2 | Outdoor temperature prefix '-' or '+' |
3 | Outdoor temperature, 1. digit (tenner) |
4 | Outdoor temperature, 2. digit (singles) |
5 | Outdoor temperature, separation period '.' |
6 | Outdoor temperature 3. digit (tenth) | Byte 2 to 6 combined result in a floating point temp. value, measurend in °C. See conversion example for °F.
7 | Brightness South, 1. digit (tenner) |
8 | Brightness South, 2. digit (singles) |
9 | Brightness West, 1. digit (tenner) | Since the P03/1-RS485 only supports 1 brightness sensor, byte 9 is in that case identical to byte 7 ("South, 1. digit")
10 | Brightness West, 2. digit (singles) | Since the P03/1-RS485 only supports 1 brightness sensor, byte 10 is in that case identical to byte 8 ("South, 2. digit")
11 | Brightness East, 1. digit (tenner) | Since the P03/1-RS485 only supports 1 brightness sensor, byte 11 is in that case identical to byte 7 ( "South, 1. digit")
12 | Brightness East, 2. digit (singles) | Since the P03/1-RS485 only supports 1 brightness sensor, byte 12 is in that case identical to byte 8 ("South, 2. digit")
13 | Dusk: 'J' = Yes; 'N' = No |
14 | Daylight, 1. digit (hundreds) |
15 | Daylight, 2. digit (tenner) |
16 | Daylight, 3. digit (singles) |
17 | Wind speed, 1. digit (tenner) |
18 | Wind speed, 2. digit (singles) |
19 | Wind speed, separation period '.' |
20 | Wind speed, 3. digit (tenth) | Byte 17 to 20 combined, result in a floating point value (measured in m/s). See Beaufort Scale for a reference of wind speed interpretation.
21 | Rain: 'J' = Yes; 'N' = No |
22 | Day of week: 1 = Monday, 7 = Sunday, '?' = not defined |
23 | Date, DAY, 1. digit (tenner) |
24 | Date, DAY, 2. digit (singles) |
25 | Date, MONTH, 1. digit (tenner) |
26 | Date, MONTH, 2. digit (singles) |
27 | Date, YEAR, 1. digit (tenner) |
28 | Date, YEAR, 2. digit (singles) |
29 | Time, HOUR, 1. digit (tenner) |
30 | Time, HOUR, 2. digit (singles) |
31 | Time, MINUTE, 1. digit (tenner) |
32 | Time, MINUTE, 2. digit (singles) |
33 | Time, SECOND, 1. digit (tenner) |
34 | Time, SECOND, 2. digit (singles) |
35 | Daylight saving time: 'J' = Summer, 'N' = Winter, '?' = not defined | Daylight saving time determination based on time zone GMT+1
36 | Checksum, 1. digit (singles) |
37 | Checksum, 2. digit (tenner) |
38 | Checksum, 3. digit (hundreds) |
39 | Checksum, 4. digit (thousands) |
40 | Delimiter 0x03 |

Hint: For further information about the RS485 protocol at these weather stations, see: www.Elsner-Elektronik.de.


Beaufort Scale

The Beaufort Scale is an empirical measure for describing wind speed based mainly on observed sea conditions. Its full name is the Beaufort wind force scale.
There is also an equivalent to observed land conditions, which are more viable for the determination of the conditions in home weather station environments. These land conditions are listed below.

.

Beaufort No. | Wind speed (in m/s) | Description | Land conditions
0 | > 0.3 | Calm | Calm. Smoke rises vertically.
1 | 0.3 - 1.5 | Light air | Wind motion visible in smoke.
2 | 1.5 - 3.3 | Light breeze | Wind felt on exposed skin. Leaves rustle.
3 | 3.3 - 5.5 | Gentle breeze | Leaves and smaller twigs in constant motion.
4 | 5.5 - 8.0 | Moderate breeze | Dust and loose paper raised. Small branches begin to move.
5 | 8.0 - 10.8 | Fresh breeze | Branches of a moderate size move. Small trees begin to sway.
6 | 10.8 - 13.9 | Strong breeze | Large branches in motion.
7 | 13.9 - 17.2 | High wind, Moderate Gale | Whole trees in motion. Effort needed to walk against the wind.
8 | 17.2 - 20.7 | Fresh Gale | Twigs broken from trees.
9 | 20.7 - 24.5 | Strong Gale | Larger branches break off trees, and some small trees blow over.
10 | 24.5 - 28.4 | Whole Gale/Storm | Trees are broken off or uprooted, saplings bent and deformed. Shingles in poor condition peel off roofs.
11 | 28.4 - 32.6 | Violent storm | Widespread vegetation damage. More damage to most roofing surfaces.
12 | >= 32.6 | Hurricane-force | Considerable and widespread damage to vegetation, a few windows broken, structural damages to poorly constructed sheds and barns.

For further information about wind speed definitions in reference to "New Beaufort Scale", see http://en.wikipedia.org/wiki/Beaufort_Scale.


FUNCTION F_DEG_CELSIUS_TO_FAHRENHEIT (Example)

FUNCTION F_DEG_CELSIUS_TO_FAHRENHEIT (*Example*)

This little example shows a solution for the re-occuring task of converting temperatures measured in degrees Celsius into temperatures displayed in degrees Fahrenheit. The function header declaration only consists of the function name, it's return data type and the input variable for the degrees Celsius value.

FUNCTION F_DEG_CELSIUS_TO_FAHRENHEIT : REAL
VAR_INPUT
    rCelsius : REAL; (* °C *)
END_VAR

Example Code (ST)

The only code necessary for this is the one line shown as Structured Text example below:

F_DEG_CELSIUS_TO_FAHRENHEIT := rCelsius * 1.8 + 32;