Electronic – Interfacing a flow control sensor with a microcontroller

microcontrollersensor

How can I interface this sensor with a microcontroller?
It has a normally open output and it will work @ 24V.
If I feed the BK contact from the sensor to a pin of the microcontroller through a voltage divider, would that be a good design?

Best Answer

An open collector PNP is a bit uncommon, but nothing to worry about. When the PNP is switched on (the switch in the diagram) V+ is switched to BK, so then the level will be +24V DC. If the transistor is off, BK would be floating (it's an open collector) so you'll have to place a pull-down resistor to ground.
If you place two resistors in series here, you'll have the voltage divider you need to reduce the 24V signal to e.g. 5V. For a 5V microcontroller the top resistor can be 18k\$\Omega\$ and the lower 4.7k\$\Omega\$ (that's the ratio anyway).

If you want isolation between the flow sensor and your microcontroller you'll have to use an optocoupler, like the CNY17. Make one of the resistors a 1k\$\Omega\$, and replace the other one by the optocoupler's LED. It doesn't matter which one goes where, but pay attention to the LED's orientation.
The collector of optocoupler's output transistor goes to your microcontroller, with a 10k\$\Omega\$ pull-up resistor to the microcontroller's power supply. The emitter goes to ground.