2
\$\begingroup\$

I have a tank with a water pump. I want to use two XKC-Y25 water level sensors to fill the tank, one sensor for the high level (let's call it SW1) and one for the low level (SW2). The sensors provide an open-collector output. Both PNP and NPN versions are available, and each sensor can be configured to have NO (normally open) or NC (normally closed) outputs.

In the diagrams I have shown the two water sensors (SW1 and SW2) as two switches to simplify things.

Basically, if the water goes below the SW2, the pump starts and fills the tank until the water triggers the SW1 sensor and the pump shuts down. Using both sensors in series doesn't work because when the pump starts, the water rises and deactivates the SW2 sensor, shutting down the pump. After many researches, I came up with this schematic with I think latching relays:

enter image description here

The lamp is the water pump. I tested with Tinkercad but it doesn't work. Before burning anything, what do you think?

EDIT. Thanks to your suggestions, here is the second version. Since I don't have a DPDT I used two SPST in parallel. The relays are the "SRD-12VDC-SL-C" (from the datasheet it says the nominal coil current is 30mA for "High sensitivity" and 37mA for "Standard", not sure which one I should consider). I added also the schematic of the two water level sensors: both are the "PNP version" where both of them have the MODE pin grounded so they output current only when there is no water. The PNP transistor is inside the sensor. The water pump in reality is a 24V DC electrovalve (I thought that it wasn't important). I added also a push button to trigger the valve even if the tank is not empty (thanks to @AnalogKid). I'm sorry for my ignorance but I'm not an engineer, this is just my hobby.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
19
  • \$\begingroup\$ I suggest you redraw and try again with the actual sensors instead of switches and then tell us exactly how it doesn't work. \$\endgroup\$
    – Finbarr
    Commented Sep 11, 2023 at 12:04
  • 2
    \$\begingroup\$ @fabius94 You can use the circuitlab built into this website for free. Or you can use your own downloaded version of LTspice or Microcap or KiCad. \$\endgroup\$
    – Hearth
    Commented Sep 11, 2023 at 15:04
  • 1
    \$\begingroup\$ The second version looks good. || As Analogkid notes - you can add a pushbutton across 1 as a start button if you want to fill the tank from an intermediate state. || Currents sound OK for sensors. \$\endgroup\$
    – Russell McMahon
    Commented Sep 12, 2023 at 10:11
  • 1
    \$\begingroup\$ OK, it is clear from page 10 of the datasheet (finally!) that the PNP version has an open-collector output stage that can source current by pulling the load up to its own internal operating voltage. It cannot sink current from the load to GND. Technically, it can pull up a load connected to a negative voltage, such as a 24 V relay operating on +/-12 V, but that is not a suggestion. Basically, the PNP version has Q1 and Q1 in your latest schematic built-in. \$\endgroup\$
    – AnalogKid
    Commented Sep 12, 2023 at 17:08
  • 1
    \$\begingroup\$ For the NPN version, page 10 shows an open-collector NPN transistor with a grounded emitter and an internal pull-up resistor to the internal Vcc. This can drive an external PNP transistor if you add a current-limiting resistor between the sensor output and the transistor base. \$\endgroup\$
    – AnalogKid
    Commented Sep 12, 2023 at 17:10

2 Answers 2

2
\$\begingroup\$

You need one relay, plus a NO (normally open) low sensor and a NC (normally closed) high sensor. If sensors only come in NO versions their "sense" can be inverted either electronically or with a relay.

Relay has a NO1 contact to power pump and a NO2 contact to latch itself.
These MIGHT be the same contact.

Water level neither high nor low. Pump off.

Water level falls and turns low level NO sensor on.
NO sensor powers relay on.
Relay self powers via NC high contact and its NO1 contact.

Water filling starts.
Low level NO contact opens - nobody notices :-)

Tank fills until NC high level sensor opens.
Relay releaes.

