Captron
Posts: 8
Joined: Tue Dec 12, 2017 2:52 pm

12V Simple Pulse detection and count on Pi3 help12

Tue Nov 27, 2018 6:44 pm

(CHANGE TITLE TO 12v)
This may have been done to death (but with mostly dead links) however as a newby, I think this is a bit different: I want to be able to cheaply and accurately count pulses every second from a Water Flow Meter in order to calculate flow (L/Min). Programming is Python.

I am building a complicated controller with over 16+ inputs on piggy back input cards and a dozen outputs. It is working now, but this one pulse issue is giving me grief.

The flow meter set up: 3 Wires, V+, common and Pulse. V+ can be 4.5 to 18V, with 12v prefered for powering reasons, as my particular configuration has a 12V power supply back feeding the pi voltage through another RTC card. This means 12v would be the powering of choice, still too high for the Pi. Could possibly use a resistor to drop voltage I suppose, but risky if I use a GPIO pin. Serial input cards are analogue thermistor (PT1000) resistance (or ma) centric.

The output pulse is derived internally from the flow sensor and the pulse is V+ to common square wave pulse. By that I mean, if the V+ is 12V then the square wave is 12v peak to 0V. Obviously timing and ultimately flow is based on pulse duration.

In a perfect solution, I would like to find a D/A card/hat for the pi that can provide a pulse count or even an analogue out for my serial input cards to understand.

Any ideas?

Idahowalker
Posts: 570
Joined: Wed Jan 03, 2018 5:43 pm

Re: 12V Simple Pulse detection and count on Pi3 help12

Tue Nov 27, 2018 6:54 pm

An opto-isolator between the 12V signal and the RPi.GPIO
Idaho, U.S.A.

ghp
Posts: 1598
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: 12V Simple Pulse detection and count on Pi3 help12

Tue Nov 27, 2018 8:23 pm

Hello, found a nice device which possibly matches your needs: https://www.exp-tech.de/zubehoer/labor/ ... -totalizer
Another option would be to use an adafruit feather, backed up by a battery, fast as a 120MHz Cortex M4. You could use digital serial, SPI or I2C to talk to the raspberry.
And of course use an optocoupler to isolate from high voltage inputs.

onlinegill
Posts: 45
Joined: Sun Oct 14, 2018 1:57 pm

Re: 12V Simple Pulse detection and count on Pi3 help12

Wed Nov 28, 2018 5:23 am

what about 5v or 12 dc relay ?
i am using following 5v relay to power up 24vdc solenoids along with npn transistor
https://rover.ebay.com/rover/0/0/0?mpre ... 1869298037

Captron
Posts: 8
Joined: Tue Dec 12, 2017 2:52 pm

Re: 12V Simple Pulse detection and count on Pi3 help12

Wed Nov 28, 2018 5:16 pm

3 Very good ideas.

Not sure how an opto-isolator would help, you would still have a digital signal would you not? How does this link to the Pi?

ONlineGill I am also not sure how relays would help

Closest so far is the device indicated by GHB. Costly though.

Cheers

User avatar
paddyg
Posts: 2591
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: 12V Simple Pulse detection and count on Pi3 help12

Wed Nov 28, 2018 7:15 pm

I probably misunderstood your question but couldn't you use two resistors as a voltage divider? With optoisolator if the pulses might have stray spikes.

The optoisolator would connect your gpio pin to ground and you would set the pin to pull up, the external pulse would then effectively be like closing a switch once per pulse.
optoiso.png
optoiso.png (24.85 KiB) Viewed 2765 times
Last edited by paddyg on Sat Dec 01, 2018 6:18 pm, edited 1 time in total.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

ghp
Posts: 1598
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: 12V Simple Pulse detection and count on Pi3 help12

Wed Nov 28, 2018 9:04 pm

Hello,
think there are two problems to solve for a precise and reliable flowmeter application.
(1) is an interface problem. Flowmeters usually have hallsensor with open collector output. Usually you have long distances from computer to appliance, which raises interference, spikes, radiofrequence problems. Optocoupler close to the pi help solving this problem, also ensure galvanic separation. A series resistor on 12V side limits current.
(2) impulse count. There is usually one tick per a certain volume. As raspberry are sometimes rebooted, programs not always running or not very reliable, it is clear that an independent controller dedicated for this purpose is a need. Battery backup ensures that no ticks are lost. Debouncing or jitter removal is needed. The pi only needs to read absolute value updates from this device. A simple microcontroller can do this, the "feather" I proposed has a LiPo charger on board which ensures that no ticks are lost.

Captron
Posts: 8
Joined: Tue Dec 12, 2017 2:52 pm

Re: 12V Simple Pulse detection and count on Pi3 help12

Fri Nov 30, 2018 9:08 pm

Some great ideas here, my thanks.

For clarification: I am not required to load the pi down with an ongoing pulse detection. I would guess counting pulses over 200ms and then again after one minute would be sufficient to provide an averaged assessment of flow over long periods of time.I like the idea of opto-isolation.

Cheers.

Captron
Posts: 8
Joined: Tue Dec 12, 2017 2:52 pm

Re: 12V Simple Pulse detection and count on Pi3 help12

Sat Dec 01, 2018 3:57 pm

Just wondered: Has anyone tried or know if this can help:
AD/DA PCF8591 Converter Module for Arduino Raspberry pi: Analog To Digital To Analog Converter. I see it has what appears to be a light sensor but no idea why. There are no specs.

https://www.ebay.com/itm/AD-DA-PCF8591- ... 0167.m2940

or

https://www.ebay.com/itm/PCF8591-AD-DA- ... 0005.m1851

Captron
Posts: 8
Joined: Tue Dec 12, 2017 2:52 pm

Re: 12V Simple Pulse detection and count on Pi3 help12

Sat Dec 01, 2018 4:00 pm

SOrry I now see one brief description:
Features:
Data link:
https://www.mediafire.com/file/h3z95zke ... 1.zip/file
Single-Supply Operation
PCF8591 operating voltage range of 2.5V to 6V
Low standby current
Through the I2C bus serial input / output
PCF8591 by 3 hardware address pins addressing
Sampling rate PCF8591 I2C bus rate decided
4 analog inputs programmable as single-ended or differential inputs
Automatic incremental channel selection
PCF8591 analog voltage range from VSS to VDD
PCF8591 built-in track and hold circuit
8-bit successive approximation A / D converter
Through an analog output DAC gain


Package Included:
1pc * PCF8591 AD/DA converter module
4pcs * 20cm Dupont Wire

ghp
Posts: 1598
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: 12V Simple Pulse detection and count on Pi3 help12

Sat Dec 01, 2018 6:10 pm

Hello, the PCF8591 is a 8-bit A/D and D/A converter used for example in Pi2Go robot. It does not directly solve the 12V to 3.3V level conversion you need and provides no isolation. If you go for an optocoupler solution, look for a 4N25 and a 1k resistor (which will need prox 10mA from the flowmeter). Paddy has provided the basic sketch, just add the 1k resistor on 12 V side. On gpio side, you can use basic GPIO logic with an internal pullup.

Forris
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 319
Joined: Fri Jan 06, 2012 7:46 pm

Re: 12V Simple Pulse detection and count on Pi3 help12

Sat Dec 01, 2018 6:24 pm

Correct me if I'm wrong, but your reason for wanting to power the sensor at 12V is that you're using a 12V supply to power the Pi?

In my experience, water flow sensors aren't exactly power-hungry, so should be quite happy being powered straight from the Pi's 5V pins, which would save an awful lot of messing around with level-converters, resistor dividers, or opto-isolators.

Captron
Posts: 8
Joined: Tue Dec 12, 2017 2:52 pm

Re: 12V Simple Pulse detection and count on Pi3 help12

Sun Dec 02, 2018 9:54 pm

From another site I was given this diagram is one possible option using a $1 optocoupler its much like the one paddyg provided. Maybe it will help others, I have not tested or ordered this yet.
OPtocouplerPC817-2018-12-02_1452.png
OPtocouplerPC817-2018-12-02_1452.png (31.29 KiB) Viewed 2742 times

User avatar
paddyg
Posts: 2591
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: 12V Simple Pulse detection and count on Pi3 help12

Sun Dec 02, 2018 10:13 pm

Where Vcc is 3V3 not 5V. Safer and simpler to just use pullup setting.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

Return to “Python”