Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

from ladder to st

suibaf
2016-04-13
2016-04-14
  • suibaf - 2016-04-13

    Excuse for my basic question. As you can see in the LADDER link I wrote a PRG in ladder and it work fine(ON and OFF the BUZZER_ON bit). I want to translate in ST, as you can see in the second link, but it does not work. Please can you suggest where I fail?
    BR

    IMG: Bild

    IMG: Bild

     
  • Anonymous - 2016-04-13

    Originally created by: scott_cunningham

    In ST, S= and R= are hardly used, if ever (I never used them over the last 10+ years). The following statement is effectively the same as a set coil in ladder:

    IF Timer.Q THEN
       Buzzer = True;
    END_IF
    

    This is because the variable is set when the IF is TRUE and is never reset to FALSE because there is no code line Buzzer = FALSE.

    Go back through your ST with this knowledge and see what luck you have.

    PS. I would suggest attaching your screen shots to your post and not use external locations like drop box - these links will fail after some years and some viewers will avoid following the links.

     
  • suibaf - 2016-04-13

    Hi,

    thank you very much for your answer.

    Zitat:
    I would suggest attaching your screen shots to your post

    How is possible to include image in my post? With img tag, as you can see above, I link always to dropbox.
    BR

     
  • Anonymous - 2016-04-13

    Originally created by: scott_cunningham

    Just below the submit button on the post, there is an "Upload attachment" section to attach files. Once you attach the file, you can add an IMG link in your post if you want to have the graphic inline.

    Here is roughly what your ST code could look like (not tested):

    Timer_Buzzer_Off(IN:=NOT(Buzzer_On), PT:=T#5S);
    Timer_Buzzer_On(IN:=Buzzer_On, PT:=T#100MS);
    IF Timer_Buzzer_Off.Q THEN
       Buzzer_On := TRUE;
    END_IF
    IF Timer_Buzzer_On.Q THEN
       Buzzer_On := FALSE;
    END_IF
    Test1 := Buzzer_On;
    

    The IF statements act like the SET/RESET functionality. Definitely not the only way to do it!!! (See TP() pulse timer, RS latches, etc). Just note this will not be exactly a 5.1 second cycle - it takes a PLC scan or two to reset/restart TONs (i.e. it will be longer than 5.1 seconds...).

     
  • ndzied1 - 2016-04-14

    I have a bit of a different take on this. Below is what I would do. I try to avoid using IF statements to turn on logic bools because many times there are issues with, where, how they get reset.

    VAR
       BuzzerTimer:    TON;
       BuzzerOffTime:  TIME:= T#5S;
       BuzzerOnTime:   TIME:= T#100MS;
       Buzzer_ON:      BOOL;
    END_VAR
    // Continuous Running Timer (Preset = Ontime + Offtime)
    BuzzerTimer(IN:= NOT(BuzzerTimer.Q) , PT:= (BuzzerOnTime+BuzzerOffTime));
    // Turn the Buzzer on if the elapsed time is less than the ONtime
    Buzzer_ON := BuzzerTimer.ET <= BuzzerOnTime;
    
     
  • Anonymous - 2016-04-14

    Originally created by: scott_cunningham

    Nice, n0rm!

     
  • suibaf - 2016-04-14

    Thank you very much!

     

Log in to post a comment.