Analog readings change when i restart device

Hello
I build a small sensor node with 4 analog inputs for soil moisture sensors (the Vh400 from vegetronics).
The sensor uses the electric imp 002.

I power the PCB with 12V from an external PSU.
On board I have a 3.3V dc-dc converter to power the imp.
I also have a 5V LDO - The VH400 moisture sensors need at least 3.5V in to work properly.
The Vh400 outputs 0-3V analog which I feed through up-amp buffers to analog-in pins on the imp.
The soil moisture sensors are connected with TRS (stereo jack) connectors.

However I have a problem. If i disconnect and reconnect power to the board, measurements change.

With the analog sensors connected and the board powered up it measures as it should, let’s say the sensors measure:
Sensor 1: 26%
Sensor 2: 68%
Sensor 3: 68%
Sensor 4: 62%
(These are the right measurements checked with reference measurement equipment).
If I measure voltage on the 5V rail i read ~5,02V

If i then disconnect the 12V power and put it back in, i get different measurements, even thou I should get the same:
Sensor 1: 5%
Sensor 2: 46%
Sensor 3: 45%
Sensor 4: 42%
If I measure voltage on the 5V rail i read ~4,82V

And now the tricky part: If i disconnect and reconnect a sensor by pulling out the mini-jack connector and putting it back in, readings go back to being normal. Also voltage on the 5V rail reads 5,02V again.

If I power the board with 6.5V instead of 12V i have no problems.
I have a feeling it has to do with the 5V LDO somehow, but don’t know.
With no sensors connected via the mini jack connectors there a low volume but high frequency pitch sound coming from the board.

Please see attached schematics, I really cannot figure out what the problem might be.

Hi @toebs -

Taking a very quick look at your schematic - what jumps out is the mixing of +5v and +3v3 within your design leading to the possibility of temporary start-up voltages outside the Imp-002 pin input specifications. I think this could occur, especially during any sort of power sequencing, leading to unpredictable behavior. Also, I couldn’t find any information on your CO2 sensor, but its supply voltage suggests it might be outputting levels certainly beyond the imp input pin capability.

I might suggest you consider seeing if you can change your U3 supply voltage to 3v3, and perhaps also using a level shift approach to interface the CO2 sensor to the imp.

Anyway, just some quick initial thoughts. (By the way, very nice job explaining/documenting your problem and observations. The schematic is very helpful, and I’m sure will help getting you some good feedback to resolve your issue).

Edit: Ok, did find the specifications for the SenseAir S8 module, and it looks like the UART pins are 3v3 compliant, so that interface may be fine as is. Still might be an issue with the power up sequencing of the regulators though, so I think I’d still look at power to the buffer amps.

Hi LarryJ
Thanks alot for the very helpful reply!
I will change supply voltage to the op-amp tomorrow, and see if it helps. I don’t know why I gave it 5V in the first place… :confused:

In regards to the CO2 sensor I have contacted the manufacturer earlier and they assured me that:
“Yes, the S8 UART is running 3.3V CMOS levels. Actually, there is an onboard regulator that supplies the microcontroller with 3.3V.”

On a side note; I uploaded the wrong schematics:
On the right schematics the “imp LEDs” are not shorted to ground :smiley:
And D4, D5, D6, D7 (3.3V schottky) have been removed.

Not sure if the op-amp supply voltage will help @toebs, (hopefully), but seems like a good thing to do regardless to prevent the possibility of +5 on an imp pin. (Yes, I did catch that the S8 UART pins are indeed 3.3v compliant).

As it seems like it could be something that might be related to the power on sequencing of the regulators, perhaps it’s something you could look at if you have a scope … checking the 3v3 vs. 5v power upon startup, as well as maybe the imp inputs (i.e. op-amp outputs) also vs. 3v3 (imp power). Might help shed some light on the situation.

Ok im back and I put a scope to the two voltage rails and did a little testing.

See attached pics please

There is some sort of ripple on the 5V rail after connecting 12V.
The ripple disappears when i disconnect/reconnect a soil-moisture sensor.
The ripple also disappears if I power up the board slowly going from 0 to 12V.

What to make of this, could it be due to sequencing of the PSU’s somehow?

I’m not an LDO expert, but it appears to perhaps be a load dependent oscillation on the +5v? You might want to check your input/output caps, their ESR (what type are you using?), and layout for the 1117 device. I’m not sure it’s PSU sequencing related, just may be a load change on the +5v that squelches the oscillation.

Other thing that’s interesting is the delay between the +5v (sensor/CO2 power) and the +3.3v (imp power) … if I’m reading your time scale correctly, it’s about 200us? Not sure if this is an issue, but would be interesting to hear from EI if there might be any problems related to this.

From your initial description of the problem though, it seems like your measurement errors are correlated with this oscillation coming and going, so might be the thing to focus on. Again, not my strong suit, but I’m thinking maybe double-check the layout and caps related to U10.

(Did you end up switching the op-amp supply voltage over to the +3.3v rail?)

Hi @toebs -

Did a bit more digging to try to better understand the possible oscillation you’re seeing on your +5v line. Found a couple of links (here and here) that may be of interest as they discuss situations similar to what you’re seeing.

The short story seems to be that too low of an ESR on the AP1117 output cap might cause an oscillation. (Are you using ceramics?) This may be something for you to look into a bit further.

(Edit: hard to know though as the above information might be outdated. The current AP1117 data sheet from Diodes, Inc. indicates ceramic output caps should be fine, and makes no mention of a minimum ESR requirement. Still might be worth a try though to try a different output cap).

HI again.

Thanks alot for you inputs!
I havent had time to tinker with it yet, but on monday I will try to change the cap to a tantalum one for higher ESR.

