0
\$\begingroup\$

I've previously built this circuit to control a submersible pump with a PIR sensor:

enter image description here

I'm now going to add a float switch to the circuit to prevent the pump running if the water level gets too low. I would like to also include a green LED when the switch is on (sufficient water level) and a red LED when its off (low water level).

enter image description here

The circuit would therefore look like this with the inclusion of a red LED, however I can't think how to implement the red LED to be on when the switch is off and then to turn off when the switch is on (the inverse of the green LED's behaviour). Any pointers would be appreciated.

Note: R1 is meant to be 47k and a 1N4004 diode is across the motor

\$\endgroup\$
2
  • \$\begingroup\$ Does the float switch have both an NO and an NC contact by chance? You could add a relay in to give you that functionality, then it is pretty simple, the float operates the relay, use the NO side for the Green LED and the NC side for the Red LED... \$\endgroup\$
    – Ron Beyer
    Nov 11, 2017 at 5:47
  • \$\begingroup\$ It can be either NO or NC but not both unfortunately \$\endgroup\$
    – Seano
    Nov 11, 2017 at 5:53

3 Answers 3

1
\$\begingroup\$

This would be a very simple modification that might be acceptable.

schematic

simulate this circuit – Schematic created using CircuitLab

When the switch is closed, \$Q_1\$ is off and the red LED is also off. When the switch is open, \$Q_1\$ receives base drive via the green LED and \$R_2\$ and \$R_3\$, sufficient to turn on the red LED. The green LED current will be cut down by a factor of about 20 (about \$1\:\textrm{mA}\$), so it won't be nearly so visible. There may also be some "leakage" into your pump/PIR circuit via \$R_3\$, but I don't think that will cause you trouble. You might want to lower \$R_1\$'s value, just in case. So this may, or may not, be acceptable in your circumstance. You'll have to decide. But it's easy to understand and implement.


Just for completeness, the "inverter" circuit that I believe was suggested might look like the following:

schematic

simulate this circuit

But the price paid here is that the red LED current either goes through the red LED or else it goes through \$Q_1\$. But the current is always present. So you pay an added price in current draw. That may also be acceptable, though.

\$\endgroup\$
8
  • \$\begingroup\$ Seems like a weak pull down is needed tho \$\endgroup\$
    – Passerby
    Nov 11, 2017 at 8:07
  • \$\begingroup\$ @jonk is there a way to prevent or further limit the leakage via R3? Also how do I go about selecting a suitable BJT for this application (I have some experience selecting MOSFETs but have yet to use BJTs)? \$\endgroup\$
    – Seano
    Nov 12, 2017 at 1:00
  • 1
    \$\begingroup\$ @Seano Any PNP would do the job. The switch is carrying the motor current. When open, the PNP only sees very low current needed for the red LED. So any junkbox thing would do it, likely. I don't think the leakage will be a problem. But you should test it and see. The motor will NOT operate through \$R_3\$, that's for sure. But it's worth seeing what the PIR does to make sure. You could double the \$R_3\$ value to lower it still further without changing behavior to lower the leakage still further if that turns out important. Otherwise, it's a topology change. \$\endgroup\$
    – jonk
    Nov 12, 2017 at 1:32
  • 1
    \$\begingroup\$ @seano just a thought, but you should be careful using your float switch like that. In the instance that you are close to its switching point it is quite likely to bounce between on and off. Your pump is also reasonably high powered, so you're putting a decent current through a bouncing switch. This circuit will be fine in the lab, but in the field I would have the float acting as a low power switch with hysteresis. \$\endgroup\$
    – awjlogan
    Nov 28, 2017 at 0:41
  • \$\begingroup\$ To clarify, the hysteresis would be mechanical. You could also use a circuit that would latch off until reset, which is probably cleaner given the solution @jonk has given. \$\endgroup\$
    – awjlogan
    Nov 28, 2017 at 1:16
1
\$\begingroup\$

