Structured Text Scan Cycle

damica1

Member
Join Date
Aug 2015
Location
Illinois
Posts
839
I think I understand how the scan cycle of a ladder program is done.

But if you create a section of code that uses Structured Text how would that get scanned?

Example:

for i := 1 to 5 by 1 do
AWT_1(TRUE, channel, data);
end_for;

Is each line a scan? How would this section excute?

Can someone explain this in more detail to me.

Thanks
 
Structured text is scanned the same way that ladder logic is.

The FOR-loop in your example though, halts the scan untill i = 5 and then continues.
The same would be the case with a FLL instruction in ladder (in logix5k).
 
Structured Text [For Loops] halt the scan until the loop completes.

In cases where I can't tolerate the scan delay I usually build a multi-branch rung, use a counter that increments with each scan, and then on a parallel rung do your logic with an indirect address indexed off the counter.acc value. This will give you one step per scan but still functions like a loop.
 
you might be interested in the "numerical" or "incremental" modes of the FAL (File Arithmetic and Logic) instruction ...
 
Last edited:
OK, I'm still confused because of this. In my example:

for i := 1 to 5 by 1 do
AWT_1(TRUE, channel, data);
end_for;

Notice I now have an array, so AWT and most function won't excute(over and over) until the enable goes to false and back to true. So how do you make them work if they are in an array.

The loop above will not work because the AWT enable never goes back to false. What am I missing? Do I need to do something like this?

for i := 1 to 5 by 1 do
AWT_1(TRUE, channel, data);
AWT_1(False, channel, data;
end_for;
 
OK, I'm still confused because of this. In my example:

for i := 1 to 5 by 1 do
AWT_1(TRUE, channel, data);
end_for;

Notice I now have an array, so AWT and most function won't excute(over and over) until the enable goes to false and back to true. So how do you make them work if they are in an array.

The loop above will not work because the AWT enable never goes back to false. What am I missing? Do I need to do something like this?

for i := 1 to 5 by 1 do
AWT_1(TRUE, channel, data);
AWT_1(False, channel, data;
end_for;


I think what you would do is use a tag to that first parameter, where you currently use (TRUE/FALSE). When that loop executes each cycle, it will check the status of your trigger tag. I assume that is what you would do if you were calling an instruction like that in ladder.

There isn't anything magic about SCL or loops. It simply gives you an easier way to write what would have been large amounts of code. All the normal rules of scans still apply. You start at the top, and work your way down to the end. The next time the code is executed, you do it again. The FOR loop simply means you call that code 5 times, with "i" having a different value each time.
 
I'm not too familiar with sending Ascii strings but shouldn't your command read AWT_1(channel,TRUE,data);

Can something like this be done (i don't have RSlogix 5000 in front of me right now)

for i := 1 to 5 by 1 do
AWT_1(TRUE, channel, data);
AWT_1.EN = FALSE;
end_for;

Steve
 
According to the manual, the serial port instructions like AWT run asynchronously to the scan.

I would try to concatenate the data together and then send it out the serial port in a single AWT command.
 
Last edited:
Just a reminder, I'm working with Connected Component Workbench.

This may work:
AWT_1.IN := False; "This would be equivalent to a ladder scan with AWT_1 "NOT ENABLED".

I will have to test.

MK42 I think I understand your concept here also, as it may work too!
 

Similar Topics

I have an expression in a structured text routine of a Logix controller that looks more or less like the following: ResultInteger := Integer1 *...
Replies
13
Views
379
Good evening. I display the step number of a SFC on a display. Sometimes, on a trip, it goes quickly through many steps and I need to prove to...
Replies
1
Views
125
I am trying to set up a piece of equipment with a Horner HE-X4R. I'd like to use structured text and so far I'm just trying to get a basic On/off...
Replies
0
Views
70
Good morning. I'm doing a rehab and I need to recycle some part of the old code that won't change and that I need. This is a calculation that...
Replies
22
Views
1,357
I'm writing some structured text that's handling a data structure that comes from a PC. The PC structure is in the "new" LREAL 64-bit floating...
Replies
3
Views
485
Back
Top Bottom