Tuesday, 14 April 2015

analog - Replacing a tactile switch with an ultrasonic ranger


I'd like to have a switch activated when something gets near it. Today it's just a pushbutton, that's active as long as it's depressed.


I'm going to use an analog ultrasonic ranger, using its analog output. What I'd like to do is have an analog circuit activate a mosfet when a certain range threshold is hit. My question is - how do I make this "binary?" How do I have Vgs applied to the mosfet when the analog voltage on the ranger crosses a specific value? I thought about using a zener diode with the breakdown voltage at the distance that I need (the threshold I'm looking for is about 10" away from the device, which translates to ~100mV on the analog pin). Given the low voltage the sensor will output at that distance, I assume a zener won't work.


I'd like to not involve an MCU if possible, because I'd like this to be a simple drop-in.



Answer



A simple comparator circuit will do:


schematic


simulate this circuit – Schematic created using CircuitLab



U1 can be a slow, rail-to-rail CMOS part that costs under $1 - either a general purpose op-amp, or a dedicated comparator. Ensure that there's no diode between (+) and (-) inputs. Microchip has plenty of them, for example.


Since we assume push-pull outputs like on every op-amp, there's no need for any pull-up/pull-down resistors on the output of U1. If you use an op-amp, that'll be the case. With comparators - it varies.


The ratio of R3 to R4 sets the amount of hysteresis - here it's at 1%. The turn-on voltage is set by the ratio of R1 to R2, and given by VCC * R1/(R1+R2) * (1 - R3/R4). R5 isolates the gate capacitance from the amplifier's output, preventing the amplifier from oscillating.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...