Pulse count counter

mawaloc
2020-05-10
2020-05-10
  • mawaloc - 2020-05-10

    Hello

    I'm trying to make a pulse count.
    In my system , I've a sensor that gave me a speed. => ok for that
    MY PLC gave me also an input "pulse count". PI Sensor_Speedometer => Value type Word.
    I'm trying from this Input to get a total distance.
    As this value come back to 0, when PLC Power off; it's restart everytime to 0.
    So I would like to make a counter on the Rising edge of this input, and record this value.

    How it's possible

    Thank You
    Maxime

     

    Last edit: mawaloc 2020-05-10
  • aliazzz

    aliazzz - 2020-05-10

    Hi,

    Since we cannot see your code, apart from the snippet you have sent, we can only give you some hints and tips.
    Plus it seems to me you using a CODESYS v23 runtime?

    For;

    As this value come back to 0, when PLC Power off; it's restart everytime to 0.
    

    You may try to store the counter in a VAR RETAIN (search extra help on how RETAIN works) however this dependent on your CPU.

    For;

    So I would like to make a counter on the Rising edge of this input, and record this value.
    

    You can use a R_TRIG (Standard.lib) Function Block.
    You can accumulate the output count pulses of R_Trig (the .Q) value in a CTU (count up FB)
    Search the help (standard.lib) for extra help on these FB's.

    I Hope these hints help you further,

    Aliazzz

     
  • mawaloc - 2020-05-10

    Hi Aliazz.
    Thanks you for your comments

    Yes correct for that project I'm using Codesys 2.3.
    About store the value => "I'm" also Ok on this. My PLC Doesn't have "retain variable " But I know how to do.

    My problem is on the R-Trig function and after CTU function.
    For those FUNCTION my understanding is you need "Boolean" Input to get the counting.
    and here I don't have. It's a "word type" , or at least I don't know How to catch them.

    I'm a beginner so may be I'm totally wrong but it's my understanding

    Thank You

     
  • aliazzz

    aliazzz - 2020-05-10

    You should check what type of sensor you have and check/study the datasheet of it.
    You have to find out what the WORD represents. When you know this you can write some code to correctly read the information.

     

    Last edit: aliazzz 2020-05-10

Log in to post a comment.