DonNH

Structured text vs. Ladder

5 posts in this topic

OK, another probably basic issue.

I have a ladder program shown below which works as expected - Line 0 latches the start variable when I_SW1 (momentary contact) is pressed.

Line 1 unlatches the start variable by enabling I_Off when I_sensor4 is triggered (momentary contact).

Line 2 turns on light O_L1 when start is active, so it turns on when I_SW1 is pressed and turns off when I_sensor4 is pressed.

The remaining lines work as expected.

The structured text is supposed to work exactly the same. It does for everything except that start doesn't unlatch when I_sensor4 is pressed -- 

I_off goes to True, but start stays as True rather than going to False on line 1 of the ST program. Even if I force the start variable to False, O_L1 stays on.

If I force start to False then O_L1 to False, the light turns off.

???

ladder-new.png

ST-new.png

Edited by DonNH

Share this post


Link to post
Share on other sites

Instead of line 2 reading END_IF it should be an else statement

ELSE;

start:=FALSE;

END_IF;

In ST you need to set bits false, in LD coils do it automatically if preceding conditions aren't met.

1 person likes this

Share this post


Link to post
Share on other sites

Thanks!

Lots of little details for a newbie to learn.

Note that I also had to add the else statements after lines 3 and 5.

 

Edited by DonNH

Share this post


Link to post
Share on other sites

coil instruction is used to assign both true and false values:

variable := expression;

or in your case

start := (i_SW1 or start) AND NOT I_Off;
I_Off := start AND i_sensor4;
...etc.

 

1 person likes this

Share this post


Link to post
Share on other sites

I like that there are multiple ways of doing this.

Definitely see that there are different things to worry about between ladder and ST.

(edit) This ST program appears to mimic the original ladder program, except that the timers in line 6 & 7 leave their outputs in the ON state if sensor 4 is triggered before the timer runs out. I thought I fixed it by adding the AND NOT I_off in line 4, but now that doesn't work. Weird.

 

ST-short.png

Edited by DonNH

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now