Vous êtes sur la page 1sur 9

How do you use a GPS

receiver to determine
the coordinates and
synchronize the
system time of the S7-
1200, S7-1500 and ET
200SP CPU?
Siemens
CM 1241 RS232, CM PtP RS232, CM PtP Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/45057335 Support
This entry originates from Siemens Industry Online Support. The conditions of use
specified there apply (www.siemens.com/nutzungsbedingungen).

Security Siemens provides products and solutions with industrial security functions that support the
Informati secure operation of plants, systems, machines and networks.
on In order to protect plants, systems, machines and networks against cyber threats, it is
necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial
security concept. Siemens’ products and solutions only form one element of such a
concept.
Customers are responsible to prevent unauthorized access to their plants, systems,
machines and networks. Systems, machines and components should only be connected
to the enterprise network or the internet if and to the extent necessary and with
appropriate security measures (e.g. use of firewalls and network segmentation) in place.
Additionally, Siemens’ guidance on appropriate security measures should be taken into
account. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more
secure. Siemens strongly recommends to apply product updates as soon as available and
to always use the latest product versions. Use of product versions that are no longer
supported, and failure to apply latest updates may increase the customer’s exposure to
cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security
RSS Feed under http://www.siemens.com/industrialsecurity.

Contents
 Siemens AG 2017 All rights reserved

1 Description ..................................................................................................... 3
1.1 Download .......................................................................................... 3
1.2 GPS Receiver.................................................................................... 4
1.2.1 GPS Message ................................................................................... 4
1.2.2 Communication Parameters............................................................... 4
1.3 Hardware Setup................................................................................. 5
1.3.1 Connect RS232 (connector) to CM PtP (ET 200SP) ........................... 5
1.3.2 Hardware Configuration ..................................................................... 6
1.4 Handling the Library........................................................................... 6
1.5 Function Block "GpsReceive"............................................................. 8
1.5.1 Inputs ................................................................................................ 8
1.5.2 Output Variables ................................................................................ 9
1.6 Creation Environment ........................................................................ 9

Receiving GPS frames with S7-1200, S7-1500 and ET 200SP CPU


Entry ID: 45057335, 12.0 , 11/2017 2
1 Description

1 Description
The SIMATIC controllers S7-1200, S7-1500 and ET 200SP can process standard
GPS frames of the RMC data type according to the NMEA-0183 standard. The
GPS receiver captures GPS frames via the RS232 interface of the communication
modules CM1241 RS232, CM PtP RS232 or CM PtP.
The function blocks in the attached library provide the degrees of longitude and
latitude of your current position. In addition, the current UTC time and date in the
"DTL" data type format are output and the system time of the CPU is synchronized.
The function block "GpsReceive" uses the communication instructions "PtP
Communication" V2.3:
Table 1-1
Name Description Version
Port_Config Configure the PtP communication port V1.2
Receive_Config Configure the PtP receiver V1.2
Receive_P2P Receive data V1.5
Receive_Reset Delete receive buffer V1.2

Note More information about the "Point-to-Point" instructions is available in the STEP
7 Professional V14.0 manual.
 Siemens AG 2017 All rights reserved

The "Port_Config" instruction configures the communications port with the


parameters listed in Table 1-4. Further configuration of the communication modules
is not necessary.
The "GpsReceive" function block is processed in one CPU cycle. The program
must further process the current position values as well as the time and date
information for consistency immediately after calling "GpsReceive". More details on
the variables are available in Table 1-8.

1.1 Download
The download consists of the block library and a sample project. Copy each zip file
into a separate folder. Double-click each zip file to open it and unpack it.
After unpacking the library, follow the steps in Table 1-6. You can then use STEP 7
V14.0 Upd2 to open and process the extracted project.
Table 1-2
Contents Description
45057335_S7-1x00_GPS_LIB_V12d0.zip Library
 For CM 1241 RS232 >= V2.1,
 FB " GpsReceive" V1.0
S7-1500 and ET 200SP CPU
 FB " gps_rcv" V12.0  For CM 1241 RS232 < V2.1
45057335_S7-1x00_GPS_PROJ_V12d0.zip Sample project
 S7-1200 with CM 1241 RS232 >=
 PLC_1
