Integration Thies weather station
This manual shows the integration of a Thies weather station Compact WSC11, 4.9056.10.000, using the template "FB_BA_Weatherstation_Thies".
Required hardware:
- Thies Weather Station Compact WSC11, 4.9056.10.000 (ASCII format)
- KL6041, preconfigured to 22 bytes process image
Required additional library:
- Tc2_SerialCom
Adding the template:
- Click on the desired PLC project (1).
- 1. In the template repository, right-click on the template FB_BA_WeatherStation_Thies (2)
- 2. Add the template (3) and (4).
- 3. The following dialog with the list of additionally implemented function blocks opens. Close the dialog with OK.
- 4. All new PLC function blocks are now dragged into a folder Templates and can be distributed in the project if required.
- In the standard PLC project a weather station template FB_BA_Weatherstation_Draft is already included, which contains all necessary display objects and is intended for individual linking.
Adding a fast task for serial communication
The serial terminal (KL6041) is configured to the following communication parameters during a PLC restart:
- Baud rate: 9600
- Data bits: 8
- Parity: none
- Stop bits: 1
- Handshake: RS485 HALFDUPLEX
The process image must be set to 22 bytes beforehand.
After that the actual communication between terminal and weather station starts.
The function blocks required for this are available in the Tc2_SerialCom library and are called in the "FastCycle" method of the "FB_BA_Weatherstation_Thies" template. This call must be assigned to a faster task than the normal PLC cycle task.
- 1. Right-click POU to open the new window, select add (1) and POU (2).
- 2. A window opens. Enter the name there (example MAIN_fast) (3). The POU type is a program in structured text (ST).
- In this program, the method FastCycle is now called.
- 3. Add a new item (2) by right-clicking on Tasks (1). Name it with a meaningful name, for example FastTask (3).
- This new task must now be set to a small cycle time. The 5 ms shown here are a recommendation
- A task reference must be created so that this task is available to the program part:
- 4. Right-click on the project (1), select add (2) then taskreference (3). A window opens. There, select the Task to which the reference should refer (4).
- The task reference now appears in the PLC part below. The function block that is to be called in this task can now be assigned to it.
- 5. Open a dialog by right-clicking on the task Fast Task(1), select add (2) and then existing item (3).
- A window will open where you can select the call program.
Adding the serial communication library
Dragging in the template "FB_BA_WeatherStation_Thies" does not automatically add the required serial communication library. This must be inserted manually:
Right-click on "References" (1) and select "Add Library" (2). In the window that opens, select the "Tc2_SerialCom" library (3) and confirm with "OK" (4).
Creating program links
The link variables for the process image of the serial terminal are located in the "FB_BA_WeatherStation_Thies" template. However, just because of the implementation of the template, they are not automatically available for linking. To do this, the solution must be rebuilt once.
It is important at this point that no other compilation errors occur in the program.
Under "Build", select "Rebuild Solution". At this point, only the already existing PLC task has a process image.
After an error-free creation, the link variables of the template are available and the Fast Task also holds a process image area.
First, all input variables of the terminal process image are marked (click on status and then press the arrow down key while holding down the shift key) (1), then right-click and select "Multi-link" (2). Link to "stRawDataIn" of the template.
The linking of the output data is done analogously.