Author Topic: Liquid Level Circuit Design  (Read 2178 times)

0 Members and 1 Guest are viewing this topic.

Offline sirklezeroTopic starter

  • Newbie
  • Posts: 7
  • Country: us
    • I was a teenage Doppelgänger
Liquid Level Circuit Design
« on: December 09, 2018, 06:07:00 pm »
Hello!

I'm pretty new to designing circuits, and am working on a project to keep a tank of water filled between the level of two sensors; a min and max level scenario. I have an extensive software engineering background and put together a pretty simple arduino project to do this, but then decided I wanted something a bit simpler, a bit less overkill, and something also where I could learn a few new things. So, I decided to ditch the arduino and design something a bit lower level. I'm hoping someone here could give this a once over and provide a friendly critique of what I'm working on. I've attached the KiCad schema as an attachment.

With that said, here's what I've been thinking:

The system is based on two optical liquid level sensors, one installed near the bottom of my tank, and one near the top. Both output 0V when exposed to liquid and in my case 5V when exposed to air. I'm looking to keep the water level in between those two sensors, without dropping below the lower, or filling higher than the top by using a solenoid controlled brass liquid valve. Since this is water, and it's in my basement, I'm also concerned about overfilling and flooding my basement, so I've installed a mechanical float valve on the inside of the tank that can mechanically shut the water supply off if it reaches the actual top of the tank (near enough). My experience with these floats is that they are far from perfect and at least the two that I've tried have had leaks that caused them to fill faster than the water is used, causing a small water disaster. All of this is then connected to the utility water connection in the basement for its water supply.

On the circuit side of things I'm powering this with 12V. I've then got an LM7805C regulator stepping down to 5V for the logic level portion of things. From there I went for a simple NOR gate SR latch based on the SN74LS02 to handle the logic processing of the sensor output. The LOW sensor is attached to the SET of the latch and the HIGH sensor is attached to the RESET of the latch. From there I've got two LED's connected to the outputs of the latch as indicators. Pretty simple so far, and testing in a cup of water on my bench seems to work great. However, this is where I start having a few questions...

My hope is to use the 12V power supply to power the solenoid for the brass valve. At 12V it's sheet says it will draw 3A. So, based on some other recommendations I've gotten I built a MOSFET into my circuit. I've got the output of my latch going to the GATE of my MOSFET, a 10k pull-down resistor between GATE and SOURCE and I've got a 1N4001 kickback diode in parallel with the solenoid to protect the MOSFET.

With my, hopefully decent explanation, I'm hoping to get some feedback on a couple things:

  • Is the way I have the MOSFET included in this circuit the right way to do it? I was unsure if the diode would go in parallel or series with the load of the solenoid.
  • I'm not entirely sure how to calculate the heat dissipation for this circuit and this MOSFET to determine if I'll need a heatsink.
  • I'd like to add some headers to this that could be wired up to a microcontroller for monitoring. I have another microcontroller in the basement that does some climate monitoring (it's a woodworking shop), and I think it would be interesting to catch a notification when the tank is filling. I'm just not sure of the best way to do this, would I just connect a header at the output of the latch and monitor it with the microcontroller?
  • Generally speaking, I'd love a critique of the design. I'm SUUUUUPER new to designing circuits, and this is my first project using KiCad, so I'm not sure what I could be doing better both in the design of the schematic and the circuit itself.
  • Ultimately I'd like to make a PCB for this. For this type of circuit, any tips or pointers you might have?

This has been a really fun project for me to learn on, and I get something useful for my workshop, so it's a double win. I know I have a lot of questions, and I'm grateful for your time reading all this.
Mostly clueless software engineer
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: us
Re: Liquid Level Circuit Design
« Reply #1 on: December 09, 2018, 07:39:48 pm »
"VALVE" (gate of the mosfet) should be tied directly to the NOR gate output. 

You do not need the 10K resistor tied to the gate.

Place a 0.1uf ceramic bypass capacitor directly at the supply pins of the NOR gate.

Shield the long run of wire between the two sensors and the inputs to the NOR gates.
« Last Edit: December 09, 2018, 07:46:15 pm by Wimberleytech »
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 11858
  • Country: us
Re: Liquid Level Circuit Design
« Reply #2 on: December 09, 2018, 07:45:17 pm »
"VALVE" (gate of the mosfet) should be tied directly to the NOR gate output. 

You do not need the 10K resistor tied to the gate.

The 10 k resistor R2 appears to be a pull down resistor to ensure the gate does not float. Seems sensible to me?
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: us
Re: Liquid Level Circuit Design
« Reply #3 on: December 09, 2018, 07:47:31 pm »
"VALVE" (gate of the mosfet) should be tied directly to the NOR gate output. 

You do not need the 10K resistor tied to the gate.

The 10 k resistor R2 appears to be a pull down resistor to ensure the gate does not float. Seems sensible to me?

Output of NOR should not float, but the 10k will not hurt anything for sure...so it is fine.
 

