capture time between rising edge of 2 pulses

EICS

Member
Join Date
Dec 2008
Location
Melbourne, Australia
Posts
321
i need to capture the time between the rising edge of 1 pulse and the rising edge of the next pulse after it.


i have a flow meter that gives a pulse for every 10 litres. i need to calculate the approximate flow rate in Litres/second


i am using an ABB AC500 (PM554-ETH) with codesys.


any one done this before? even if done in a rockwell plc i can recode.



thanks in advance.
 
Couple of thoughts, start a timer(RTO) and a counter to count the pulses. Make it so the timer will run as long a counter is (Let's say less than 100) when counter hits 100 timer will stop, then divide the total run time by (100 x 1 liter) that should give you a estimate on flow rate.

Create an array of let's say 100, now every pulse move the time stamp into an array variable. Computer the difference between the time stamps for every pulse. This should also give you a rough idea of flow rate.
 
The timer can be run off off a one-shot (or R_TRIG, if you prefer).

The caveat to this method is that it only stores the result from the last pulse. If there is no flow, there is no indication of it. An alarm can be attached to the output of the timer. My sample is set to 5 minutes, but you can change it to whatever is reasonable.
.
.

2018-06-20_6-47-01.jpg
 
Many thanks Jordan. This is very helpful.
I will give it a go tomorrow onsite.

Much appreciated.

I love codesys after 30 + years of using the rockwell virus
 
In the AB downloads section of this forum there is a file that calculates MPH speed between 2 sensors. Changing the time calculations would allow this to calculate pretty much anything.

"MPH Between 2 Probes.RSS "
 
Hi Jordan, many thanks works VERY well.


Excellent help.


Regards
Alan



The timer can be run off off a one-shot (or R_TRIG, if you prefer).

The caveat to this method is that it only stores the result from the last pulse. If there is no flow, there is no indication of it. An alarm can be attached to the output of the timer. My sample is set to 5 minutes, but you can change it to whatever is reasonable.
.
.
 
Using a TON would run the risk of loosing pulses if the rate goes up to high.
Why not use a high speed counter and look at the rate or frequency of the input.
A counter only looks at the leading edge of an incoming pulse to calculate the rate.
with a little math you could easily calculate the tine between the 2 pulses and not have to be concerned about missing a pulse.
 
This is the right way to do it.

Using a TON would run the risk of loosing pulses if the rate goes up to high.
Why not use a high speed counter and look at the rate or frequency of the input.
A counter only looks at the leading edge of an incoming pulse to calculate the rate.
with a little math you could easily calculate the tine between the 2 pulses and not have to be concerned about missing a pulse.
TON blocks will only go on when the scan gets to the TON block. The pulse can come at any time. Rely on software as little as possible.
Someone above mention time stamps. This would be good if the time stamps have micro second resolution.
 
all valid points mentioned above.


i should have mentioned that my flow rate is slow, i get one pulse (10 litres) between 1 and 10 seconds depending on the flow rate used in the process.


Jordan's code works well for the application i have for a slow frequency input.


many thanks for all the responses, most helpful.
what a great wealth of knowledge on this forum
 
Here's a simpler way, you have 1 pulse for very 10 Liters
Your flow rate is slow.
Count the pulses for 30 sec.
Multiply the pulses counted by 10
Device the result by 30
Reset the counter and start over
The result will be the liters per sec.

You don't need to know the time between the pulses just the number of pulses received.
 
Here's a simpler way you have 1 pulse for very 10 Liters
your flow rate is slow.
count the pulses for 30 sec.
multiply the pulses counted by 10
device the result by 30
reset the counter and start over
the result will be the liters per sec.

you don't need to know the time between the pulses just the number of pulses received.


simple and excellent idea. i have configured and completed my task today. i do like this idea, thank you Gary
 

Similar Topics

Hi All I have a very simple logic with some light sensors and RFID reader, which are providing start and stop events for capturing some short...
Replies
10
Views
2,722
Working on a project using MQTT and an Automation Direct Click Plus. Have the bidirectional communication pretty much figured out. One of the...
Replies
1
Views
1,446
Is there anyway to replay the capture file from a PC to simulate traffic on a network. This would be to allow testing of some sensors and check if...
Replies
1
Views
1,058
Hi all, Let's say we have a nice real (analog) value that has already been scaled with an SCP in Studio5000. Is there a slick method to...
Replies
6
Views
1,569
Hi, I want to capture a value from variable A (e.g Temperature) when certain conditions are met and write this value to another variable B...
Replies
2
Views
1,502
Back
Top Bottom