Sep 3, 2014

DescriptionWith the block in the library, you can use a GPS receiver to read out the time stamp and date of GPS messages. You can use this data to compensate the time drift of the real-time clock (RTC) of your S7-200.
In the attached sample PLC application, the minutes and seconds of the real-time clock are synchronized with the time stamp of the GPS message. Restricting time synchronization to minutes and seconds has the following advantages:
  • It can be applied worldwide, independently of time zones.
  • It can be applied independently of summer/winter time.
Time synchronization is done between xx.20 and xx.40 after the synchronization command.

Fig. 01
CommunicationThe GPS receiver receives GPS messages in compliance with the NMEA standard and sends these as ASCII character strings to the S7-200 basic module. The time stamp and date are read out of them in each case. The S7-200 uses the freely programmable communication mode (Freeport) via the RS485 connection ( Port '0' or Port '1') for communication with the GPS receiver. The library uses the RMC protocol of those available in the NMEA standard.
Transfer format
The transfer format used for GPS messages in compliance with the NMEA standard requires the following interface parameters:
  • 4800 baud
  • 8 data bits
  • No parity
  • 1 stop bit
The resulting interface parameter to be entered at the "GPS_NMEA_TIME_UTC" block is 2#1101 (see description under "Library: Read out time stamp and date").
RequirementsThe library and the sample PLC application can be used
  • With a GPS receiver with serial interface that supports the NMEA standard and which is connected to the S7-200 basic module via an RS232 PC/PPI cable.
  • With an RS232 PC/PPI cable
Library: Read out time stamp and dateThe library contains the "GPS_NMEA_TIME_UTC" block for reading out the year, month, day, hour, minute and second in UTC (Universal Time Coordinated).
 

No.Remarks
1Use the GPS receiverConnect the GPS receiver to the RS485 connection of your S7-200 basic module via an RS232 PC/PPI cable. Set the DIP switches of the PC/PPI cable as in Fig. 02.
Fig. 02

Additional informationThe RS485 connection does not provide any power supply for your GPS receiver.
2Add libraryStore the attached "gps_time_read_port0.zip" or "gps_time_read_port1.zip" file on your computer. Unpack the file and add the library to your configuration software STEP 7 Micro/WIN.Additional information
Instructions for adding libraries are available in Entry ID 16689345.
3Add GPS block
From the "GPS_TIME_READ_PORT0" or GPS_TIME_READ_PORT1" library you drag-and-drop the "GPS_NMEA_TIME_UTC" block into a cyclically called network.

Fig. 03

Assign an unused memory area to the library.
Additional information
  • Approx. 950 bytes are need in the CPU's program memory.
  • The library occupies 214 bytes in the CPU's variable memory.
  • The required interrupt "GPS_NMEA_RC" and the subprogram "GPS_NMEA_INIT_PORT0" or "GPS_NMEA_INIT_PORT1" are inserted automatically in your project.
  • Information on assigning memory area for libraries is available in Entry ID 16689345.
4Connect the GPS blockAssign the contacts of the block. The variables used in Fig. 04 are examples. Via the "Freeport_Config" contact you configure the freely programmable communication. The parameter "2#1101" results for the NMEA transfer format used (see "Transfer format").
Fig. 04

Additional informationAdditional information on configuring the freely programmable communication is available in the S7-200 manual, section 7.5 "Creating user-defined protocols in the freely-programmable communication".
5Use the GPS blockYou start the GPS evaluation with a positive edge at the 'Start' input. You can tell how well the evaluation is from the contacts 'DONE', 'ABORTED' and 'GPS_status'.The table lists the contacts of the block and tips for usage.
  

Contact nameData typeContact typeRemarks
ENBOOLInputSM0.0
STARTBOOLInputPositive edge = one-off read out
Freeport-ConfigINTInput'2#1101' =  parameter for initializing the freely programmable communication
DONEBOOLOutput1 = GPS reception completed
ABORTEDBOOLOutput1 = GPS reception defective
UTC_yearBYTEOutputOutput of the year
UTC_monthBYTEOutputOutput of the month
UTC_dayBYTEOutputOutput of the day
UTC_hourBYTEOutputOutput of the hour
UTC_minuteBYTEOutputOutput of the minute
UTC_secondBYTEOutputOutput of the second
UTC_statusBYTEOutputASCII-coded;
  =  65 (A) -> Data OK
 <> 65 (A) -> Data defective
Additional informationThe time stamp of the GPS message include the UTC time.
Table 01
Sample application: Synchronize the timeThe sample application uses the functions of the "gps_time_read_port0.mwl" or "gps_time_read_port1.mwl" library. You can use the sample application without incorporating the library.
 
No.Remarks
1Use the GPS receiverConnect the GPS receiver to the RS485 connection of your S7-200 basic module via an RS232 PC/PPI cable. Set the DIP switches of the PC/PPI cable as in Fig. 05.
Fig. 05

Additional informationThe RS485 connection does not provide any power supply for your GPS receiver.
2Open the sample applicationStore the attached "gps_time_read_port0.zip" or "gps_time_read_port1.zip" file on your computer. Unpack the file and add open it using your configuration software STEP 7 Micro/WIN.
3Use the sample applicationYou start the sample application with a positive edge at the 'Start' input of the "GPS_SYNC" block. For this you set the variable V541.0 to 'high' using the variable table. The sample application remains active until synchronization has been done after the time window has been reached. You can tell the status of the evaluation from the contacts 'DONE', 'ABORTED', 'GPS_rcvd_warning' and 'sync_not_in_window'.
Fig. 06

The sample application cyclically reads the time stamp of the GPS message received. The minutes and seconds are synchronized automatically in the time window between xx.20 and xx.40. The table lists the contacts of the block and tips for usage.
 

Contact nameData typeContact typeRemarks
ENBOOLInputSM0.0
STARTBOOLInputPositive edge starts the synchronization
CANCELBOOLInputAbortion of the synchronization
DONEBOOLOutputCompletion of the synchronization
BUSYBOOLOutputSynchronization active
ABORTEDBOOLOutputSynchronization aborted
GPS_rcvd_warningBOOLOutputGPS reception defective
sync_not_in_windowBOOLOutputTime of synchronization not in time window
Additional informationChange the value of variable VW802 to '1000' to have synchronization tested at any time. At the end of each test, reset the variable to the value '100'.
Table 02
PasswordThe password for the library is "1234" (without the quotation marks).
Download
 
DescriptionDownload
Library for reading out the GPS time via Port '0' gps_time_read_port0.zip ( 3 KB )
Library for reading out the GPS time via Port '1' gps_time_read_port1.zip ( 5 KB )
Sample application for synchronizing the RTC via Port '0' gps_time_sync_port0.zip ( 9 KB )
Sample application for synchronizing the RTC via Port '1' gps_time_sync_port1.zip ( 9 KB )

0 comments :

Post a Comment