[? Code]: What is the reason for M100.0 not being set?

SIMATIC S7-200/300/400, Step7, PCS7, CFC, SFC, PDM, PLCSIM,
SCL, Graph, SPS-VISU S5/S7, IBHsoftec, LOGO ...
Post Reply
nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

[? Code]: What is the reason for M100.0 not being set?

Post by nashama » Fri May 06, 2011 11:29 am

Dear All,

Code: Select all

AN T10
L S5T#5S
SD T11

A T11
L S5T#5S
SD T10

A T10 
S M100.0
What is the exact reason for M100.0 for NOT getting set?

And why/what difference will it make , if we shift the last 2 statements on top of the codes?

Regards

hardy
Posts: 21
Joined: Mon Oct 10, 2005 12:26 am
Location: America

Re: [? Code]: What is the reason for M100.0 not being set?

Post by hardy » Fri May 06, 2011 2:53 pm

try this:

Code: Select all

      A     T     11
      L     S5T#5S
      SD    T     10

      AN    T     10
      L     S5T#5S
      SD    T     11

      A     T     10
      S     M    100.0

nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

Re: [? Code]: What is the reason for M100.0 not being set?

Post by nashama » Fri May 13, 2011 2:02 pm

Dear hardy,

Thanks for the reply.
I will try your codes on simulator (and with all due respect I know it will work)
But I just wanted to know what is the EXACT reason for M100.0 for not getting set in my original codes.
In short, can u explain in words , why it doesn't get set?
Regards

nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

Re: [? Code]: What is the reason for M100.0 not being set?

Post by nashama » Fri May 13, 2011 2:11 pm

Dear hardy,
Just 1 more thing with respect to your modified codes:
I haven't simulated your codes yet ......... but do you mean M100.0 will get set after 10s ?
Plz comment back.
Regards

sventek
Posts: 56
Joined: Sun Jul 13, 2008 10:48 am
Location: Europe

Re: [? Code]: What is the reason for M100.0 not being set?

Post by sventek » Fri May 13, 2011 2:45 pm

Hi nashama!

The reason is, that timers works asynchronous to the Step7 program. When you wait long enough, the Marker 100.0 will be set, depending when the timer will elapse (tested on a real CPU).

| When timer elapse here, first T11 will be set back and then also T10 -> M100.0 can't be set.
AN T10
L S5T#5S \
SD T11 __\
_________ \
A T11 ____| When timer elapse fortuitous here, -> M100.0 will be set.
L S5T#5S _|
SD T10 __/
_______/
A T10
S M100.0
| Also here -> when timer elapse here, first T11 will be set back and then also T10 -> M100.0 can't be set.

When you shift the last two statement on the top, M100.0 will always be set, when timer T10 elapses, because there is no condition before the two statements that could reset first T11 and with that T10.

I hope that help's you.

sventek

nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

Re: [? Code]: What is the reason for M100.0 not being set?

Post by nashama » Fri May 13, 2011 3:40 pm

Dear sventek,
Many thanks for the reply.
Definitely, u gave the insight of the s7 STL codes (Thx again !)
My estimate was this (which may be wrong):Since the timers are updated every 10ms, the scan of CPU may not be able to set M100.0 immediately below the original codes. However, when the last 2 statements are relocated to the top of the codes, M100.0 will get set in the next scan cycle of the CPU (because , by this time the timer status of T10 will be already updated)
Does this makes sense? Plz comment bk.
Reagards

sventek
Posts: 56
Joined: Sun Jul 13, 2008 10:48 am
Location: Europe

Re: [? Code]: What is the reason for M100.0 not being set?

Post by sventek » Fri May 13, 2011 7:58 pm

nashama wrote:Dear sventek,
My estimate was this (which may be wrong):Since the timers are updated every 10ms, the scan of CPU may not be able to set M100.0 immediately below the original codes. However, when the last 2 statements are relocated to the top of the codes, M100.0 will get set in the next scan cycle of the CPU (because , by this time the timer status of T10 will be already updated)
Reagards

I'm sorry, but you are wrong. It's simply so as I mentioned: Timer is running asynchronous to the program. At a time, time is elpased. When timer is elapsed before the first code line, all timer will be initialized -> M100.0 can't be set. In your short code snipped last line is more or less before first line, so there is not so much space where you can prove T10 successfully onto TRUE. But when you set the last two lines into first, M100.0 will always be set when timer is elapsed.

Everything clear?

sventek

nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

Re: [? Code]: What is the reason for M100.0 not being set?

