by pebe » Sat Apr 26, 2014 3:30 pm
Here is your circuit with some modifications. R4 has been added so that the output of the comparator can pull point (A) higher or lower to give some hysteresis. R4 has been calculated as 10.198K but 10K should be near enough. One of your 4K7 resistors has been replaced with a 5K pot so that the voltage at point (A) can be adjusted during set-up.
The LM339 is a comparator – not an op-amp, so it has no internal pull-up for its output. When its output is low, a transistor switches the output to ground. But when the output is ‘high’ the transistor is o/c and R4 relies on R2 and R3 to pull it up. So don’t change any of the resistor values, otherwise the input voltage swing of 6V to 4.3V will be wrong.
To set up,
-1). Connect the inverting input of the comparator to 0V and switch on. Its output will then go high.
-2). Adjust P1 to give 6V at point (A).
-3). Connect the inverting input of the comparator to 12V. Its output will then go low, turning on the relay. Point (A) will then change to 4.3V
-4). Disconnect the inverting input of the comparator and connect it to your sensor.
With an input of 6V or more, the relay will be ON
With an input of 4.3V or less, the relay will be OFF.
Changing the value or R3 from 1K to 3K3, should still give ample base current for the transistor to switch the relay.
Best of luck.
- Attachments
-
- Hysteresis Amp.GIF (3.61 KiB) Viewed 26938 times