I found this in the AP1117 datasheet:
“The output of the regulator. A minimum of 4.7µF capacitor (0.15Ω ≤ ESR ≤ 0.5Ω) must be connected from this pin to ground to insure stability.”

I will report back
/Toebs (who was logged into friends account, and didn’t know hot to delete forum post :))

Changed the output cap to a 10uF tantalum (what I had lying around). Now the ripple is gone and all seems fine :-). Thanks a lot for the help Larry!

Good to hear it worked out for you … thanks for the update.

Ok I am back with new misfortunes hehe. There seems to be some kind of spill-over or noise from one sensor reading to another.
What I experience is that if I connect or disconnect a sensor and leave it in (or out) it will have a slight influence on the readings of the sensors still plugged in.

If I do not change the sensor setup and just leaves lets say 1 sensor in its value will stay pretty fixed ±1%, and never jump like I see it when I connect or disconnect sensors.

I do not change the position or touch the sensors them selves, I only plug them in or out of the stereo jack.
See these results ("raw is ADC reading):

(three sensors connecte)
2015-02-06 16:19:11 UTC+1 [Device] 0 raw: 38793 44%
2015-02-06 16:19:11 UTC+1 [Device] 1 raw: 41642 47%
2015-02-06 16:19:11 UTC+1 [Device] 2 raw: 45611 53%
2015-02-06 16:19:11 UTC+1 [Device] 3 raw: 16 0%

(disconnected sensor “1” - Readings from “0” and “2” are affected
2015-02-06 16:20:23 UTC+1 [Device] 0 raw: 36953 40%
2015-02-06 16:20:23 UTC+1 [Device] 1 raw: 32 0%
2015-02-06 16:20:23 UTC+1 [Device] 2 raw: 44586 51%
2015-02-06 16:20:23 UTC+1 [Device] 3 raw: 0 0%

2015-02-06 16:21:22 UTC+1 [Device] 0 raw: 39145 43%
2015-02-06 16:21:22 UTC+1 [Device] 1 raw: 16 0%
2015-02-06 16:21:22 UTC+1 [Device] 2 raw: 32 0%
2015-02-06 16:21:22 UTC+1 [Device] 3 raw: 48 0%

2015-02-06 16:22:53 UTC+1 [Device] 0 raw: 37049 41%
2015-02-06 16:22:54 UTC+1 [Device] 1 raw: 32 0%
2015-02-06 16:22:54 UTC+1 [Device] 2 raw: 44858 51%
2015-02-06 16:22:54 UTC+1 [Device] 3 raw: 16 0%

2015-02-06 16:28:59 UTC+1 [Device] 0 raw: 40729 46%
2015-02-06 16:28:59 UTC+1 [Device] 1 raw: 16 0%
2015-02-06 16:28:59 UTC+1 [Device] 2 raw: 46171 53%
2015-02-06 16:28:59 UTC+1 [Device] 3 raw: 42026 47%

Can sense be made of this?

Are you scaling your ADC values with hardware.voltage()?

Just to give more information:
Readings from one sensor is sometimes affected If i change conditions for another sensor.

All sensors are in separate containers with soil and water.
Look at below results. Measurements at 17:09 has been steady like this for 15min ish, but when I add more water to soil where sensor “1” is, reading for sensor “2” changes by 5%.

2015-02-06 17:09:35 UTC+1 [Device] 0 raw: 39369 44%
2015-02-06 17:09:35 UTC+1 [Device] 1 raw: 22117 10%
2015-02-06 17:09:35 UTC+1 [Device] 2 raw: 45483 52%
2015-02-06 17:09:35 UTC+1 [Device] 3 raw: 42362 48%

2015-02-06 17:18:50 UTC+1 [Device] 0 raw: 39705 44%
2015-02-06 17:18:50 UTC+1 [Device] 1 raw: 28727 22%
2015-02-06 17:18:50 UTC+1 [Device] 2 raw: 49548 57%
2015-02-06 17:18:50 UTC+1 [Device] 3 raw: 42506 48%

Think we need to see your actual schematic here. This sounds like an issue in the input conditioning circuits.

As @philmy alludes, I suspect what may be happening is that your ADC reference voltage (i.e. VDDA) is changing slightly as you add or remove loads (i.e. sensors). You can do a quick check my sticking a voltmeter on your 3v3 line and seeing if it moves as you plug in or remove sensors. If that’s the case, then perhaps you can either stabilize VDDA, or use hardware.voltage() as suggested to compensate for this variation.

Hi again.
So heres an update:
First of all, thanks to you all for helping, I really appreciate it and do not take it for granted!

@Philmy: Sweet function, had not seen that it existed. It seems as if it might have solved my issue :slight_smile:

@Hugo: The schematic was actually attached in post1, but seems like the forum update removed it. I have attached it again.

@Larry: As always Larry, you are ready to provide some good insights. Thanks!

Im having problems attaching it to the forum, here it is as a dropbox link:
https://dl.dropboxusercontent.com/u/2119565/schematic_spider%20(3).PDF

Im not a 100% sure that the hardware.voltage() fixed the problem entirely, still seems that changing one sensors environment can have a small (1-2%) effect on readings on the other sensors.
It’s a little hard to track thou, so I have set up some data logging to see if I can track the changes and make sense of it.

Huh. Still can’t see the schematic :frowning:

Not seeing any bypass on U3, but if it’s close enough to C11 this may be fine. You may want to add some low-pass filtering on the sensor inputs - right now you could well have high frequency noise on there which could be upsetting things. The unity gain buffers are generally a good idea though.

Thanks hugo, it always amazes me how much time you spent helping us here on the forum given all you got going on :).

I have added bypass caps and lowpass filters with Fc ~ 30Hz. I am unsure how low I should go, maybe 30Hz is way low, I was just thinking about noise from 50Hz stuff?

Does it look sane?