Author Topic: Earth ground referenced comparator  (Read 5501 times)

0 Members and 1 Guest are viewing this topic.

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #25 on: January 16, 2022, 04:36:00 am »
Both ON/OFF being in the same state is "don't care = x". It will never happen. So the only four outcomes is marked 0 or 1 in the TIMEOUT_ALARM column. And i'm only interested in the 1 (which is timeout). With the NOR gate, I achieve that, right? ​

OK, I see the four legal states in the middle of your table.  Why do you show the four others that are impossible?  Trust me, that only confuses things.

Please tell us about your moisture sensor.  How much current can it "switch" and what is the leakage in the "dry" state?  Is this something like a spike in the ground?  Or is it some hard-on / hard-off sensor?  And you mentioned a heater -- do we need to know about this and how it will be controlled by your circuit?
It is simply a metal rod going from the top of the tank and down halfway into the tank (tank should never fill more than half), and the tank is grounded to mains earth.So I'm basically measuring the resistance between mains earth and the rod, with the water providing resistance when it hits the proper fill level.

OK that's pretty simple.  Have you got resistance measurements at the proper fill level?  Pure (distilled) fresh water is actually a good insulator.  What do you know about the water you are working with?
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #26 on: January 16, 2022, 04:39:45 am »
Hey, would anyone else like to weigh in here?  I don't want to steer okw wrong, or over-complicate things.  Trust me, I can take a little necessary criticism!
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #27 on: January 16, 2022, 12:34:07 pm »
OK that's pretty simple.  Have you got resistance measurements at the proper fill level?  Pure (distilled) fresh water is actually a good insulator.  What do you know about the water you are working with?
I measured the it at 3.5 - 4M. But that's with the same water sitting in the tank for a few weeks/months (stainless steel tank with a few copper pipes). It will probably be a bit higher when fresh water flows in. The intake is on the bottom, the outlet is on the top, so a lot of "old" water (with ions) will still be left and create a resistance. The fresh water will only slightly dilute the tank water. Newer tanks are stainless steel (negligible ion deposits), older models are copper (contributes with quite a lot of Cu2+ ions).
I also measured fresh water in a 1 liter jar, 7-9M. So it will definitely detect something, if my opamp resistors are tweaked good enough.
In Norway we have quite soft water (little ions) compared to other places in the world, so if I get the detector to work here, I'm sure it would work anywhere.
« Last Edit: January 16, 2022, 12:35:38 pm by okw »
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #28 on: January 16, 2022, 04:19:35 pm »
It would be nice to get an upper limit on the "water detected" sensor resistance.  If we assume it's 10M then with the bias resistors in your circuit the comparator (-) input shifts from 2.976V (dry) to 2.851V (wet).  Call this 100mV.  That's not a lot of swing and you are going to want 1% resistors to set the comparator voltages.  You will also probably want to increase the value of the bias resistors at the (+) input tp more closely match the resistance at the two inputs.  You also need to reduce the amount of hysteresis -- what you have is now about 0.2 Volts.  Perhaps increase R8 to 5M or so?

One way to increase the wet/dry voltage change is to increase the resistance of your sensor bias divider resistors, or add a third resistor as I had shown (scratched out) in my last circuit.  But this comes at the expense of more sensitivity to the comparator input offset voltage and input offset current.  I checked the existing circuit against the 358 specs and the effect of these factors was only about +/- 7mV, but when you increase the input resistances this effect also increases.  There are comparators available with much lower offset specs should this be an issue.

