Execution speed

mazeeff

Member
I have a need to trigger a event at a very specific time. I would like to use the CT variable to trigger on a time down to the second. I have read posts where the execution speed was 180 instructions per second, and that a temperature read takes 850ms. I have just under 300 lines of code. Am I at risk of my loop cycle being greater than 1 second?
 
there is a task scheduler inside WebControl. Temperature reading is only initiated every second for all the sensors, however, PLC engine is a different task, which is going a lot more often. How often they are scheduled depends on how many other pending tasks.  If there are a lot other activities, then it will be less time for execute PLC instructions.  If there are no other activities at all, then all times are being used for executing PLC instructions. In reality, you will find the PLC is executed very fast.
 
To make PLC executing reliably, you will need to test and experiment based on your setup.  PLC engine allow total 1000 PLC instructions lines. However, very few PLC program will run from line 1 to line 999, rather the logic is flowing from one section to another.
 
I was planning to use the CT variable to test for 02:00:00, but I am starting to think that the smarter move would be to use CH and CM instead. This would give me up to a minute to catch it, as opposed to 1 second for CT.
 
mazeeff said:
I was planning to use the CT variable to test for 02:00:00, but I am starting to think that the smarter move would be to use CH and CM instead. This would give me up to a minute to catch it, as opposed to 1 second for CT.
 
From my viewpoint (coding for things that can kill people), looking FOR a specific time to do something is so fraught with danger, it should be a last resort only.
Instead, look for the time being Equal to OR LATER than your target, and setting a flag once done. That way, even if you are unavoidably delayed, you will still execute it once, even if it is a few seconds later.
 
Also, by way of comment - the temperatures are read in the background. Reading say T1, T2 and T3, will not stop execution for 3*800ms = 2400ms.
They are read in the background and stored as "immediately available" values, but they just won't update instantly.
 
My longest program is (edited - I included comments and notes in my initial count) 2086  856 lines, and it still gets around reliably in under a second.
 
CAI_Support said:
PLC engine allow total 1000 PLC instructions lines.
 
When did this change? I have some (quite long) code running in older boards.
I might be able to reduce it with some of the newer commands, but it's going to be quite a squeeze!
 
rossw said:
From my viewpoint (coding for things that can kill people), looking FOR a specific time to do something is so fraught with danger, it should be a last resort only.
Instead, look for the time being Equal to OR LATER than your target, and setting a flag once done. That way, even if you are unavoidably delayed, you will still execute it once, even if it is a few seconds later.
 
Also, by way of comment - the temperatures are read in the background. Reading say T1, T2 and T3, will not stop execution for 3*800ms = 2400ms.
They are read in the background and stored as "immediately available" values, but they just won't update instantly.
 
My longest program is (edited - I included comments and notes in my initial count) 2086  856 lines, and it still gets around reliably in under a second.
 
I will take your advice, and just look for the time to be greater than 2 AM.. My application is not that critical! I was just cleaning up my DST code that was discussed in an earlier thread. It would seem like it is a good idea to stay away from using the CT variable, since it goes down to 1 sec resolution.
 
rossw said:
When did this change? I have some (quite long) code running in older boards.
I might be able to reduce it with some of the newer commands, but it's going to be quite a squeeze!
 
Both of my manuals (3.2.13 & 3.2.16) state the 1,000 line limit in section 6.
 
It was 300 lines originally, we later expand that to 1000 lines.  That has been like that for many versions.
We could expand it further in future version, since PLC program is stored in external EEPROM, that still has space to allow expansion.
 
We actually command all temp sensors conversion at once, then read back result one by one.  That way, temperature change will not be detected 10 seconds later, if you have 8 sensors, rather is updated almost every second.
 
I want to mention about CTS and other timer functions, like CT, CH, CM,etc.  We will eventually implement DST support by user using PLC instruction to tell WebControl when to turn on DST, and when to turn off DST.  All the time related IO identifier will be subject to DST, except CTS, since that is the seconds since year 2000.  Does not matter if DST on or off.  Even we don't  have DST support now, it is better to make notice of that so that your code will executed correctly.
 
CAI_Support said:
I want to mention about CTS and other timer functions, like CT, CH, CM,etc.  We will eventually implement DST support by user using PLC instruction to tell WebControl when to turn on DST, and when to turn off DST.  All the time related IO identifier will be subject to DST, except CTS, since that is the seconds since year 2000.  Does not matter if DST on or off.  Even we don't  have DST support now, it is better to make notice of that so that your code will executed correctly.
 
Good point. With fall DST jumping backward, I have to make sure that when CH changes from 2 AM to 1 AM, my code leaves DST off.
 
Back
Top