1/16/2010 8:49 PM | |
Joined: 12/22/2006 Last visit: 1/25/2022 Posts: 1742 Rating:
|
Hello, This is what I believe the OB35 is doing (see attachment) But using a timer itself to start it is not so good. I use a M200.0 in between. Why do you not use the system clock for this? Would be better. AttachmentOB35.pdf (280 Downloads) |
Best regards |
|
1/17/2010 11:05 AM | |
Joined: 10/7/2005 Last visit: 6/7/2023 Posts: 2966 Rating:
|
Hello nbk
They act assimple clock bits. Incrementing MB190 by 1 every 200ms (which is essentially what happens in your code) is a simple way of creating 8 clock bits with the least significant bit being the "base frequency" and the others being 2, 4, 8 ,16, 32, 64 and 128 multiples of it. In you case the individual bits of MB190 behave like this: M190.0: ON for 200ms, OFF for 200ms (400ms "Base frequency") M190.1: ON for 400ms, OFF for 400ms (i.e. 2 x "Base frequency") M190.2: ON for 800ms, OFF for 800ms(i.e. 4 x "Base frequency") M190.3: ON for 1600ms, OFF for 1600ms(i.e. 8x "Base frequency") M190.4: ON for 3200ms, OFF for 3200ms(i.e.16x "Base frequency") etc.
S5 Timers are handled by the operating system which meanstheir time value and status is updated in the background asynchronously and unrelated to theprogram scan. You could also for example start a 10secOn Delay timer in OB100 and it will come true 10 seconds later even though OB100 is only executed once on startup. This does of course not mean that what was programmed with T1 in your OB35 is "elegant"(it is anything but elegant), but it will"do the job" of creating a "sort of" 200ms pulse (with an errorof up to 100ms! in case T1 times out just after OB35 was called and you'll need to "wait" another 100ms to start it again.The "base frequency" of your logic is more like 250ms on average). A simpler solution would have been to get rid of T1 altogether and simple increment MB190 by 1 every call of OB35. This would then createthe clock bits with a base frequency of 200ms (in which caseM190.1 would neededto be used where currently M190.0 is used and M190.2 would needed to beused where currently M190.1 is used). Even simpler (as mentioned by jklm) is of course to use the clock memory bits from the HWconfig (your logic could however have originatedfrom an S5 upgrade where these would not have existed). I hope this helps |
Cheers |
|
1/18/2010 7:50 AM | |
Posts: 197 Rating:
|
Thank you very much jklm and Fritz. |
This contribution was helpful to
1 thankful Users |
Follow us on