Structured Text

dbh6

Lifetime Supporting Member
Join Date
Jan 2013
Location
Central, NJ
Posts
552
Hello everyone,

Ok, as i'am becoming a more advanced plc programmer, I have been on more and more service calls lately. Some programs i ran into are written in structured text, and coming from a electrical engineering background, it took me a while to trouble shoot. Anyways i have the sudden interest to understand how to write code in structured text, and i would like to know if anyone has, like a .pdf or a book online or something that i can use to build my knowledge, thanks.
 
first a general word of caution: be sure that you research and understand the difference between the two following assignment instructions:

:= and [:=]

they can give different results when the processor does a "Go-To-Run" operation ... programmers just starting out with Structured Text can be unpleasantly surprised by the differences ...

moving right along ...

if you used the default installation settings for RSLogix5000 then you probably have the following files in the SAMPLES folder of your program directory:

ST_GearChange.ACD

ST_Motion_Example.ACD

these contain some examples of Structured Text programming which you might find helpful ...

 
There isn't a [:=] instruction in structured text unless this is part of the new unreleased specification.

It is there in Structured Text in RSLogix 5000. It is used for a non-retentive assignment.

Reference:
Publication 1756-RM003k-EN-P - July 2008

Extract(Page 662) from the publication shown below.

Non Retentive Assignment.jpg
 
Last edited:
Even if RS has added an 'non-retentive expression' to RSLogix 5000 that is not part of the IEC specification, I cannot grasp it.
How can an expression be non-retentive ?
A Tag (i.e. a memory address) can be retentive. That I can understand.
Does it mean that in code you can turn the retentiveness of a Tag on and off ?
 
Like Jesper, i too am peplexed by this. What if I had several of these in a program:

myTag := Value_1
// some code
myTag := Value_2
// some more code
myTag := Value_3

Which value or expression would be retained? Presumably the last one processed.

Nick
 
Let me try to explain the difference between using a ":=" and a "[:=]" in RSLogix 5000 with a simple code.

Code:
Motor := (Motor OR  On) AND NOT(Off);

IF On

THEN

 Value := 70;

 END_IF;

When the above code is run, then when "On" becomes high "Motor" becomes High and "Value" becomes 70.Then if "On" becomes low
"Motor" remains high and "Value" remains 70.

After that if I make the controller go to "Program Mode", and then bring it back to "Run Mode", "Motor" still remains high and "Value" is still 70.

However if I code like this:
Code:
Motor [:=] (Motor OR  On) AND NOT(Off);

IF On

THEN

 Value [:=] 70;

 END_IF;

Then the same things happen when "On" goes high and then goes low as stated above but this time if then the controller is brought back to "Run Mode" after having switched to "Program Mode" the "Motor" becomes low and "Value" becomes 0,ie. they get reset.
 
Last edited:
I think I understand what the function does. But I am perplexed to find that to know if a Tag is retentive or not, you would have to trawl through all the code, and then interpret all the assignments and estimate if a conditional assignment was activated or not. Very confusing and very time consuming.
And what happens if a tag is written to from somewhere else, from an HMI for example ?
 
the way Allen-Bradley implements it in RSLogix5000 is this way:

:= is RETENTIVE and basically acts like an Allen-Bradley OTL (Latch) instruction in ladder logic ...

[:=] is NON-retentive and basically acts like an Allen-Bradley OTE (Output Energize) instruction in ladder logic ...

secret handshake: the Allen-Bradley processor handles the retentive and non-retentive assignments/instructions differently on PRE-scan – and in certain SFC (Sequential Function Chart) operations ...

the obvious discussion that this has generated proves my original point ... specifically, many programmers aren't aware of the differences - and sometimes unpleasant surprises are the result ...

party on ...
 

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
378
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,350
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