V2.1
 PLC_2  S7-1500 with CM PtP RS232 BA
 PLC_3  ET 200SP CPU with CM PtP
 PLC_4  S7-1200 with CM 1241 RS232 < V2.1

Receiving GPS frames with S7-1200, S7-1500 and ET 200SP CPU


Entry ID: 45057335, 12.0 , 11/2017 3
1 Description

1.2 GPS Receiver


1.2.1 GPS Message

The recommended minimum data record C (RMC) of the NMEA-0183 standard is


evaluated to determine the geographical position and UTC time. This is structured
as below.
Table 1-3
Information Contents Remark
Identification of
$GPRMC Beginning of the data record
the data record
"hhmmss" or - used in connection with the date for
UTC time
"hhmmss.sss" synchronization
"A" for OK or "V"
Status - used to assess the validity of the data
for warning
- used for calculating the latitude in
Latitude "ddmm.mmmm"
decimal form
"N" for North or
Direction
"S" for South
- used for calculating the longitude in
Longitude "dddmm.mmmm"
 Siemens AG 2017 All rights reserved

decimal form
"E" for East or
Direction
"W" for West
Velocity - not evaluated in the block
Course
- used in connection with the UTC time
Date "ddmmyy"
for synchronization
Deviation - not evaluated in the block
Signs
only available for NMEA 0183 version
Signal integrity
V2.3
Checksum "*hh" End of the data record
The individual blocks of information are separated by commas (",").

1.2.2 Communication Parameters

The "GpsReceive" function block parameters correspond to a standard GPS


receiver as per the NMEA 0183 standard:
Table 1-4
Parameter Setting
Parity None
Data bits 8 bits per character
Stop bits 1
Flow control None

Receiving GPS frames with S7-1200, S7-1500 and ET 200SP CPU


Entry ID: 45057335, 12.0 , 11/2017 4
1 Description

1.3 Hardware Setup


The "GpsReceive" block was successfully tested with the GPS receivers listed
below:
 GARMIN GPS18x PC (external power supply: 8-30V)

Figure 1-1
S7-1500

ET 200SP
S7-1200
 Siemens AG 2017 All rights reserved

RS232 GPS
L+ M

1.3.1 Connect RS232 (connector) to CM PtP (ET 200SP)

Figure 1-2
TXD Transmit Data
1 3
RXD Receive Data
2 2
3 RTS Request To Send
7
CTS Clear To Send
4 8
DTR Data Terminal Ready
5 4
DSR Data Set Ready
6 6
DCD Data Carrier Detect
7 1
RI Ring Indicator
8 9
PE Ground
9 5

Receiving GPS frames with S7-1200, S7-1500 and ET 200SP CPU


Entry ID: 45057335, 12.0 , 11/2017 5
1 Description

1.3.2 Hardware Configuration

The following example shows the hardware configuration using the S7-1200 as an
example. Proceed correspondingly for the hardware configuration of the S7-1500
and ET 200SP.
Table 1-5
No Instruction
.
1. Connect the GPS receiver to the S7-1200.
Proceed as follows:
1. Equip the S7-1200 with a CM 1241 RS232 communication module.
2. Connect the GPS receiver to the communication module.

Note:
The power supply of your GPS receiver must be from the external power source required in the
description (voltage level and polarity).
2. Add the communication module to the "Device Configuration".
Proceed as follows:
1. Open the project navigation in STEP 7 (TIA Portal).
2. Open the "Device Configuration" of your CPU.
3. Open the "Device View".
4. Open the "Hardware Catalog".
 Siemens AG 2017 All rights reserved

5. Select your communication module "CM 1241 (RS232)".


6. Important for the S7-1200: FB "GpsReceive" functions for CM 1241 RS232 with firmware V2.1
and higher. For the firmware < V2.1 use FB "gps_rcv".
7. Drag the communication module from the "Hardware Catalog" and drop it into the "Device
View".

1 3 4

2 7

1.4 Handling the Library


See sample project in the attached zip file "45057335_S7-
1x00_GPS_PROJ_V12d0.zip".

Receiving GPS frames with S7-1200, S7-1500 and ET 200SP CPU