Online tautech

  • Super Contributor
  • ***
  • Posts: 28325
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: Liquid Level Circuit Design
« Reply #4 on: December 09, 2018, 07:49:19 pm »
Why optical ?
Is the liquid non-conductive ?

Old thread:
https://www.eevblog.com/forum/beginners/which-sensor-to-use-for-salt-water-level/
Avid Rabid Hobbyist
Siglent Youtube channel: https://www.youtube.com/@SiglentVideo/videos
 

Offline sirklezeroTopic starter

  • Newbie
  • Posts: 7
  • Country: us
    • I was a teenage Doppelgänger
Re: Liquid Level Circuit Design
« Reply #5 on: December 10, 2018, 03:55:48 am »
Output of NOR should not float, but the 10k will not hurt anything for sure...so it is fine.

Yeah, I was reading another thing that mentioned that the gate can maintain a charge, and that the pull-down would keep it from latching open once signal stops. Is this true, or am I maybe misunderstanding something.
Mostly clueless software engineer
 

Offline sirklezeroTopic starter

  • Newbie
  • Posts: 7
  • Country: us
    • I was a teenage Doppelgänger
Re: Liquid Level Circuit Design
« Reply #6 on: December 10, 2018, 03:59:16 am »
Why optical ?
Is the liquid non-conductive ?

Old thread:
https://www.eevblog.com/forum/beginners/which-sensor-to-use-for-salt-water-level/