Relay cannot reoperate until water level falls to operate low level NO sensor.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
9
  • \$\begingroup\$ jusrt to clarify both sensors are the same type, on when the water is below the sensor and off when the warer is above it. \$\endgroup\$ Commented Sep 11, 2023 at 13:05
  • \$\begingroup\$ Thank you very much I tested on Tinkercad and works! Since currently I don't have a DPDT relay but only SPDT, do you think that it is doable with them? Or better to simplify things and buy a DPDT? \$\endgroup\$
    – fabius94
    Commented Sep 11, 2023 at 13:31
  • 1
    \$\begingroup\$ @fabius94 You could do this with two SPDT (or SPST) relays. Just put the coils in parallel and it acts like a DPDT (resp. DPST) relay, though one that pulls twice the coil current. \$\endgroup\$
    – Hearth
    Commented Sep 11, 2023 at 15:07
  • \$\begingroup\$ Genius thank you! \$\endgroup\$
    – fabius94
    Commented Sep 11, 2023 at 16:41
  • \$\begingroup\$ Hi guys, I have a problem, I discovered that the electro valve has a latched solenoid so to close it, I have to reverse the polarity. What can be the best solution? In the end, I used a DPDT relay instead of two SPST. I saw this forum.digikey.com/t/polarity-reversal-using-a-dpdt-switch/626 . I can use the output of the relay to activate the second relay (instead of the pump) and then use the second relay to reverse polarity. Do I need some type of protections? Like I think a diode on the coil. \$\endgroup\$
    – fabius94
    Commented Aug 7 at 14:44
3
\$\begingroup\$

This type of control setup is a frequent request. It is less complicated than you think. And, the control circuit and the pump are completely isolated from each other and can have different power systems. For example, the control circuit can run on 24 Vdc while the pump is 120 Vac.

IF each sensor has a SPDT switch, that is, a switch with both normally-open (NO) and normally-closed (NC) contacts,

THEN this can be done with one DPST or DPDT relay.

One set of relay contacts drives the pump. The other set works with the normally-open (NO) contacts of the lower switch to form a latch. This is a common method for turning a momentary relay into a latching relay. The NC (normally closed) contacts of the upper switch upper switch are in series with the control circuit, and removes power from it when the contacts open at high water, resetting the latch.

If the upper sensor has only NO contacts, then that switch drives a small SPDT relay to perform the NC function.

Dog duty. Schematic later.

Ahh - Russell posted the schematic while I was typing.

Note - If you want to add the ability to force the system into PUMP mode when the water level is intermediate, add a SPST switch in parallel with the low sensor.

\$\endgroup\$
5
  • \$\begingroup\$ Thank you too for the explanation! Regarding the sensors, the datasheet is a bit vague. They only say that there are three different versions: a "High and low level output interface" (not sure what it means), an "NPN output interface" and a "PNP output interface". I think I'm going to buy a PNP because easier to understand. They also have 4 pins: VIN 12V, GND, OUTPUT and MODE, which if grounded, the sensor behave like an NC switch instead of NO. \$\endgroup\$
    – fabius94
    Commented Sep 11, 2023 at 13:58
  • \$\begingroup\$ Yes, I know they can output max 100mA, but the relay coil absorbs max 37mA. It is an "SRD-12VDC-SL-C" (from the datasheet it says that the coil nominal current is 30mA for "High sensitivity" and 37mA for "Standard"). Even in the sensor datasheet, they have an example where they connected a relay to the output, so I should not have problems. However, I'm going to redraw the schematic. Regarding the pump, I'm sorry I thought that wasn't important, but in reality, I'm controlling an electrovalve rather than a pump. I need the third relay because it works with 24V rather than 12V. \$\endgroup\$
    – fabius94
    Commented Sep 11, 2023 at 16:39
  • \$\begingroup\$ That is VERY different from a switch. All of those options involve solid state output devices, almost certainly intended to control low voltage and low current circuit inputs rather than a relay coil. Please update your question with data for the pump motor. This could be an all-solid-state, no-relay project. Unless you prefer a wired solution as opposed to soldering a small circuit? \$\endgroup\$
    – AnalogKid
    Commented Sep 11, 2023 at 16:41
  • \$\begingroup\$ @fabius94 Please add the information here as an addition at the end of your question - OR as an answer. Technically its an answer, but I like such material being added into the question in a way that its clearly added later. (Others likings may differ :-) ). || PNP is good as shown in your new solution. NPN works the same but is "mirror image - "feeding ground" to the relays rather than battery / +ve. \$\endgroup\$
    – Russell McMahon
    Commented Sep 12, 2023 at 0:42
  • \$\begingroup\$ @RussellMcMahon Thanks! I added all the information in the edit. It's my first post here! So I think that my second version should work, is it correct? Maybe a bit high in consumption since considering 37mA and a +10% error (as in the datasheet) I have a consumption of 81.4mA from the coils. It is max 100mA so it should be fine. \$\endgroup\$
    – fabius94
    Commented Sep 12, 2023 at 8:36

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.