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

Use of counters in SFC

Trompdelft
2016-10-10
2016-10-11
  • Trompdelft - 2016-10-10

    I am looking for simple examples for using counters in SFC. Is there anyone who can help me
    I just tried to introduce counters with structured text but it doesn't work. I can use function blocks but there should be a more simple way. It is very hard to find examples.

     
  • wollvieh

    wollvieh - 2016-10-10

    hey,
    what is the problem ?
    can you tell , what you really want do to ?

    Example :

    var
    counter : DINT;
    endvar

    IF (xxx = true)
    THEN
    counter := counter + 1;
    END_IF

    IF (counter > 3)
    THEN
    ;( do something )
    ELSE
    ;( do another thing )
    END_IF

     
  • Trompdelft - 2016-10-11

    Thank you very much for your reply !

    What I want to do:

    Develop Codesys lessons (simulation with hardware) with PLC's for second year students at applied sciences level, mechanical engineering.

    A simple assignment with three pneumatic cylinders who move in a machine-simulating sequence, with some delay (timer) and some repetition (counter). That's all. (cylinders move in and out, and sensors detect start and end positioning)

    I am relatively new (just work for about a year with Codesys) and work with SFC, which I understand now more or less.

    Can you specify the sentence "do something" ? could that be a SFC transition, for instance cilinder B is 'in' and sensor b0 is active.

    And how to reset the counter ?

    IMG: CDS.JPG

     
  • wollvieh

    wollvieh - 2016-10-11

    look at the small sample i made, maybe it is helpfull...

    Although usefull : search in CODESYS Documentation for SFC Flags...

    IMG: sfc.JPG

    IMG: sfcflags.JPG

    sfc.project [103.84 KiB]

     

Log in to post a comment.