0
\$\begingroup\$

I would like to use 2 magnetic proximity sensors (normally open reed switches) to determine the position of a chicken door (vertical sliding door) which in turn controls a motor. If the door comes within reach of the first (lower) switch, the motor should slow down some. When both switches are closed, the motor slows down even more and finally when only the second (upper) switch is closed the motor stops completely.

I would like to use a simple circuit that generates a voltage that can be read with a single GPIO (ADC). I would prefer an output that matches the following truth table:

(S1 = bottom switch, S2 = top switch, x = open circuit)

S1, S2, Output
 x   x  0V 
 1   x  1.6V 
 1   1  3.3V
 x   1  5V

The output does not need to be in that order, but it needs to be distinguishable (at least 1/4V between states).

If at all possible, I would like to use only discrete components.

\$\endgroup\$
3
  • \$\begingroup\$ Using 2 GPIOs means using no extra components. \$\endgroup\$ Commented Feb 26, 2015 at 22:11
  • \$\begingroup\$ Can you add a truth table that shows exactly what the switches are doing? Show the truth table in the order that the switches operate: which switch changes state first, etc. \$\endgroup\$ Commented Feb 26, 2015 at 22:13
  • \$\begingroup\$ S1 is the first (bottom) switch, S2 is the second (top). S1 will close first, then S2 will close (S1 still closed), then S1 will open but S2 will remain closed when the door is fully up. \$\endgroup\$ Commented Feb 26, 2015 at 23:04

1 Answer 1

2
\$\begingroup\$

I think using 2 digital inputs is the way to go, but absent that, you want to build a 2-bit Digital to Analog Converter.

http://tabatha.esg.utulsa.edu/digital/pages/r2r-alt.gif

This pic, from http://tabatha.esg.utulsa.edu/digital/pages/r2r-alt.gif, shows a 3 bit converter. You would simly omit the bottom bit, leaving off the 2K resistor at V1 and the 1K resistor attached to it.

You won't get your table, but you will get unique voltages for each bit. For this 2-bit converter, if your switches provide 5V, one bit will add 2.5V to the output, and the other will add 1.25V. So, none on would be zero volts, if the switch attached to the LSB is on and the other off, you'll have 1.25V, if the switch attached to the MSB is on and the other off, you'll have 2.5V, and if both are on you'll have 3.75V

Your issue with this approach will be implementing it with SPST reed switches. You may need an op amp buffer on each one.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.