How many scans to complete this Function - TIA

UKAi

Member
Join Date
Feb 2022
Location
UK
Posts
22
Cant decide if this will take a 100 scans or 1 scan to complete -
my thoughts are that if the internal memory in the plc is updated and available for the next rungs logic then this would all be done in 1 scan, - I'm reaching out for some guidance, I'm struggling with this a bit
Screenshot-2022-03-08-003418.jpg


thanks -
 
This addressing !?!?
"Q".Q."Fault Array"["Q".Q.[Pointers[1]]

So much going on in just a PLC address.
Someone is trying to obfuscate his code.
Or is it some kind of test ?

You do know that in TIA you can add SCL networks to LAD and FBD blocks.
Try something like this:
Code:
FOR i:= 99 TO 0 BY -1 DO
   "Alarms".Fault[i] := "Alarms".Fault[i+1] ;
END_FOR
 
JMP is akin to GOTO.
You can use it but it is more error prone and more difficult to read. If you have more than one jump label, you can quickly make a nasty bug when you are copying-and-pasting code around in the same block.
When you use a canned function such as a FOR loop, the compiler takes care of the rest.
 
A FOR is a canned GOTO, as are WHILEs, REPEATs, etc. There is nothing to stop a malformed FOR from causing problems any less or more than a JMP.

Every coder will likely manage cause a watchdog fault using a JMP once, even if just for the fun of it. The good ones don't repeat the mistake and don't need the imaginary guardrails of a canned construct to protect them; the not so good ones will be making so many other mistakes that any benefit from the FOR will not be noticed.

There is no such thing as structured programming, only structured programmers.

"A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear GOTOs*, shall not be infringed."

* and shoot themselves in the foot.
 
I think people seem to forget, any of those functions when compiled do use jumps, when Basic, C, Pascal (Even many PLC weather interpreted or compiled the basic functions like for are just calls to a loop etc. try de-compiling it just the same as when a variable used to jump to an address, so in reality there is no difference, I do agree that a for/next or while seems to be self explanatory but in reality they are basically the same.
 
A FOR is a canned GOTO, as are WHILEs, REPEATs, etc. There is nothing to stop a malformed FOR from causing problems any less or more than a JMP.

Every coder will likely manage cause a watchdog fault using a JMP once, even if just for the fun of it. The good ones don't repeat the mistake and don't need the imaginary guardrails of a canned construct to protect them; the not so good ones will be making so many other mistakes that any benefit from the FOR will not be noticed.

There is no such thing as structured programming, only structured programmers.

"A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear GOTOs*, shall not be infringed."

* and shoot themselves in the foot.
There could be difference. Some processor scan I/O and logic independently.
SLC is like a one instruction, no I/O is updated until it is done.
I could be wrong. But I do think there is difference between AOI and Jump ladder routings.
 
... I just deleted a whole post because I went to a bit of a rant.

But seriously, both parky and drbitboy, do you really argue that JMPs and GOTOs are perfectly fine to use today .. ?
 
Why not, the code is basically the same just harder to understand compared to for next, but then again if you do not understand the difference (or reality the same at machine code level) then I can understand.
Years ago there very few PLC platforms if any that had for next or do while or what ever.
 
It also depends on WHO are reading the code, it's more common to know LAD then SCL. So to be fair, more people can read "JUMP" instructions in a LAD then can read a for loop in SCL
 

Similar Topics

When I turn the slider all the ways down, it cannot go below 145 scans. The simulation is going way to fast for me to follow. I see others on...
Replies
2
Views
1,454
Good Evening , We have a number of Powerflex 525 Drives . I took notice for years elsewhere and our plant , that our Powerflex 525 drive...
Replies
0
Views
636
Good Afternoon, Just wondering , are many of you using SAP in your plants ? If so , is it difficult to learn ? Are there many training...
Replies
10
Views
1,417
It better to have too many instead of not enough right?
Replies
26
Views
2,867
Hi all- I have an application where: - I have a fixed system with a pre-determined, static, network (say, 192.168.2.0/24). - That system...
Replies
13
Views
4,235
Back
Top Bottom