Well, can't you just use a complementary NOT gate near the green led to power the red one?

NOT gate example electronics-tutorials.ws

(Source image from this webpage)

\$\endgroup\$
2
  • \$\begingroup\$ Applying that to my circuit would the resistor coming from A be in parallel to my green LED? @UtkarshBajpai \$\endgroup\$
    – Seano
    Nov 11, 2017 at 6:00
  • \$\begingroup\$ Yes, A would be in parallel, to the green LED. \$\endgroup\$
    – marymarlo
    Nov 11, 2017 at 6:12
1
\$\begingroup\$

To add to the comments from jonk's answer, there is a problem in using the float switch to directly connect to the battery. When the water level approaches the switch set point, the switch will bounce indeterminately between on and off. This is a common problem when one has an on/off threshold for a slowly varying\$^1\$ analog signal, and can be addressed with hysteresis. This means that the on and off points are different, and the output will latch to on/off until the signal changes enough to reach the other set point.

In this system, the pump draws a fairly high amount of power, which you do not want pulsing on and off rapidly. It's usually best to have low power switches. Low power switches are usually cheaper, smaller, and there's often more choice.

A potential solution is shown in the schematic below. You can use a 4001 quad NOR IC, which will run directly from the 12 V supply you have (I haven't included decoupling etc) and as it's CMOS draws very little current. CMOS logic cannot drive much current (about 3 mA with a 12 V supply), so there's a small MOSFET to drive the red LED. The resistor values are fairly arbitrary.

schematic

simulate this circuit – Schematic created using CircuitLab

The main feature is the use an SR (set/reset) latch to hold the state of the float switch until actively reset using the other button; this provides the hysteresis. When the float switch pulls one input of NOR2 LOW, the output of NOR2 goes HIGH, and is then fed back to NOR1. NOR1's inputs are both now HIGH, and so it's output is LOW. The red LED will be on when the output of NOR2 is high (which is what you want). The system is now latched in this state until the opposite process with the Reset switch. The reset switch can either be manual, or you could (for example) have another float switch higher up in the tank so when the water reaches this point, the system will run again. Anything that will pull that input LOW in response to a higher water level is fine.

The other NOR gates generate the correct outputs given the system state: the pump is only on when the PIR output is HIGH, and the output from the latch is LOW.

\$^1\$ "Slowly changing" is relative to the speed of the switching element. A high speed comparator, for example, could switch in one nanosecond and so a slow signal in that application could be MHz in frequency. A mechanical switch may switch in milliseconds.

\$\endgroup\$
10
  • \$\begingroup\$ Thanks for your great answer @awjlogan. Just confirming, would a FQP30N06L mosfet work for M2 in your design? I believe it would be appropriate but confirmation would be great...Had to buy a bunch of them when I bought for M1 so would be ideal \$\endgroup\$
    – Seano
    Dec 11, 2017 at 0:17
  • \$\begingroup\$ No problem @Seano - your FQP30N06L will work, hugely overkill but if you have them to hand, why not :) \$\endgroup\$
    – awjlogan
    Dec 11, 2017 at 20:35
  • \$\begingroup\$ so I'm finally getting around to building this and have one final question. If I were to use a normally closed switch for the Reset (upside down float switch so that it will open once the water level is at its limit) and use a PNP BJT to invert its signal for NAND1, how would I actually go about fitting the BJT into the circuit for this funcitonality? @awjlogan \$\endgroup\$
    – Seano
    Jan 5, 2018 at 8:44
  • 1
    \$\begingroup\$ @Seano No need, just swap the position of R2 and Reset and that will do the same thing. When the switch is closed, the input will be HIGH and when it opens to reset, the input will be pulled LOW. \$\endgroup\$
    – awjlogan
    Jan 5, 2018 at 10:05
  • \$\begingroup\$ NAND4 should actually be a NOR gate right? \$\endgroup\$
    – Seano
    Sep 24, 2018 at 3:05

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.