Entry ID: 45057335, 12.0 , 11/2017 6
1 Description

Table 1-6
No Instruction
.
1. Proceed as follows to download and open the global library "GPS":
1. Load, unpack and open the global library "45057335_GPS_LIB_V12d0.zip".
2. Click the "Open global library" button to open the library.

5 6
 Siemens AG 2017 All rights reserved

2. Proceed as follows to incorporate the function block "GpsReceive".


1. Drag and drop the function block "GpsReceive" into a cyclically called network.
2. Connect the inputs of the function block "GpsReceive" as described in Table 1-7.

Receiving GPS frames with S7-1200, S7-1500 and ET 200SP CPU


Entry ID: 45057335, 12.0 , 11/2017 7
1 Description

1.5 Function Block "GpsReceive"


With a positive edge at the input "cmd_get_time_n_date", the FB "GpsReceive"
reads the RMC message of a GPS receiver connected via RS232. The position is
determined from the message and the UTC time is used to synchronize the CPU
system time. Successful processing is signaled via the output "return_done" for
one cycle.
FB "GpsReceive" waits 20 seconds for receipt of the message before setting the
output "return_aborted" for one cycle.

1.5.1 Inputs

The following table shows the inputs of the GpsReceive function block.
Table 1-7
Connection Data type Remark
cmd_get_ BOOLEAN The evaluation of an RMC-GPS message is triggered by a rising edge.
time_n_date In the sample program, clock marker bits trigger the rising edge.
1. Mark your controller in the "Project Navigation".
2. Right-click to open the "Properties".
3. Select the "System and clock memory" item.
4. Check the option box to enable use of the clock marker byte.
5. Enter an address for the clock marker byte. In this example the
address of the 0.5 Hz marker bit is M0.7.
 Siemens AG 2017 All rights reserved

4
1 5

2
6

cmd_hw_id PORT Here, you enter the hardware ID of the communication module.
You can find the hardware identifier in the "System Constants" under "PLC
tags > Show all tags".

1 3

Receiving GPS frames with S7-1200, S7-1500 and ET 200SP CPU


Entry ID: 45057335, 12.0 , 11/2017 8
1 Description

Connection Data type Remark


cmd_baud UInt Baud rate of the RS232 port:
 1: 300 baud
 2: 600 baud
 3: 1200 baud
 4: 2400 baud
 5: 4800 baud (standard setting)
 6: 9600 baud
 7: 19200 baud
 8: 38400 baud
 9: 57600 baud
 10: 76800 baud
 11: 115200 baud
cmd_restart BOOLEAN Optional: This variable enables the baud rate change of the RS232
interface on the occurrence of a rising edge.

1.5.2 Output Variables

Table 1-8
Variable Data type Remark
 Siemens AG 2017 All rights reserved

Latitude_Real Real This variable includes the current latitude position in decimal form
(32-bit floating-point number). Can only be evaluated in
conjunction with "return_done".
Latitude_LReal LReal This variable includes the current latitude position in decimal form
(64-bit floating-point number). Can only be evaluated in
conjunction with "return_done".
Longitude_Real Real This variable includes the current longitude position in decimal
form (32-bit floating-point number). Can only be evaluated in
conjunction with "return_done".
Longitude_LReal LReal This variable includes the current longitude position in decimal
form (64-bit floating-point number). Can only be evaluated in
conjunction with "return_done".
return_done BOOLEAN This variable is set to "true" in the cycle in which the GPS frame is
successfully received and the CPU system time is successfully
updated.
return_aborted BOOLEAN This variable is set to "true" in the cycle in which reception of the
GPS frame or the time and date synchronization has failed.
gps_time_n_date DTL This variable includes the current UTC time with date received
with GPS. With "return_done" = "true" the CPU system time is
synchronized with this time.

1.6 Creation Environment


The screens in this FAQ response correspond to STEP 7 V14.0 Update 2.
All tests were successful with STEP 7 V14.0 Upd2.

Receiving GPS frames with S7-1200, S7-1500 and ET 200SP CPU


Entry ID: 45057335, 12.0 , 11/2017 9

Vous aimerez peut-être aussi