Post by nashama » Sat May 14, 2011 6:24 pm

Thanks again dear Sventek.
In context of this thread , I found something in your explanation which I couldn't find even through "F1" of Simatic Manager. Thank u.
How about this?(hope you will respond with an equally interesting reply)

AN T5
L S5T#1s
SD T5

A T5
CU C5

Will C5 keep counting? or this situation will be similar to the last one as well?
Sorry for raising "basic" type questions ....... but I guess I will get to know something in the end from your experience and expertise !!
Regards

Trafo
Posts: 28
Joined: Sat Oct 09, 2010 11:39 am
Location: SLOVENIJA

Re: [? Code]: What is the reason for M100.0 not being set?

Post by Trafo » Sat May 14, 2011 8:35 pm

nashama wrote:Dear All,

Code: Select all

AN T10
L S5T#5S
SD T11

A T11
L S5T#5S
SD T10

A T10 
S M100.0
What is the exact reason for M100.0 for NOT getting set?

And why/what difference will it make , if we shift the last 2 statements on top of the codes?

Regards
Hi, code should be modified like this:

AN M 0.0
L S5T#5S
SD T 11

A T 11
L S5T#5S
SD T 10

A T 10
= M 0.0

SET
A T 10
S M 100.0

The reason why I called SIEMENS folklore, so you get used to it. (welc)

Trafo
Posts: 28
Joined: Sat Oct 09, 2010 11:39 am
Location: SLOVENIJA

Re: [? Code]: What is the reason for M100.0 not being set?

Post by Trafo » Sat May 14, 2011 8:40 pm

AN T5
L S5T#1s
SD T5

A T5
CU C5

Will C5 keep counting? or this situation will be similar to the last one as well?
Sorry for raising "basic" type questions ....... but I guess I will get to know something in the end from your experience and expertise !!
This will not work. It should be modified :


AN M 100.1
L S5T#1S
SD T 5

A T 5
= M 100.1

A T 5
JCN M001


L MW 1000
L 1
+D
T MW 1000

M001: NOP 0


L MW 1000
T MW 1002


Personally I'm never using CU.

sventek
Posts: 56
Joined: Sun Jul 13, 2008 10:48 am
Location: Europe

Re: [? Code]: What is the reason for M100.0 not being set?

Post by sventek » Sun May 15, 2011 8:14 pm

nashama wrote:Thanks again dear Sventek.
In context of this thread , I found something in your explanation which I couldn't find even through "F1" of Simatic Manager. Thank u.
How about this?(hope you will respond with an equally interesting reply)

AN T5
L S5T#1s
SD T5

A T5
CU C5

Will C5 keep counting? or this situation will be similar to the last one as well?
Sorry for raising "basic" type questions ....... but I guess I will get to know something in the end from your experience and expertise !!
Regards
Hi nashama!

I could not test this on a real CPU, because I'm out of office this week. But anyway and without testing it is the same. Did you get another result? I think again, when you wait a longer period, the counter should count from time to time.
No poblems with the "basic type questions". It's always possible to learn something new, also for experts (and I'm realy not an expert :) )

Regards
Sventek

SHKODRAN
Posts: 197
Joined: Wed Dec 24, 2008 4:37 pm
Location: Europe
Contact:

Re: [? Code]: What is the reason for M100.0 not being set?

Post by SHKODRAN » Sun May 15, 2011 11:04 pm

I think that is so much easier:

Code: Select all

 A(    
      O(    
      AN    T    100
      L     S5T#5S
      SD    T    101
      A     T    101
      )     
      O(    
      A     T    101
      L     S5T#5S
      SD    T    100
      A     T    100
      )     
      )     
      NOT   
      S     M    100.0
I do not know exactly what you want to do, but it works well. (suc)

nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

Re: [? Code]: What is the reason for M100.0 not being set?

Post by nashama » Mon May 16, 2011 1:12 am

Dear SHKODRAN,

You demonstrated another way of HOW to set M100.0 , while I was asking for the reason WHY M100.0 was not getting set in my original post.
Nevertheless, thank u for sharing the new idea to set M100.0.
Regards

nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

Re: [? Code]: What is the reason for M100.0 not being set?

Post by nashama » Mon May 16, 2011 1:19 am

Dear Sventek,

