|
|
 |
|
 |
| |
| Home > Libraries > ID 0009 > Detail |
 |
 |
 |
 |
| |
|
| |
|
 |
| Step7-MicroWin: |
[V4.0] |
 |
| CPU: |
[all CPU22x] |
 |
| Operating system: |
-- |
 |
| Other: |
[CPU221,CPU222 need the CC292 clock module] |
 |
|
|
|
 |
|
 |
QUESTION:
How to implement the LOGO! function Weekly timer in MicroWin ?
ANSWER:
The following library conatins a block wich emulate these LOGO function.
Additional Features compared to the LOGO version:
- several days duration inside a single configuration (cam)
- modify configurations trough operator panels etc.
- the max. number of blocks are limited only trough the CPU memory size

The Library "Logo functions V1.1" contains the new function "Weekly timer".
The Function "Pulse Relay" are already described in a previous entry, see bottom links.
Description
The Weekly timer offers the possibility to parameterize up to 3 independent configurations,
which influence one output.
Any Weekly timer block takes therefore always 24 successive Bytes.
Any Configuration gets 8 Bytes. This byte contains the data to switch the output on/off.

Parameters of unused configurations must be preset with 0.
Function call

| Parameter |
Variable Type |
Explication |
| EN |
[BOOL] |
Weekly timer 1=active 0= inactive |
| Config |
[BOOL] |
Indirect Address to the Table with the 3 Configurations
Used configurations must contain data for the On-time and Off-time moment
Not used configurations must be empty (preset with 0) |
| Freq |
[BOOL] |
Frequency of program execution
0 = Configurations would be checked each Second
1 = Configurations would be checked each Minute |
| Refresh |
[BOOL] |
accept new Parameters
if configurations are modified at runtime (e.g. trough operator Panel),
this bit must be activated (Signal True(1)) once to take over the new settings |
| Memory |
[DWORD] |
temporary memory |
| Output |
[BOOL] |
Signal output |
| Error |
[BOOL] |
error at program execution |
| Status |
[BYTE] |
on error shows the error-code |
|
Notice:
The Weekly Timer library adds 2 additional temporary subroutines to the user project.
They are only required for program execution. The user has not to care about them or to parameterize.
Parameter description
En
This parameter activates or deactivates the Weekly timer. These Signal should be always
True(1) (at best trough SM0.0).
Config_Adr
This parameter requires the indirect Address to the 24-Byte long Table with the On/Off timing data.
This should be a constant (like in the picture above) or double word (DWORD) variable which
contain the address.
Notice:
The program is not designed to change the table address at runtime. If required this
should be performed in the first CPU cycle (SM0.1) before the Weekly Timer subroutine is called.
(For indirect addressing in general refer the S7-200 system manual).
Freq
The user configurations wouldnt be checked in every CPU cycle, since this would load the
CPU unnecessary.
This parameter controls the program execution frequency.
The CPU load would be reduced if the function is executed only once per Minute.
Freq = 0 (Low)
At Signal 0(Low) the function will be executed only once per Second.
This enables the user to switch the output with a resolution in seconds.
At this point the On and Off settings could be placed inside a single Minute.
Following pictures shows the frequency of program execution in this mode

Notice:
The minimum switching time is 1 second. The On and Off settings shouldnt
cross between all configurations into the same Moment (Weekday + Hour + Minute + Second),
since in that case the output still left in his last state.
Freq = 1 (High)
At Signal 1(High) the function will be executed only once per Minute.
The smallest resolution would be then a minute. Switching inside a Minute wouldnt be possible.
The parameter seconds inside the configuration would be in that case ignored.
Following pictures shows the frequency of program execution in this mode

Notice:
The minimum switching time is 1 minute. The On and Off settings shouldnt cross between
all configurations into to the same Moment (Weekday + Hour + Minute), since in that case
the output still left in his last state.
General
Switching between the frequencies at runtime is permitted. Trough this it is possible to
reduce the CPU load on time critical moments (events).
As long the execution is in "Minute"-mode, configurations which should switch at specific
seconds, could switch to early or to late, if a on/off event occurs on that time.
Following pictures shows the frequency of program execution in these modes

