Multiplexor analog readings problem

sghioto

Joined Dec 31, 2017
8,634
Well maybe it does and maybe it doesn't. You said:
The funniest thing is that with the connector X1 connected, if I switch any of the lights ON, everything gets nice and stable, getting the same values 0 to 2 on sensors NOT reached by the water and more higher values (and stable) with sensors touching the water. Any ideas about why this is happening???????
So maybe you should try ditching the converter and use the regulator on the Arduino?
SG
 

Thread Starter

irrintxi

Joined Nov 5, 2017
21
Well maybe it does and maybe it doesn't. You said:


So maybe you should try ditching the converter and use the regulator on the Arduino?
SG
As it is easy, I might try that to see if there is any improvement but stil:

- Recomended power to the arduino es 6-12v
- The battery is a car battery so spikes might occur
 

ebeowulf17

Joined Aug 12, 2014
3,307
If the lights are powered by the same power supply as the Arduino, and the power supply is a switching supply, then it makes sense that running the lights cleans up the signal.

I've experienced several power supplies which were very noisy when supplying especially low currents, but got much cleaner with heavier loads. Many supplies specifically call out a minimum load.

I'm with @sghioto in thinking you need to bypass the power supply and see if that solves the problem - if it does, you can find a better solution, whether that's a linear supply, a cleaner switching supply, or simply adding some suitable filtering to the existing supply.
 

ebp

Joined Feb 8, 2018
2,332
Switchers are notorious producers of noise.

What is the precise physical arrangement?
are the lights close to the battery or close to the converter?
how long is the connection between the battery and the converter?
how is the connection made - what sort of wires? are they twisted together
Buck switchers input current is chopped. A significant amount of good quality low-ESR capacitance is required to handle this. Cheap modules generally seem to use cheap capacitors (or crapacitors, as I call them). Without the capacitance the chopped current appears on the input wires, making the inductance of those wires important and potentially creating substantial ringing. Depending on arrangement, lamps could spoil the Q of the unwanted circuit and reduce ringing. It is also possible that the voltage drop caused by the lamps moves the switcher from discontinuous to continuous inductor current, which often results in a change in behavior.

It is never safe to say supplies involving switchers are clean and stable without examining them with a good, properly used oscilloscope. A meter isn't even remotely adequate.
 

Thread Starter

irrintxi

Joined Nov 5, 2017
21
Thank you all for your support.
Today, I have made many trials, to gather more information:

1- As suggested, I take the DC-DC converter out and I have power the arduino with the battery voltage (13.5v) straight to the RAW input.
Unfortunately I haven´t been seen, any improvements, at all.


2- I have prepared a bench test to test my system on different conditions. I have used, instead of a battery, a power supply 12v from my home 220v. I also I have connected a 12v lamp for tests to the same power supply. I have prepared some switches to simulate the tank levels sensors.
Under these circumstances, EBERYTHING works well and stable: with the water tank connector plugged and unplugged, with the lamp on and off. Under any circumstances, it works fine:

- Open analog ports values: 0 to 4.
- Open analog ports values, with a light on: 0 to 4.
- Open analog ports values (not sending the 5v from the DO): 0 to 4
- Open analog values without connector plugged: 0 to 4


3- If I replace the switches that simulate the water sensors by the real sensors:
- Open analog ports values: 0 to 130, random (most of the time <40).
- Open analog ports values, with a light on: 0 to 130, random (most of time <40).
- Open analog ports values (not sending the 5v from the DO): 0 to 300, random
- Open analog values without connector plugged: 0 to 4


4- I have connected back my system to its original place and then I have replaced the water tank sensors for the new bench switches:
- Open analog ports values: 0 to 16, random.
- Open analog ports values, with a light on: 0 to 4.
- Open analog ports values (not sending the 5v from the DO): 0 to 16, random
- Open analog values without connector plugged: 0 to 4


Test 3, makes me think there might be something on the cables that goes to tank sensors????? (They are Individual 0.5mm2 wires lead them together with the 5v from the DO), so I make another test.

On my original system I have replace, the connector that goes to the tank for a connector with 3wire 5m long cable. The result is interesting:
As soon as I connect the new connector (3 wire, 5m long, connected to nothing…), the values on the analog ports goes unstable with values up to 81.

I looks like the wires connected to this connector acts as an antenna????

I do not understand as each of the analog input ports have a 10K resistor connected ground….

I am still lost. With more information but lost about how to solve it…..
 

LesJones

Joined Jan 8, 2017
4,511
Have you tried the low pass filter (The 100 nF capacitor and 1K to 10K resistor.) that I suggested in post #4 ? I also suggest that you use screened cable for the 5 metre run to the sensors.