Counter C5 did not count at all.
I had to modify the codes (which is more or less similar to Trafo's suggessions)

AN M4.6
L S5T#1s
SD T5

A T5
= M4.6
CU C5

With this arrangement , C5 started counting.
Regards

nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

Re: [? Code]: What is the reason for M100.0 not being set?

Post by nashama » Mon May 16, 2011 1:31 am

Dear Trafo,
Thanks for the reply.
May I ask u few things?
1) Why can't you use " + I " instead of " +D " to increment MW1000 since it is a WORD, not a DOUBLE WORD.
2) Trafo : "The reason why I called SIEMENS folklore, so you get used to it."
Couldn't understand that ......... is it some kind of mystery or something mysterious with Siemens you mean? I'm not sure what does that mean. But thanks for your time and attention.
Regards

pwkoller
Posts: 15
Joined: Sun Dec 04, 2005 9:06 am
Location: Europe

Re: [? Code]: What is the reason for M100.0 not being set?

Post by pwkoller » Mon May 16, 2011 9:45 pm

[quote="sventek"]Hi nashama!

The reason is, that timers works asynchronous to the Step7 program. When you wait long enough, the Marker 100.0 will be set, depending when the timer will elapse (tested on a real CPU).

| When timer elapse here, first T11 will be set back and then also T10 -> M100.0 can't be set.
AN T10
L S5T#5S \
SD T11 __\
_________ \
A T11 ____| When timer elapse fortuitous here, -> M100.0 will be set.
L S5T#5S _|
SD T10 __/
_______/
A T10
S M100.0
| Also here -> when timer elapse here, first T11 will be set back and then also T10 -> M100.0 can't be set.

When you shift the last two statement on the top, M100.0 will always be set, when timer T10 elapses, because there is no condition before the two statements that could reset first T11 and with that T10.

I hope that help's you.

sventek[/quote]

This explaination is totaly right, but shifting the 2 statements on top only minimizes the chance to loose single settings of m100.0 ->

A T10__ \
S m100.0 |... if executing this AND timer ellapses..... (unlikely but possible)
AN T10_ /
....


the cure is:
A T11
L s5t#..
SE T10

AN T10
L s5t#..
SE T11

A T10
S M100.0

Anyway : i can not imagine any practical use of accumulating times this way

greetings pwkoller

nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

Re: [? Code]: What is the reason for M100.0 not being set?

Post by nashama » Wed May 18, 2011 2:20 pm

Dear pwkoller,
Thanks for suggesting another way to set M100.0
pwkoller : "Anyway : i can not imagine any practical use of accumulating times this way"
That's right. It is just for testing purpose only ....... Though it looks so simple to the naked eye , for the first time when you see the codes that M100.0 will get set easily in the original STL , however , it requires some "internal understanding" to know WHY M100.0 don't get set that easily !!
Regards

pwkoller
Posts: 15
Joined: Sun Dec 04, 2005 9:06 am
Location: Europe

Re: [? Code]: What is the reason for M100.0 not being set?

Post by pwkoller » Wed May 18, 2011 9:35 pm

hi,
some (practical) thoughts:

while maintaining large programs it is possible to get constructions like the m100 problem -
hidden the three parts of it somewhere in the whole program.

as we have seen, only one sequence of the three parts gives us a proper result
so what if a necessary program change forces us to alter the sequence of called programparts
-> we have done everything right, but it does not work.

the reason is : a signals state does not last at least ONE cycletime lenght
(similar are problems with inputs witch maintaine states shorter than cycletime)

so a general rule should be: make your signals at least one cycletime long ( to be seen from the whole program )

another point is : nobody pays you for the minimal amount of statements in your program
but only for 100% realyability and 100% functionality. And you will do yourself a favour if you have to
maintain the program.

for our example this means the following: ( the three parts could be called in ANY sequence and it will work )

-> part 1
UN M 1.1 // Signal timer 10 (consumed)
L S5T#500MS
SE T 11
U T 11
= M 1.0 // Signal timer 11 (provided)

-> part 2
U M 1.0 // Signal timer 11 (consumed)
L S5T#500MS
SE T 10
U T 10
= M 1.1 // Signal timer 10 (provided)

-> part 3
U M 1.1 // Signal timer 10 (consumed)
S M 100.0

happy programming, pwkoller

nashama
Posts: 50
Joined: Thu Apr 21, 2011 9:37 am

Re: [? Code]: What is the reason for M100.0 not being set?

Post by nashama » Thu May 19, 2011 3:05 pm

Thanks pwkoller.
So my idea of time resolution (or time base of S5timer) versus scan cycle time of CPU is not the reason of the problem as Sventek clarified that timers run asynchronously to the user program.
Further to that , I take your advice to make sure the signal state is made to last more than atleast one scan cycle time.
Regards

Post Reply