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.
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?
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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;
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;
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
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
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