Les.
 

ebeowulf17

Joined Aug 12, 2014
3,307
Have you tried the low pass filter (The 100 nF capacitor and 1K to 10K resistor.) that I suggested in post #4 ? I also suggest that you use screened cable for the 5 metre run to the sensors.

Les.
+1 on Les' low pass filter, suggested all the way back in post 4.

I didn't follow every detail of the tests performed by the thread starter, but it sounds like the power supply is ruled out, so the simple low pass filter should be good.
 

Thread Starter

irrintxi

Joined Nov 5, 2017
21
Have you tried the low pass filter (The 100 nF capacitor and 1K to 10K resistor.) that I suggested in post #4 ? I also suggest that you use screened cable for the 5 metre run to the sensors.

Les.
Hi Les!!!
The reason I did not try it and I have made other trials is simply beacuse I do not have any capacitor with me at the moment. But surelly I will try it! :)
I live in a 400 people town so I have to go to somewhere else to get them. I will get them next week and I will let you know the results
 

Thread Starter

irrintxi

Joined Nov 5, 2017
21
I have finally found a couple of 100nf capacitor here!!!! Unfortunatelly not veru good news.......
These are the results:

100nF capactior + 1K resistor:
Open analog ports values: 0 to 26.
Open analog ports values, with a light on: 0 to 26.
Open analog values without connector UNplugged: 0 to 8
Values where water reachs the sensor drops to values about 200 (but one channel that is theorically open shows values of about 650)


100nF capactior + 10K resistor:
Open analog ports values: 0 to 2.
Open analog ports values, with a light on: 0 to 8
Open analog values without connector UNplugged: 0 to 4
Values where water reachs the sensor drops to values about 30 but sometimes even 0. (but one channel that is theorically open shows values of about 160)

100nF capactior and NO resistor:
Open analog ports values: 0 to 70.
Open analog ports values, with a light on: 0 to 70.
Open analog values without connector UNplugged: 0 to 4
Values where water reachs the sensor drops to values about 460(but one channel that is theorically open shows values of about 900)

Edit: This is what I did (just to make sure I did understand it....)
 

Attachments

LesJones

Joined Jan 8, 2017
4,511
Yo have the low pass filter connected correctly. I am assuming the mux is a 4051 (Not a 4061 as in your diagram.) Can you do some tests with the 5 volt wire to the water tank connected directly to +5 volts. (This is so you can do some tests with your multimeter.)
With non of the probes in the water select each probe in turn and measure the voltage with reference to ground to the selected mux input and note the value. Then measure the voltage on the mux output pin. Do this for all 5 inputs. Then repeat these tests with the probes in the water. Post the results of these tests.

Les.
 

Thread Starter

irrintxi

Joined Nov 5, 2017
21
Yo have the low pass filter connected correctly. I am assuming the mux is a 4051 (Not a 4061 as in your diagram.) Can you do some tests with the 5 volt wire to the water tank connected directly to +5 volts. (This is so you can do some tests with your multimeter.)
With non of the probes in the water select each probe in turn and measure the voltage with reference to ground to the selected mux input and note the value. Then measure the voltage on the mux output pin. Do this for all 5 inputs. Then repeat these tests with the probes in the water. Post the results of these tests.

Les.
I will do that tomorrow
 

sghioto

Joined Dec 31, 2017
8,634
What kind of lights are you using when connected to the 12 volt battery the problem disappears? Do you have anything else connected to the 12 volt battery that powers the Ardruino?
SG
 
Last edited:

LesJones

Joined Jan 8, 2017
4,511
Some more quesions to better understand you setup. It the water tank made of metal ? Are there metal pipes going to the tank ? Do the inlet and outlet pipes connect to the mains water supply or the pipework to taps around your house ? Is the ground point on your circuit connected to any external ground or is your curcuit totaly floating ? Does any moisture build up on the insulation material that the probes are mounted on ? A picture of the probe mounting and more information about the whole water system could be heplful. At the moment we don't know if the tank is a few hundred cubic cm capacity or millions of cubic metres. If I was building this type of system I would have the tank at ground potential. You have a wire probe into the tank trying to bring the whole water system up to + 5volts with your electronics ground. I would connect the common of the 10K resistors that connect to each probe connected to +5 volts. This would mean that you would now get a high reading when the probe was not in contact with the water. (This could be dealt with in the software if needed.) Doing it this way would reduce the risk of RF pickup in the wiring.

Les.
 

Thread Starter

irrintxi

Joined Nov 5, 2017
21
Yo have the low pass filter connected correctly. I am assuming the mux is a 4051 (Not a 4061 as in your diagram.) Can you do some tests with the 5 volt wire to the water tank connected directly to +5 volts. (This is so you can do some tests with your multimeter.)