So this is in a water tank?  When it is filling there will be ripples, so the detector will initially see an oscillating high-resistance wet/dry/wet/dry condition until the level has risen enough for more immersion.  Wil this be a problem for your design?  I have experience with water tanks (I have lived in rural areas with wells), and the level detectors used for pump control are usually two-wire mechanical switches with perhaps 1/2 foot of mechanical hysteresis.  You really don't want to have high-frequency pump cycling.
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #29 on: January 16, 2022, 10:49:23 pm »
It's quite difficult to measure, as the readings jump up and down as i move the dmm probes in the water. Perhaps concentration of ions isn't uniform?
Yes, the high frequency pump cycling must be avoided at all costs. Wouldn't a wide hysteresis swing take care of that?
It has to be the current level probe design. This is a closed heated tank (<1.7bar and 130'C).

Besides tweaking the values. Would the latest circuit be sufficient and a good design for this? So I can go ahead and layout and produce a prototype. It's only a few bucks, but I don't wanna waste time and money, if something is wrong.
 

Online Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1326
  • Country: ca
Re: Earth ground referenced comparator
« Reply #30 on: January 16, 2022, 11:05:00 pm »
It's quite difficult to measure, as the readings jump up and down as i move the dmm probes in the water. Perhaps concentration of ions isn't uniform?

You need to measure it using the actual rod in the tank as it fills with water. DMM probes will be completely different.
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #31 on: January 17, 2022, 03:12:40 am »
Can you run two wires to a pair of probes held apart a small distance by insulators?  One of the probes can be grounded.  That way you won't have to work with the resistance from the probe to the tank wall, but just between the two parallel probes which should be more repeatable.

As for hysteresis, you need a linear (or at least usefully monotonic) variation in sensor resistance as it becomes immersed.  I suspect you do have that and it would be very useful to know how the resistance varies as a function of immersion depth.  If halfway was (say) 10M and fully-immersed were 5M then we could work out an appropriate hysteresis range.  Again, using a parallel sensor arrangement might make the values more repeatable.

We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #32 on: January 17, 2022, 05:13:05 pm »
Can you run two wires to a pair of probes held apart a small distance by insulators?  One of the probes can be grounded.  That way you won't have to work with the resistance from the probe to the tank wall, but just between the two parallel probes which should be more repeatable.

As for hysteresis, you need a linear (or at least usefully monotonic) variation in sensor resistance as it becomes immersed.  I suspect you do have that and it would be very useful to know how the resistance varies as a function of immersion depth.  If halfway was (say) 10M and fully-immersed were 5M then we could work out an appropriate hysteresis range.  Again, using a parallel sensor arrangement might make the values more repeatable.

I need to keep it exactly as is (tank is completely closed (except a few inlets and outlets). Earth grounded copper tank and a probe (insulated from the the mounting point of course).

I could of course hook up a data logger with a voltage divider and see how resistance varies during the water low/normal area.
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #33 on: January 17, 2022, 06:08:47 pm »
I need to keep it exactly as is (tank is completely closed (except a few inlets and outlets). Earth grounded copper tank and a probe (insulated from the the mounting point of course).

I could of course hook up a data logger with a voltage divider and see how resistance varies during the water low/normal area.

It would be extremely helpful to get this resistance vs level data.  With that we can optimize the sensor interface and the amount of hysteresis.

You have mentioned using this design in more than one place.  Will the tank dimensions be the same?  This will most likely affect the probe-to-tank resistance.
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #34 on: January 17, 2022, 06:24:10 pm »
It would be extremely helpful to get this resistance vs level data.  With that we can optimize the sensor interface and the amount of hysteresis.
I'll try to see how fast I can get to this.

You have mentioned using this design in more than one place.  Will the tank dimensions be the same?  This will most likely affect the probe-to-tank resistance.
Yes, same dimensions and geometry.
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #35 on: January 17, 2022, 06:34:31 pm »
Yes, same dimensions and geometry.
Great news!  This helps a lot. 
The only other variable will be the water conductivity which will determine the full-immersion resistance, and the effective hysteresis vs level change.  Perhaps the variation will be minor...
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #36 on: January 17, 2022, 07:32:07 pm »
Is there an easy way to add a delay on both ON and OFF? I've seen this same principle (one with LM324 and another with both LM324 + LM358), but they didn't engage the pump until 2-3 seconds after plugging in. Maybe there is possible to add some rise/fall delay on the output? In addition to the hysteresis?

By the way, will the lm358 (and the rest) with the current protection survive if the heating element cracks and starts leaking AC current via water to ground? This happens very often (reason no1 for heating elements die, reason no2 is of course burnt heating wire). The GFCI should trip, but many older setups don't have it, or not tripping at low enough currents.
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #37 on: January 17, 2022, 07:53:58 pm »
Is there an easy way to add a delay on both ON and OFF? I've seen this same principle (one with LM324 and another with both LM324 + LM358), but they didn't engage the pump until 2-3 seconds after plugging in. Maybe there is possible to add some rise/fall delay on the output? In addition to the hysteresis?

By the way, will the lm358 (and the rest) with the current protection survive if the heating element cracks and starts leaking AC current via water to ground? This happens very often (reason no1 for heating elements die, reason no2 is of course burnt heating wire). The GFCI should trip, but many older setups don't have it, or not tripping at low enough currents.

As long as you don't need much timing precision a delay could be as simple as putting a series resistor then a capacitor to ground at the comparator output.  You are using cmos NOR gates so the RC values should be reasonable.  I think you will want to use schmitt-trigger-input NOR gates in that case, but these are available.  You will probably need  to add a diode and maybe a resistor to ensure proper power-up and power-down behavior. (Are you sure you don't want to use an 8-pin PIC for all this?  It would get rid of most of your components and cost less.)

240VAC leaking into the water?  That's nasty.  If the tank is your ground reference then the only real problem is on the sensor input.  The protection circuit I showed you can handle moderate transients, but with high-voltage and current more than (say) 10 mA then first the diodes will blow, followed by the 358.  Or more likely, the input protection diodes will pump up the +5V voltage to a couple hundred volts and zap every active device on the board.  Once we get a better handle on the sensor resistance range we can probably modify the input circuit slightly to make it fairly bulletproof in the broken-heater scenario -- probably by putting a series resistor in line before the diodes and perhaps using higher-current diodes and some sort of clamp (Zener or equivalent).

So how are you switching power to the pump and heater?  This is important when we are so concerned about grounding and isolation and power-faults.  All you've shown us is what looks like an alarm-type beeper.
« Last Edit: January 17, 2022, 08:19:14 pm by fourfathom »
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #38 on: January 17, 2022, 08:34:56 pm »
A PIC would be easier and cheaper, but I'm treating this as a project for learning - and I've learned a lot so far. I do software dev all day, so it's fun doing this all old-school.

This is my relay and triac circuit. Not everything is calculated yet.
« Last Edit: January 17, 2022, 08:37:32 pm by okw »
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #39 on: January 17, 2022, 09:08:22 pm »
OK, we can look at the protection circuitry once we have better sensor resistance data. 

About your relay and triac, I'm glad to see the optoisolators!  But take a look at OK2 pin 6.  You need to connect the opto collector instead.  You might want to put a bypass cap on pin 6 but check the device specs -- I believe the base is usually left floating.  For that matter, the entire OK2 driver circuit looks "interesting".  Why so complex?  Why the reverse-diode across the opto input?  You are only going to get less than 0.4 mA of opto drive current through Q1, and that's probably not enough.  Why not just drive the opto via a resistor from your logic?

And Q2 needs some protection from the relay-off flyback spike.  There are various ways to do this, all pretty simple.

I haven't reviewed the design in total, these items just jumped out at me.
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #40 on: January 17, 2022, 09:56:09 pm »
Of course, my bad. Pin 5, not pin 6. And I added a 100nF between pin 4 and 6. Seems it would add some noise immunity.
The protection diode should be on the relay, not triac optocoupler. A hasty mistake.
But yeah, the complex input was probably too much. I removed everything and driving it through a resistor now.
 

Online Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1326
  • Country: ca
Re: Earth ground referenced comparator
« Reply #41 on: January 18, 2022, 12:18:59 am »
I don't see the point of OK1 since the relay coil is also connected to the +5V line. Just drive Q2 directly via R13. Yea, and a diode across K1's coil (Cathode to +5V) is a good idea.
R12 makes no sense to me. Connect the emitter of Q1 to ground, or just drive the OK2 directly like you did with OK1.
« Last Edit: January 18, 2022, 12:24:23 am by Kim Christensen »
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #42 on: January 18, 2022, 12:35:09 am »
I don't see the point of OK1 since the relay coil is also connected to the +5V line. Just drive Q2 directly via R13. Yea, and a diode across K1's coil (Cathode to +5V) is a good idea.
R12 makes no sense to me. Connect the emitter of Q1 to ground, or just drive the OK2 directly like you did with OK1.

Yes.  I agree with all of this.  I think okw is now driving opto OK2 directly as you suggest. 

And yes, the opto for the K1 circuit seems redundant -- the relay will provide the necessary isolation.  Since you need the transistor Q2 to handle the 71 mA relay current, just drive the transistor from the logic.  The 1K base resistor should probably be dropped down to perhaps 560 Ohms though. I think the cmos logic can source that 7 mA base current.
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #43 on: January 18, 2022, 12:55:35 am »
The relay optocoupler was there to provide AC noise protection, especially since it's switching high loads (1400w heating element). This is resistive so it probably won't introduce so much noise(?). But the relay will switch only at the transition pump off - heating on. When heating is on, an external thermostat (in series with the relay) will switch on/off separately.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #44 on: January 20, 2022, 12:37:11 am »
Any input on this?
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1884
  • Country: us
Re: Earth ground referenced comparator
« Reply #45 on: January 20, 2022, 01:42:12 am »
Any input on this?

Not really. 

I just don't know how much noise is transferred into the relay coil when the contacts are switching high voltage / power, so the following is all guesswork:  If it's just a current spike I would think that the flyback protection would suffice (and perhaps a second diode to ground if the spike went negative).  If it's a common-mode surge that somehow forces ground-current than you're going to need more than an opto since the relay and drive transistor are still connected to +5 and ground -- but your power supply isolation should prevent that.
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #46 on: June 05, 2023, 11:52:58 am »
Finally I had time to realize this into a PCB.
Sadly the 555 timer doesn't start countdown unless the 555 trigger (signal !AUTO_FILL_ON) goes high again.
But !AUTO_FILL_ON is dependent on water level sensor and will stay low until water level is satisfactory.
I see some designs adding a pull up and a capacitor to make it an edge-trigger, but I can't manipulate the !AUTO_FILL_ON as this is part of the NOR gate to compare !AUTO_FILL_ON and PUMP_ENGAGE.
When both are low (pump is running but water level is still low after ~60 sec), it gives a buzzer alarm + pump stops.
Any idea how to fix the 555 circuit?
 

Online Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1326
  • Country: ca
Re: Earth ground referenced comparator
« Reply #47 on: June 05, 2023, 03:33:51 pm »
Since this is an old thread, was this the circuit you built? Or were there additional changes?

« Last Edit: June 05, 2023, 03:36:06 pm by Kim Christensen »
 

Offline okwTopic starter

  • Regular Contributor
  • *
  • Posts: 244
  • Country: no
Re: Earth ground referenced comparator
« Reply #48 on: June 05, 2023, 05:06:30 pm »
Somewhat modified, but yes more or less.
Except R8 is connected to the IC1A output (instead of between the NOR gates).
Also, I put a resistor R10 between IC1A output and IC4D input, and a capacitor (not assembled) between this resistor / IC4D input and ground.
R10 is now 0R, but was advised 8.2k for wider hysteresis band, have to experiment how much I need.
All opamp/NOR gate inputs has been properly grounded / etc. for more stable operation.

I didn't modify the 555 timer in the attachment, this is the PCB i received.
 

Online Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1326
  • Country: ca
Re: Earth ground referenced comparator
« Reply #49 on: June 05, 2023, 10:19:55 pm »
Finally I had time to realize this into a PCB.
Sadly the 555 timer doesn't start countdown unless the 555 trigger (signal !AUTO_FILL_ON) goes high again.
But !AUTO_FILL_ON is dependent on water level sensor and will stay low until water level is satisfactory.
I see some designs adding a pull up and a capacitor to make it an edge-trigger, but I can't manipulate the !AUTO_FILL_ON as this is part of the NOR gate to compare !AUTO_FILL_ON and PUMP_ENGAGE.
When both are low (pump is running but water level is still low after ~60 sec), it gives a buzzer alarm + pump stops.
Any idea how to fix the 555 circuit?
I've edited your diagram because the Net-Names were not helping me follow the circuit. I'll have to look at this again a bit later, but my edits may help others:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf