Studio 5000: Working on Structured Text Commands, and...

AutomationTechBrian

Lifetime Supporting Member
Join Date
Jul 2013
Location
St. Cloud, MN
Posts
669
I'm working on learning Structured Text, and I'm stuck on something so simple:

I have an If-Then statement using Bool tags, and I'm having a hard time understanding why this doesn't work...

If Homing_Process and NOT Homing_Complete then Machine_State_Homing := 1;

NOT is not working. Both Homing_Complete and Machine_State_Homing are 1. Is there another way to write the not-bit?
 
I'm hovering the cursor over the tags, which shows me the current value. Everything starts out 0. After homing, all three tags are 1s. I could do this simply in ladder logic, but I can see ST will be a great tool, once I learn it better. So I'm working through the learning curve.
 
If it's the same as Siemens you have set the bit but have no reset.

You can use

If Homing_Process and NOT Homing_Complete
then Machine_State_Homing := 1
else Machine_State_Homing := 0;

or (in Siemens at least) you could simply use

Machine_State_Homing :=
Homing_Process and NOT Homing_Complete;
 
Have you checked your syntax?



If Homing_Process and not Homing_Complete then
Machine_State_Homing :=1 ;
End_if;


This works for me.


Steve
 
I know nothing about structured text but do spend a too much time on PLCtalk.

maybe this

If Homing_Process and NOT Homing_Complete then Machine_State_Homing [:= 1]

See http://www.plctalk.net/qanda/showthread.php?t=78088


This is correct. If your familiar with ladder, think of :=1 as a OTL. You need a condition of := 0 to “unlatch” your expression.

Think of [:= 1] as an OTE, the bit will be a 1 if the expression is true, in other words, not retained.
 
I'm hovering the cursor over the tags, which shows me the current value. Everything starts out 0. After homing, all three tags are 1s. I could do this simply in ladder logic, but I can see ST will be a great tool, once I learn it better. So I'm working through the learning curve.




The logic in the OP
If Homing_Process and NOT Homing_Complete then Machine_State_Homing := 1;
is equivalent to an OTL (latch), so if ever Homing_Process was 1 and Homing_Complete was 0 on the same scan, then Machine_State_Homing would have been assigned a 1, and would remain 1 after either of the inputs changed, no?
 
Just got off the phone. I haven't read your responses yet because I'm on-site. I found a solution before he did. I switched it around:

Machine_State_Homing := Homing_Process and NOT(Homing_Complete);

That worked. I don't know why the other didn't, but I'll look at that later on when I'm home.

ST will be a big deal for me. The math is so much easier. This is changing the way I think about solutions.
 
Just got off the phone. I haven't read your responses yet because I'm on-site. I found a solution before he did. I switched it around:

Machine_State_Homing := Homing_Process and NOT(Homing_Complete);

That worked. I don't know why the other didn't, but I'll look at that later on when I'm home.

ST will be a big deal for me. The math is so much easier. This is changing the way I think about solutions.




Yah, that changes the logic from an OTL to an OTE i.e. Machine_State_Homing is assigned a value on every scan; in the OP logic that is not true.




Specifically:


This:
If Homing_Process and NOT Homing_Complete then Machine_State_Homing := 1
is equivalent to this:

Code:
   Homing_Process  Homing_Complete  Machine_State_Homing
---] [-------------]/[--------------(L)--------------------
and this:
Machine_State_Homing := Homing_Process and NOT(Homing_Complete);

(and probably also this:
Machine_State_Homing := Homing_Process and NOT Homing_Complete
)
is equivalent to this:
Code:
   Homing_Process  Homing_Complete  Machine_State_Homing
---] [-------------]/[--------------( )--------------------
Sorry I didn't see it sooner.
 
Last edited:
I personally like the "equation" form (A = B AND C). It is just more clear to me. However, if you are more of an IF-THEN type person, the OTE equivalent requires an ELSE:

IF (B AND C) THEN
A := 1
ELSE
A :=0
END_IF

Keith

P.S: Sorry, missed the post by bb76 which says exactly the same thing. My eye skipped right over that.
 
Last edited:

Similar Topics

I am using Studio 5000 Version 30 and Compactlogix. I have a recipe created in a UDT structure, with a string value called name. There are 50...
Replies
7
Views
5,374
Compactlogix controller, program has 28 conveyors that use TON's to start the conveyors. The TT sounds a warning horn during start and the DN...
Replies
7
Views
159
I have to start out by saying I am not a PLC programmer and I have basic programming skills but mainly use software as a troubleshooting tool. I...
Replies
0
Views
49
Hi everyone, I was wondering how we declare Persistent Variables in Studio 5000 (main reason to keep the values during power cycle and program...
Replies
5
Views
185
I'm adding an IAI Gateway with 2 axes connected to it. To an ethernet network on my PLC. So, I think the math is correct on the Input and Output...
Replies
0
Views
72
Back
Top Bottom