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,503
Hi Everyone. Not posted on here for a long time, but I am hoping someone can help me. I am doing a differential pressure calculation in a L27ERM...
Replies
15
Views
268
Hi, how do I convert 2x Integer registers to a Real? The two integers are from Modbus registers that contain a floating point value, I need to...
Replies
2
Views
121
What is the best way to extract the hour and minute from the register that comes from Yaskawa VFD. In studio 5000 I have a register saved as INT...
Replies
3
Views
125
I have an Allen Bradley temperature switch that I am trying to use in studio 5000. I am getting the message "Unable to interpret the IODD file"...
Replies
0
Views
76
Back
Top Bottom