Refresh
It is possible to change the data for the On/Off events at runtime trough operator
panel or user program. After modifications the Refresh-Bit must be set once to take over
the new values and reset the internal memory. Without these the new setting could catch
at first on the next week.
Notice:
This function will be performed only at a rising edge. So you should use a pushbutton to switch this.
If a switch is used the customer must reset this switch after the subroutine call, to prevent
continuously executions.
Error + Status
If error occurs while function execution the Error-Bit will be set as long the error is there.
The parameter Status contains the corresponding error code.
The current Weekly timer version checks only the completeness of the configuration data.
On error the status shows the configurations which cause the error.
On error all complete configurations will be further proceeding.
Possible error codes:
1 = Failure in Config 1
2 = Failure in Config 2
4 = Failure in Config 3
Time deviation
The Library use the Special Memory Bits SM0.5 for the "second"-execution and the SM0.4
for "minute"-execution.
These Timer-Bits runs asynchronous to the CPU Clock.
The maximum deviation at SM0.5 is <=1sec. and at SM0.4 <= 60sec.

The maximum deviation of the switching time against the CPU Clock is:
Second execution = 1 sec + CPU cycle + Weekly Timer execution
Minute execution = 60 sec + CPU cycle + Weekly Timer execution
Table structure for the On-/Off-time
Value range of the Table-Parameters and values for Weekday

The structure of Parameter "Weekday" is oriented on the CPU Function "Read RTC" and "Write RTC".
At that point the weekdays are assigned to the values 1..7(decimal), where Sunday has the value 1.
To be able to use the same configuration on multiple weekdays this was changed.
So now each weekday get a own bit assigned, value range Bit 0..6 (1..127).
The 7th Bit is not used.
Extending
If the 3 configurations are not enough and you wish to add additional configurations which
influence the same output, you must add a additional instance which force the same output but
different configurations and temporary variables,
except Freq, Refresh parameter.

Attention:
Each instance requires always a own variable for the Memory parameter.
For the parameter Refresh must be used the same variable in any instance.
If the variables are used "Error" or "Status", the customer should check after 1-th instance
if a error occurred before the call of the second instance is made.
This isnt done in the picture above.
Technical data
| Supported CPUs: |
|
| CPU 21x |
no |
| CPU 22x |
yes |
| Step7-Microwin |
V4.0 |
| Program size |
1801 Byte |
| memory space per instance |
39 Byte |
| Resolution |
1 sec / 1 min |
Maximum number of Weekly timer
| CPU with Firmware >= Rel2.0 |
| CPU 221/222 |
4kB |
| CPU 224 |
8kB (12kb) |
| CPU 224XP |
12kB (16kb) |
| CPU 226 |
16kB (24kB) |
| (xxkB) = without Runtime-Edit |

Samples:
Sample 1 - Alarm device
To protect the corporate facilities the Alarm device should be switched ON throughout the weekend.
- On time: Friday 18:30 (06:30pm)
- Off time: Monday 06:00 (am)


Sample 2 - Pause bell
The bell should ring in a school on weekdays at 09:00, 09:15, 12:00 and 12:15.
This would require normally 4 different configurations which switch the bell always
for a few seconds.
Trough tricky programming the required configurations could be reduced to the half size.
This is done when the Weekly Timer instead to switch the output directly, monitors the output
of the Weekly timer on rising and falling edges. When edges are detected the bell would be
activated and a short timer is starte. The bell would be reset when the timer pass his target value.

The following picture shows the program call and the required program extensions.

On rising or falling edges the Off-delay timer (TOF) T37 is started and the output Q0.0 is
activated. After 30x100ms = 3sec the output would be reset.
The function "Edge detect" is a part of the "Edge evaluation" library. See links at bottom.
Sample 3 - Air conditioning
The AirCon should work in a warehouse at operating hours.
- Monday - Thursday 08:00 - 18:00 (06:00pm)
- Friday 08:00 - 14:00 (02:00pm)
- Saturday 09:00 - 12:00


Negative - Sample
In Config_1 the output is switched at Saturday + Sunday at 10:00 - 14:00 (02:00pm).
The Config_2 is programmed for Sunday at 11:00 - 13:00 (01:00pm).
Result:
Since the time-data of Configuration_2 are already inside the Configuration_1 this wouldnt
affect the output.
The output would be switched on at Sunday from 10:00 to 14:00 (02:00 pm)

Trough the Menu "PLC" - "Time of Day clock" the CPU clock could be manipulated for tests.
|
| History |
| Version: |
Fixed / Changed: |
| V1.4 |
- Refresh activation recalculate values delayed
(depend on Freq)
|
| V1.3 |
- add LOGO! random generator
- Small Bug of V1.2.2 which prevent minute execution
|
| V1.2.2 |
- output wouldn`t switch off when CPU start/refresh
match the same minute where OFF was passed
- when Freq is changed from 0->1 they don`t check the
configurations again
- description/definition FREQ parameter for multiple
instances changed
|
| V1.2.1 |
- use of absolute variable VB1000..VB1007
- second + minute execution was confused
- caculation error when OFF < NOW < ON at same weekday
- calculation error when ON+NOW at same weekday
- description/definition REFRESH parameter for multiple
instances changed
- decription of Refresh in Library POE comments was confused
|
|
|
The author makes no warranty, expressed or implied, with regard to this informations and/or software.
All implied warranties, including the warranties of merchantability and fitness
for a particular use, are hereby excluded. Under no circumstances shall the
author of this product or the author(s) of S7-200.net, be liable for any incidental or consequential damages,
nor for any damages. Attachments could contain viruses, the user is repsonsible to check the downloaded
files before using. The user has no claims, especialy not for error correction
or support.
|
 |
 |
 |
| Last Forum topics regarding this entry: |
 |
| |
show all topics |
 |
 |
 |
| Similar entries wich could interrest: |
 |
| |
ID 0027 |
Sample |
Weekly Timer samples |
| |
ID 0006 |
Library |
LOGO! Pulse Relay |
| |
ID 0011 |
Library |
LOGO! Hour counter |
| |
ID 0031 |
Library |
LOGO! Random generator |
 |
 |
 |
|
|
 |
| optimized for MS Internet Explorer and 1024 x 768 resoltution |
| |
 |
|
 |
 |
 |
 |
| |
© Copyright 2003-2006 S7-200.NET - all rights reserved.
S7-200.NET and his author(s) are not liable for any incidental or consequential damages, nor for any damages
caused by informations or software published on this page.
Simatic, Step7-MicroWin and S7-200 are registered trademarks of Siemens AG in Germany and other countries.
Further designated trademarks and brands are the property of their respective owners.
|
|
 |
 |
S7-200.NET ©2003-2006
 |
 |
|
 |
 |
External eprom |
 |
 |
 |
 |
 |
 |
 |
linear read & write access |
 |
 |
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
 |
 |
 |
+ linear access
+ variables >32Bit (string)
+ backup whole V-Memory
|  |
 |
 |
 |
More... |
 |
 |
 |
 |
 |
 |
 |
 |
Yearly timer |
 |
 |
 |
 |
 |
 |
 |
events by date & time |
 |
 |
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
 |
 |
 |
+ up top 3 configurations
+ min. Resolution = 1 min
+ unlimitted blocks
|  |
 |
 |
 |
More... |
 |
 |
 |
 |
 |
 |
 |
 |
Random event |
 |
 |
 |
 |
 |
 |
 |
counter generated events |
 |
 |
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
 |
 |
 |
+ quality assurance
+ security applications
+ unique characteristic
|  |
 |
 |
 |
More... |
 |
 |
 |
 |
 |
 |
 |
 |
Weekly Timer |
 |
 |
 |
 |
 |
 |
 |
Switch devices by clock |
 |
 |
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
+ up top 3 configurations
+ overlapping configurations
+ unlimitted blocks
|  |
 |
 |
 |
More... |
 |
 |
 |
 |
 |
|
|