With non of the probes in the water select each probe in turn and measure the voltage with reference to ground to the selected mux input and note the value. Then measure the voltage on the mux output pin. Do this for all 5 inputs. Then repeat these tests with the probes in the water. Post the results of these tests.


Les.

Yes, the MUX is a CD4051BE.

I have done some trials today:
As it is not easy to get the tank empty and refill it again, I have done the trials with the tank as it is now (only 1 of the 4 probes toched by the water). By the way, it is a 100L plastic tank and it is located in a van (campervan).

The probes are connected to the MUX on channels Y2/Y5/Y7/Y5 Y2/Y5/Y7/Y4 where Y2/Y5/Y7 are not touched by the water and Y5 Y4 is reached by water


With the 5v on the water, continuously (just to make these trials):

- Setting the Mux to read the probe on Y2 channel I got 0.1v on both MUX input and output.

- Setting the Mux to read the probe on Y5 channel I got 0.1v on both MUX input and output.

- Setting the Mux to read the probe on Y7 channel I got 0.1v on both MUX input and output.

- Setting the Mux to read the probe on Y5 Y4 channel I got 3.1v on MUX input and 3.04 on MUX output.


The arduino reads shows values between 0 to 50 on the 3 first probes but only reading once each. If I change the program to make a reading of the average of 100 values I got values between 18 to 22 which is quite ok (although sometimes these values drops to more than half)


Going back to my original system and changing the readings of the probes for 500 values average, I got values between 15 to 23 and reading the inputs of the MUX 0.07 to 0.09v, which is not to bad……
 
Last edited:

Thread Starter

irrintxi

Joined Nov 5, 2017
21
Some more quesions to better understand you setup. It the water tank made of metal ? Are there metal pipes going to the tank ? Do the inlet and outlet pipes connect to the mains water supply or the pipework to taps around your house ? Is the ground point on your circuit connected to any external ground or is your curcuit totaly floating ? Does any moisture build up on the insulation material that the probes are mounted on ? A picture of the probe mounting and more information about the whole water system could be heplful. At the moment we don't know if the tank is a few hundred cubic cm capacity or millions of cubic metres. If I was building this type of system I would have the tank at ground potential. You have a wire probe into the tank trying to bring the whole water system up to + 5volts with your electronics ground. I would connect the common of the 10K resistors that connect to each probe connected to +5 volts. This would mean that you would now get a high reading when the probe was not in contact with the water. (This could be dealt with in the software if needed.) Doing it this way would reduce the risk of RF pickup in the wiring.

Les.
The tank is in a campervan, is made of plastic and it has 100L.
No metal pipes going to from the tank. Only plastic hoses used.
I was thinking about setting up the system as you suggest but I was concern about electrolysis……


The point is, the system, for the water sensors works because there is a huge difference on values when probes reached by the water or not so I can easy detect it. BUT......... I have 2 issues:

1- If I use the free channels of the CD4051 to read the battery voltage, it won’t work as I need stable and more precise measurements. This can be solved (as it is now working) by reading the voltages by another 2 arduino analog inputs.

2- I am very curious and I like to learn what this is happening…...


As right now, the point 2 is more important to me, If we forget the water tank for a moment, why if I disconnect the tank probes wires and I connect 5m open wires (just to air) I got the same issue???? (readings not stable and not zero values when I have resistors to ground to each wire….)
 

LesJones

Joined Jan 8, 2017
4,511
First I am confused by "MUX on channels Y2/Y5/Y7/Y5" Are two probes connected to mux input Y5 ?
I don't understand why in line 2 of you readings you get 0.1 volts on Y5
and in line 4 you get 3.1 volts on Y5
You could get round the electrolysis problem with the tank at ground potential by connecting the common of the 10K resistor to your probes to the I/O pin so they were only pulled up to +5 volts while taking readings. Even though the tank is insulated it is possible the water is connected to ground via metawork on a pump or the metal of the taps. (This could be why you are only getting a reading of 3.1 volts rather than almost 5 volts.)
The 5 metre lengths of wire will work as an antenna and pick up any radio frequencies. It is possible that the peaks may go above + 5 volts or below zero volts which could cause the multipexer to misbehave. The low pass filter was to try to reduce the problem of RF getting through the mux. The switch mode regulator is a potential source of RF interference. (What is you reason for wanting to use a switch mode regulator ? With the small current drawn by the arduino I don't think it would use less power than a linear regulator.) If you will not used screened cable to the probes then possibly adding two diodes one to ground and one to +5 volts each probe input and having a low pass filter on each probe input at the arduino end of the cable may help.

Les.
 
Top