I am in the process of building a water meter counter using a Pycom Lopy. The Lopy operates at 3.3v but my input sensor which is a metal detector (K1208065) uses 12V.
Someone else has already build a similar counter using a raspberry PI with a piface. This is the circuit that is used:
I bought the reed relay (SIL121A7272L) as described in the circuit. However I couldn't get it to work. What I did to troubleshoot is:
- Measured resistance between pin 3 and 5 (1k resistance as expected)
- hooked up a multimeter in continuity mode on pins 1 and 7, I expected that when detecting metal (pull down the signal) the continuity mode would buzz. However that did not work.
- Tried swapping the coil and switch pins (opposite from what is described in the circuit)
- Tried using another reed relay, I actually bought two.
After I could not get the circuit to work, I decided to protect my input pin using a simple voltage divider. I used 100k and 33k values, because that is what I had laying around. The result was a voltage of 2.98V which is detected by the Lopy as "HIGH", but the signal is not stable. It jumps around from "HIGH" to "LOW" every now and then.
My thought is that this might be because of the resistor values being to high, is this correct?
Any thoughts on getting the reed relay to work, or getting the voltage divider stable are very welcome. Any other solutions to protect the input are welcome as well.
Best Answer
The sensor is shown here
It says that it has a PNP output switch with positive logic output.
This means that the output (black) is open circuit when off and outputs V+ when on.
The reed relay needs to connect from output to ground = (based on your image) Black (output +ve) to blue (ground).
If your uC (microcontroller requires a 0/3.3V signal you could divide the output by 4 to give 0/3V operation.
eg 39k + 10k from output to ground with output from the centre point.
Your 100k / 33k may be OK - but the Pi-Face will have some upper limit to the input impedance. Even eg a 10k/3k3 will probably be acceptable as that draws only 12V/(10k + 3k3) or ~~= 1 mA from the sensor.
Variation in the output can be "slowed" using a capacitor from centre tap to ground or even in this case from the sensor output to ground.
Divider point to ground = slower on than off.
Sensor out to ground = fast on, slow off.
Too big a capacitor on sensor output MAY damage it.
Time constant on R centre point is ~~ C x (resistance of two R's in parallel) for turn on and C x Rlower for turn off (if PiFace input resistance is high.)
What is the meter maximum output pulse rate?