nah, it's just water. I went with the optical ones because, honestly I didn't know any better when I bought them and they looked pretty fancy  :-[ At least they work really well.
Mostly clueless software engineer
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: us
Re: Liquid Level Circuit Design
« Reply #7 on: December 10, 2018, 04:03:31 am »
Output of NOR should not float, but the 10k will not hurt anything for sure...so it is fine.

Yeah, I was reading another thing that mentioned that the gate can maintain a charge, and that the pull-down would keep it from latching open once signal stops. Is this true, or am I maybe misunderstanding something.

That is a possibility.  There is feedback from drain to gate.  When the gate is driven low, the drain goes high and if there is enough charge to overcome the output of the NOR, then, yes it is possible to flip the latch. 
 

Offline sirklezeroTopic starter

  • Newbie
  • Posts: 7
  • Country: us
    • I was a teenage Doppelgänger
Re: Liquid Level Circuit Design
« Reply #8 on: December 10, 2018, 04:06:57 am »
"VALVE" (gate of the mosfet) should be tied directly to the NOR gate output. 

I tried to do this with a Label in KiCad, and I "think" it routes everything fine, but now I'm wanting to sanity check that! I was shooting for displaying the logical parts of the circuit individually, even though it's not a terribly complicated design.

Place a 0.1uf ceramic bypass capacitor directly at the supply pins of the NOR gate.
So, this is something that has always kinda threw me for a loop; when do you need capacitors and when don't you. In this case, how would these capacitors affect the input to the NOR gates? Would I put a capacitor at the junction between the sensor inputs (two of them, one for each) or would I put a capacitor at every input (six of them, one for each input of the three NOR gates)?

Shield the long run of wire between the two sensors and the inputs to the NOR gates.

How would I do this, just a shielded cable?


Mostly clueless software engineer
 

Offline t1d

  • Super Contributor
  • ***
  • Posts: 1219
  • Country: us
Re: Liquid Level Circuit Design
« Reply #9 on: December 10, 2018, 10:39:55 am »
I have always thought "capacitive water level sensors" to be interesting and doable. I think that they can be as simple as one piece of metal pipe inserted into another?

https://www.google.com/search?q=capacitive+water+level+sensor+circuit&client=firefox-b-1&tbm=isch&tbo=u&source=univ&sa=X&ved=2ahUKEwiMie64h5XfAhUNXa0KHX1xA74QsAR6BAgEEAE&biw=1280&bih=667

https://www.instructables.com/id/Capacitive-Fluid-Level-Sensor/
 

Online tautech

  • Super Contributor
  • ***
  • Posts: 28325
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: Liquid Level Circuit Design
« Reply #10 on: December 10, 2018, 10:51:51 am »
Why optical ?
Is the liquid non-conductive ?

Old thread:
https://www.eevblog.com/forum/beginners/which-sensor-to-use-for-salt-water-level/

nah, it's just water. I went with the optical ones because, honestly I didn't know any better when I bought them and they looked pretty fancy  :-[ At least they work really well.
FYI I attach the file from that thread just in case you missed it:
A single XNOR IC, 4 resistors and 2 caps.
Toggles between 2 states.
Avid Rabid Hobbyist
Siglent Youtube channel: https://www.youtube.com/@SiglentVideo/videos
 
The following users thanked this post: sirklezero

Offline rhodges

  • Frequent Contributor
  • **
  • Posts: 306
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Re: Liquid Level Circuit Design
« Reply #11 on: December 10, 2018, 02:27:36 pm »
I am doing a similar project. I have a 1000 liter "tote" (International Bulk Container) that I will use as a secondary water tank.

I thought about mechanical floats and finally decided to use an ultrasonic distance sensor. The HC-SR04 cost $1.25 on ebay. I will drill two holes on the top of the plastic tank for the transmit and receive transducers. Its board will be on top of the tank, held in place by friction.

I did not think about an optical sensor, but I would be concerned that water drops might stay on the optical surface and give a faulty signal.

Will the Mosfet saturate with TTL input? A CMOS buffer might be a good idea, or use a P Mosfet and a 2N3904 or 2N4401 to pull down the gate.

Off topic: If anyone is interested in using the HC-SR04 with an STM8S103, I have put my library and example code on github. Here is the wiki summary:
https://github.com/unfrozen/stm8_libs/wiki/lib_ping:-Control-one-to-three-HC-SR04-ultrasonic-rangefinder-devices.
Currently developing STM8 and STM32. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: us
Re: Liquid Level Circuit Design
« Reply #12 on: December 10, 2018, 02:35:27 pm »
I am doing a similar project. I have a 1000 liter "tote" (International Bulk Container) that I will use as a secondary water tank.


Be sure to post when this project is done!!
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16607
  • Country: us
  • DavidH
Re: Liquid Level Circuit Design
« Reply #13 on: December 10, 2018, 08:04:01 pm »
When I was reading your description, I immediately thought "set-reset flip-flop" but I might have made it with discrete transistors or high voltage CMOS logic so no regulator is required.

Where to place the reverse EMF suppression diode depends on the application.  In this case with a slow acting solenoid, across the solenoid is the best place.  The low voltage drop across the diode makes for a low decay time but that is irrelevant here.  A zener diode or resistor in series with the diode could be used to raise the reverse voltage and decrease the decay time.  A diode across the transistor would direct the decay current into the positive supply which may or may not be acceptable.

Unless you use a really small power MOSFET, heat sinking should not be required.  The only real question is power dissipation while turned on which depends on channel resistance which can be absurdly low such that no heat sinking is required.

 
The following users thanked this post: sirklezero

Offline sirklezeroTopic starter

  • Newbie
  • Posts: 7
  • Country: us
    • I was a teenage Doppelgänger
Re: Liquid Level Circuit Design
« Reply #14 on: December 11, 2018, 04:02:36 am »
yeah, my project is for a humidifier to help maintain a consistent'ish relative humidity in my workshop where I build classical guitars. I've got a dehumidifier element to it as well; it gets super dry during the winter here, and super humid in the summer, so the climate management is always a tug of war.
Mostly clueless software engineer
 

Offline sirklezeroTopic starter

  • Newbie
  • Posts: 7
  • Country: us
    • I was a teenage Doppelgänger
Re: Liquid Level Circuit Design
« Reply #15 on: December 11, 2018, 04:10:22 am »
I really appreciate the feedback of this group so far, thanks everyone!

It seems like, other than adding some caps at the inputs of the NOR gates (which I'm still a little fuzzy on), it seems that for the most part this should work out really well for me. I think I might poke around with some of the other ideas for water level detection, this is a learning project after-all, so the experience will be well worth it regardless of the end outcome.

Can someone help me understand how the caps benefit the circuit in this case? Is it a protection for the inputs of the NOR gates from something going wrong on the sensor side of things?
Mostly clueless software engineer
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 11858
  • Country: us
Re: Liquid Level Circuit Design
« Reply #16 on: December 11, 2018, 04:16:15 am »
...other than adding some caps at the inputs of the NOR gates (which I'm still a little fuzzy on)...

Can someone help me understand how the caps benefit the circuit in this case? Is it a protection for the inputs of the NOR gates from something going wrong on the sensor side of things?

The caps don't go on the inputs, they go on the power supply pins. Essentially place the capacitor between the power (+) and power (-) pins of the IC, as close to the IC as possible. These are "bypass" capacitors, they help to prevent high frequency glitches in the supply messing up the operation of the chip. Such glitches can be caused when the logic gates switch state (they draw a pulse of current when they switch).
 

Offline raptor1956

  • Frequent Contributor
  • **
  • Posts: 869
  • Country: us
Re: Liquid Level Circuit Design
« Reply #17 on: December 11, 2018, 06:45:13 am »
I have always thought "capacitive water level sensors" to be interesting and doable. I think that they can be as simple as one piece of metal pipe inserted into another?

https://www.google.com/search?q=capacitive+water+level+sensor+circuit&client=firefox-b-1&tbm=isch&tbo=u&source=univ&sa=X&ved=2ahUKEwiMie64h5XfAhUNXa0KHX1xA74QsAR6BAgEEAE&biw=1280&bih=667

https://www.instructables.com/id/Capacitive-Fluid-Level-Sensor/

Fuel quantity sensors on aircraft use capacitance sensors to measure fuel level.  The probe has contoured plates so that variation in tank geometry is figured in.  In addition, a compensator capacitor is used to compensate for fuel density as the temperature changes.  Ultimately this arrangement provides a fuel reading by mass that is more accurate than by level alone.


Brian
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf