show the entry list
STEP 7 Micro/WIN -- Creating S7 programs -- Calling blocks and functions
How do you reset the high-speed counters of the S7-200?
Using an S7-200 without twilight switch, how do you have shutters open at sunrise and close at sunset?
How do you count values over 16 bits with the S7-200?
How can you limit the pitch of jumps with S7-200?
How do you configure the positioning module EM253 so that the connected stepper motor can proceed in both directions?
How do you position a servo drive axis using the S7-200 pulse interface?
How do you create a bar display in TD 200 or TD 200C?
How can you optimize use of timers in STEP 7 Micro/WIN?
How do you determine the frequency of a pulse sequence and speeds?
How can you scale analog values with S7-200 in conjunction with CPU224XP and expansion modules EM 231, EM 232 and EM 235?
How do you convert a binary number into Gray code (or vice versa) in STEP 7 Micro/WIN?
How do you convert the number format DOUBLE INTEGER into BCD code (or vice versa) in STEP 7 Micro/WIN?
How do you form the absolute and negative values of numbers in STEP 7 Micro/WIN?
Why does the PID controller created by the instruction wizard sometimes not work?
What do you have to do in the SIMATIC S7-200 in order to edit part of the program once after restarting?
Which library with the inverse functions to the trigonometric functions (sine, cosine, tangent) is available for STEP 7-Micro/WIN?
Scaling the setpoint and actual values in the STEP 7 Micro/WIN V4 wizards for PID control loops
Positioning Wizard for PTO/PWM in STEP 7 Micro/WIN V4.0
How to implement a three step control with PID-loop in the S7-200 via STEP 7-Mirco/WIN?
Using an S7-200 without twilight switch, how do you have shutters open at sunrise and close at sunset?
Part number:

Instructions:
A twilight switch is usually used to define the morning and evening switching points of a shutter control. If you are using a SIMATIC S7-200 anyway to control your shutters, it is practical to determine sunrise and sunset with an astronomical algorithm that is available as a STEP 7 Micro/WIN library. You simply have to specify the longitude and latitude coordinates of the location concerned as parameters and set the CPU clock to UTC time. In addition, you have the option of shifting the opening and closing times of the shutters compared to the twilight times of the algorithm. You can, for example, have the shutters open 10 minutes before sunrise and close 5 minutes after sunset. Once parameterized, the controller works without any temporary readjustment. It is also independent of daylight saving changes. The following table explains how this works taking a sample project.
 
No. Procedure
1

Open the "shutter_control.mwp" project.
The "sunvector_2015_en.mwl" library supplied that gives the astronomical algorithm is already integrated in the project and occupies the memory area VB0 to VB49. Change the memory area as required in the menu "File > Library Memory...". You only need the mwl library file itself if you wish to add a project of your own.

2 In the program editor you go to the main program (MAIN).
In Network 1 is the call of the subprogram "shutter_control". This in turn calls the astronomical algorithm. The "shutter_control" subprogram outputs one pulse for one cycle at the bit output "open_shutter" at sunrise and at the bit output "close_shutter" at sunset. Change the input parameters of the subprogram to suit your particular requirements.


Fig. 1: Subprogram "shutter_control"

Longitude:
Degree of longitude (e.g. 11° 04' 01'' = 11.0669444°);
east of Greenwich = positive, west of Greenwich = negative;

Latitude:
Degree of latitude (e.g. 49° 26' 16'' = 49.4377778°);
north of the equator = positive, south of the equator = negative;

Up_offset:
Time offset in minutes to shift opening of the shutters compared to the time of sunrise calculated by the algorithm. If the value is positive, the shutters open earlier and later if negative.

Down_offset:
Time offset in minutes to shift closing of the shutters compared to the time of sunset calculated by the algorithm. If the value is positive, the shutters close earlier and later if negative.

open_man:
Bit input for manual opening of the shutters. A positive edge generates a cycle pulse at the "open_shutter" output. For this parameter you can configure a button, for example, or use the parameter to loop in another condition for opening the shutters.

close_man:
Bit input for manual closing of the shutters. A positive edge generates a cycle pulse at the "close_shutter" output. For this parameter you can configure a button, for example, or use the parameter to loop in another condition for closing the shutters.

open_shutter:
Cycle pulse for opening the shutters at sunrise.

close_shutter:
Cycle pulse for closing the shutters at sunset.

3 Change the output parameters of the "shutter_control" subprogram to meet your control requirements for the shutters.
There are two alternatives given in Networks 2 and 3 of MAIN:

Network 2 (static output signals):
The bit output "move_up:A0.0" is set between sunrise and sunset.
The bit output "move_down:A0.1" is set between sunset and sunrise.

Network 3 (output pulses):
The bit output "move_up:A0.0" is set at sunrise for 1 second.
The bit output "move_down:A0.1" is set at sunset for 1 second.

Delete the network with the alternative not used. Replace the alternatives where appropriate to meet your own control requirements.
Change the addresses of the output bits as required.

4

Make the UTC time available to the controller. The UTC time (Universal Time Coordinated) is valid worldwide as opposed to local time that is only valid within a regionally limited time zone. For example, UTC+1 is Central European Time (CET) and UTC+2 is Central European Summer Time (CEST). The current UTC time is available in the Internet (for example at http://www.weltzeituhr.com/). There are two types of time control available.

Using the CPU's real-time clock:
Set the current date and current UTC time in Micro/WIN under "PLC > Real-time Clock...". For Summertime you select "No changes".

Note:
If your controller is networked at all and you have a more reliable time source than the CPU clock, you can synchronize it at appropriate intervals with the operation "Set real-time clock" (SET_RTC).

Using a GPS receiver:
A very convenient type of time control is to connect a GPS receiver to the CPU. This eliminates having to synchronize or adjust the time in any way. In addition, the degrees of longitude and latitude are supplied. Refer to Entry ID 26311405 for a description of how to connect a GPS receiver to the S7-200 controller, the conditions to be met and the software blocks available. Please also note the following with regard to the interfaces between the GPS blocks and the shutter controller block:

  • Set the "Time_Source" parameter for the two calls of the "SunPos_Calculation" block in each case to TRUE in the subprogram "shutter_control". This disconnects the CPU's real-time clock from the astronomical algorithm.

  • Change the date and time components that are in BYTE format (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND), which the GPS block GPS_NMEA_UTC_Time outputs, to BCD (binary-coded decimal) and transfer them to the variables year_BCD, month_BCD, day_BCD, hour_BCD, minute_BCD and second_BCD in the memory area of the library "SunVector_2015 (v1.2)".

  • Connect the input parameters "Longitude" and "Latitude" (REAL) of the "shutter_control" block to the corresponding output parameters of the GPS block GPS_NMEA_POS. Make the necessary changes to the format here. Note that the directions N(North) and E(East) are to be counted positive, and S(South) and W(West) negative.

Download:
The ZIP file contains the astronomical algorithm "sunvector_2015_en.mwl" in the form of a library and the sample project "shutter_control_en.mwp".

shutter_control.zip ( 44 KB )

Notes:

  • Information on using the time data from a GPS receiver in an S7-200 is available in Entry ID: 26311405
  • Information on inserting libraries in STEP 7 Micro/WIN is available in Entry ID: 16689345

 Entry ID:35146699   Date:2009-04-06 
I regard this article....as helpfulas not helpful                                 
mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
To this entry
Print
Create PDF 
Send to a friend
QuickLinks
Compatibility tool 
Help
Online Help
Guided Tour