# Converting pulses per minute (uneven pulse width) to analog output signal

#### Mahonroy

Joined Oct 21, 2014
315
Hey guys, I have a flow meter that outputs pulses based on the flow. 1 pulse per gallon of liquid.
There is a rotating mechanism inside the flow meter. The faster it rotates, the more pulses it generates:
1 pulse per minute, up to 40 pulses per minute. (same as 1 gallon per minute up to 40 gallons per minute).
Also, the faster the flow, the more narrow the pulse width is because the mechanism is spinning faster.

A typical application would be to count the number of pulses per minute and correlate that to flow.
Another option would be to count the time between pulses and correlate that to flow.

What I am wanting to do is to create a circuit that takes these pulses, and converts it to an analog signal (0vdc to 3.3vdc). I will then read this analog voltage and correlate that to a flow.

If the pulse widths were set to be the same, regardless of flow rate, then I could use a low-pass filter to convert this to analog.

But since the pulse widths decrease as flow rate increases, a low-pass filter will not work because the duty cycle isn't changing.

Is there another method for accomplishing this? I feel like if there is a way I could somehow normalize the pulse width of these pulses, then I could then use a LP filter, but I am not sure how to do that?

Thanks and any help is greatly appreciated!

#### jpanhalt

Joined Jan 18, 2008
10,087
Seems like an odd requirement in the digital age, but have you considered a low-pass filter?

#### Mahonroy

Joined Oct 21, 2014
315
Seems like an odd requirement in the digital age, but have you considered a low-pass filter?
Yes, but I mentioned above regarding the low-pass filter is that it would not work, because the pulse width decreases as the flow increases (proportionally because its based off a spinning mechanism, the duty cycle is not changing).

#### AlbertHall

Joined Jun 4, 2014
10,234

#### BR-549

Joined Sep 22, 2013
4,938
Why not detect the transition, and pair it with a time stamp(RTC). The stamps give you the number and length per time.

Compare that to a look up table for desired range.

#### LesJones

Joined Jan 8, 2017
2,687
You could trigger a monostable multivibrator from the rising (or falling.) edge of each input pulse. That way you would make the length of the output pulse constant. If these constant width pulses were fed into a low pass filter it should give the result that you want.

Les.

#### crutschow

Joined Mar 14, 2008
25,263
You could use a 555 non-retriggerable one-shot to give a short pulse (say 20ms), for every sensor output pulse.
But that will have a very low average output voltage when averaged over a minute for 1 pulse per minute (about 80mV).

How fast will the circuit need to respond when the flow rate changes?
The circuit above would need a LP filter with a several minute time-constant.

I think you may want to consider some sort of digital approach, such as measuring the pulse period.
This could be with a microcontroller, or a digital counter driving an LED display.
If you really need an analog output, that could be done with a DAC from the digital period.
That will respond within one pulse period to a change in flow rate.

Last edited:

#### crutschow

Joined Mar 14, 2008
25,263
He wants frequency to voltage conversion.

#### AlbertHall

Joined Jun 4, 2014
10,234
He wants frequency to voltage conversion.
See pages 9 and 10 of the datasheet.

#### Alec_t

Joined Sep 17, 2013
11,520
I agree with Crutschow. At only 1 pulse per minute a wholly analogue approach would be next to impossible and far from accurate.

#### djsfantasi

Joined Apr 11, 2010
6,716
A blue-sky idea...

1. Start with a pair of binary counters to count the number of pulses from the flow meter
2. Add a circuit to provide one pulse per minute. A 555/divider circuit for example. Use the output of this subcircuit to reset the counters in phase 1 (above).
3. Build an R2R ladder as a cheap DAC.
4. The output of the DAC circuit is an analog voltage corresponding to the flow rate.

#### CharlesWMcDonald

Joined May 16, 2019
233
I think you may want to consider some sort of digital approach, such as measuring the pulse period.
I agree, the only way to get an accurate measurement is with the period of the signal.

#### AlbertHall

Joined Jun 4, 2014
10,234
This could be accurate to ~ 12 bits -

This is a one chip solution, PSOC 4 or PSOC 5LP. Most onchip resources unused, see
right hand window.

Regards, Dana.
Yes, easiest with a microcontroller.

#### crutschow

Joined Mar 14, 2008
25,263
See pages 9 and 10 of the datasheet.
Okay.
But the long filter time-constant is still a problem.

#### Mahonroy

Joined Oct 21, 2014
315
Thanks for the suggestions so far!

I dug deeper into the 555 timer approach (monostable multivibrator), and here is what I have come up with so far (I simulated it):

The left graph is the flow meter pulse, the middle graph is the 555 timer output, and the right graph is the output passing through an RC filter.
I changed the frequency from anything from 0.666 Hz (40 pulses per minute), to 0.0833 Hz (5 pulses per minute), and it seems to work ok. Downside is its slow to stabilize at a value.... how it is now it takes about 4 minutes to stabilize.

I wonder if there is a way to essentially get the period, and convert that directly over to an analog reading... or a way to get more of an instantaneous reading instead of having to wait for the filter to stabilize?

The reason why I can't do it digitally with a microcontroller and timer is because the only interface I have available is I2C. For this project, I2C is the only interface I have available for this.... so I can use I2C to interface up to an ADC.... but I am not really aware of any other way to get this information via I2C... so it seemed analog might work. I can also only take a reading every couple seconds or so. So there is not really a way for me to time the pulses directly.

Joined Mar 10, 2018
4,057
This is a one chip solution, accurate to ~ 12 bits.

PSOC 4 or 5LP. Most resources still unused, see right hand window.

This also has I2C if you need to offload values.

Regards, Dana.

Last edited:

#### AlbertHall

Joined Jun 4, 2014
10,234
The microcontroller can make the measurement and do I2C.

#### Mahonroy

Joined Oct 21, 2014
315
The microcontroller can make the measurement and do I2C.
I can't use anything that needs to be flashed, it has to be components that don't require firmware.

#### Mahonroy

Joined Oct 21, 2014
315
This is a one chip solution, accurate to ~ 12 bits.

View attachment 179907

PSOC 4 or 5LP.Most resources still unused, see right hand window.

Regards, Dana.
This definitely looks interesting! So is this a specific chip that functions like this? I'm a bit confused on what specific components those might be.

#### djsfantasi

Joined Apr 11, 2010
6,716
Most Microcontrollers support I2C, but you say the following:
I can't use anything that needs to be flashed, it has to be components that don't require firmware.
Why?