pH controller unstable in field measurements

Which design are you basing it off of, granted they are all similar, I am guessing pHduino from the averaging routine. Although that routine is used in a few of places :slight_smile: (hey it works great). With outdoor water bodies especially the bigger ones a little more care is needed in AC decoupling and filters on the input signal, there is a lot of noise out there and bodies of water like to pick it up, even just 100l. Damien's design and the older basic Stamp/owl2 design incorporate some additional filtering to help with these situations (an RC filter on the input plus some additional capacitors on the feedback loops).

You could also try oversampling and decimation to tighten it up a bit, take 16 reading at a set frequency then right shift(twice) the result instead of dividing it. Then take a moving average of the last N numbers of shifted results to further smooth the result. You will find that most commercial probes perform similar functions, but their reference voltages are general much lower I.E a 1.1 or 1.8 ref to the ADC. If you are building the circuit you can also use an instrumentation amplifier design which also helps, but requires at least 1 additional op-amp.

Thank you mates, those are some really good suggestions. I will try implementing some.

Have you also tried measuring right in the middle and at other parts of the tank, including at different depths? Can you eliminate the choppy conditions and test if that improves the precision? Could you try a sub-sample of the seawater in a bucket out of the wind? Long shot but- could the tank be reacting with the seawater?

Yes in fact a few days ago I went there, and had already done some of what you suggest,. The resulsts befuddled me a little bit. So:

  • Different depths in the tank do not show a relevant change in variation.

  • The water had some CO2 injected previously. I thought it could be from a poorly homogeneized mixture, but tried in another tank w/o CO2 and that's not the case.

  • Tried in low wind conditions, still no relevant improvement (although it's a liiiittle better).

  • Now comes the interesting part. I took a sample into half of a plastic water bottle, and the results are 100% accurate. Even if I moved the bottle/sensor around, so I guessed it was something else and not the wind. Then I thought of immersing the bottle with the sample into the tank, HOWEVER as soon as I touch the water surface (just the exterior of the bottle, the waters don't mix), I pick up that variation again.

So I am left guessing this has to do with the larger body of water picking some AC noise, or EM reflection at the water surface. Do you guys reckon it too?

Upon further inspection, turns out I took my 100 nF decoupling cap from the sensor entrance out of the design a few months ago. It was "eating" my sensor output, and the arduino was registering a lower voltage than supposed (maybe because of poor shielding at the time and it was picking power grid 50 Hz noise, so I had a quasi-AC wave), so I took it out. I bet this is causing me problems now, isn't it? Is the 100 nF cap adquate for this? And will some tin foil around the BNC connection help?

Also SparkysWidgets, my design is my own. I based some things in some designs, especially pHduino, but at the end of the day decided to go with an instrumentation amplifier, which as far as I remember none of the projects I saw used.

Thank you very much.
Cheers.

Try grounding the water .Connect a wire that is in contact with the water and connect it to the reference side of the probe...in this case if its a combination electrode , connect to circuit's ground or you may use signal conditioner (little expensive)

EC/pH transmitters
http://webpages.charter.net/tdsmeter/index.html

That's one fine idea, I'll try that :grin:. Hopefully tomorrow I'll be able to make a couple more experiments.

Well, "grounding the water" didn't work. The probe will always output the same voltage despite the solution it's immersed in. From taking a quick look at sensor construction, I think this is because I'm essentially short circuiting the reference and the sensing part of the probe.

The RC filter between the amplifier entrance and the probe also isn't doing a lot, it doesn't reduce variance (in fact, it looked like it exacerbated the problem) and it's still eating part of my signal, with the measured value decreasing by about 3 pH (although that would be taken care of after calibration, but since the variance is still there, it's pointless).

I also tried oversampling more than I already had, which reduces the rate at which the information is updated in the screen, but the variance is still there.

I'm all out of ideas now. I'm about to keep going forward on my project, variance or not.

I think by now you should have concluded: salt water is one big conducting body. I don't know how your pH sensor works but if you connect your sensor to a large body of conductor, you have added a huge capacitance to your input. That could potentially pick up noise very easily, just like a metal plate picks up all sorts of noise if you connect it to an analog channel. Pretty much the principle of capacitive touch screen. Grounding a good conductor would work but salt water is not a good conductor. I suggest you create a small plastic buffer in the tank and it needs to be small in size, then its rim is above water but with a few small holes on the bottom. Since the pH value should not vary quickly, those holes are going to slowly equalize pH inside and outside the buffer, but cut most electric conduction to the rest of the salt water. The less holes, the better the reading. Then just measure inside the buffer region but not the entire tank. I really want to know if this works. I'm interested in fish tank pH control, similar problem, right?

@liudr

Since the pH value should not vary quickly

that is an assumption!

In fact it depends on the context, for example in a river pH can change fast (pollution).
A small buffer would create a mini environment that misses the dynamics of the river.

How are you compensating for temperature changes?

River should be fine, not a conductor like salt water. You can dip the sensor in it without picking up much noise. I just fail to see anywhere there is a nature-made flowing body of conductors (maybe the ocean is kind of conductive but it's only slightly salty). :wink:

Seawater is 53mS/cm. That's conductive enough.

Are there pumps running in this tank? If so there's the source of electrical noise. Shield those.

Don't put any wire into this thing if there are animals in it. Copper is poisonous to marine life.

Don't put any wire into this thing if there are animals in it. Copper is poisonous to marine life.

Good point!

Solution could be something with serveral servos/steppenmotors that takes water samples - ?
Or other type of wiring?

There is one thing I think that was missed... I didn't read ALL the comments but I didn't notice anyone advising you to put a turbulence shield around the probe. Typically it is a piece of PVC pipe about 30 cm long assuming a 6 Cm probe. Your issue (and one of mine when I was working on a similar project was simply that any salt (of any kind) concentration in water will never be completely homogeneous), there will always be 'strata' of slightly different ionic concentrations of the solute and solution. The variances are statistical noise in that they will average out when the solute is used for it's intended purpose... even though a PH measurement is Logarithmic in nature and specification the average PH will be equal to the undisturbed sample... I think that you noticed in your measurements that the ""Sample" from the tank was usually the same number or very close to it while the tank measurement differed. PH measurements depend on the scope of the measurement and the measuring conditions, Your measurements will average out... make them at the same conditions every time to get the true value and eliminate conditions that could cause variances in the measured media... Thus a piece of PVC pipe and some more math to as I remember calculate the Mean Value of several measurements based on the use of the media being measured better to take a set of measurements, calculate the mean value and then repeat the measurement as outside conditions dictate probably when any changes have had time to reach equilibrium ... Chemical processes and use are typical variables as is temperature and flow about the probe. I think you have everything done except modifying the 'flow' about the probe and the measurement statistics. Your process seems to be well in hand however and I (for one) Applaud your hard work... IMO...

Doc

Thanks guys for all the input

@Docedison, liutr:

I have thought about using one such turbulence pipe, but at the time I didn't have a pvc pipe handy for it and tried with half a water bottle, but I still had variance and scrapped the idea. However, a PET bottle and a PVC pipe certainly have different dielectric properties and at the time I didn't account for that. I will try it as it sounds like a very valid idea.

@ChinaBuck:

I am compensating for temperature changes with a LM35 sensor, whose value is being accounted for in the math for pH.

@Delta_G:

I have left any pumps and solenoids far away from the tank, to avoid such issues.

ALL Submerseable Pumps are totally shielded, typically totally enclosed in a Stainless (for potable water) Steel housing that is SOLIDLY connected to the Power Line Neutral, are 3 phase 440Vac 1 to 50 (or more) HP devices. As they are AC induction type motors, they are rarely if ever a cause of noise, with the exception of the "Contactor" (relay). There is another class of pump that is a demand type that along with a flow-meter supply water on demand through a Variable Frequency Drive Controller, "VFD" pumps are triac driven in such a manner as to make a good sinewave at whatever frequency required for a given 'Volume/Speed for flow control. They are rarely a cause of noise, if installed properly "By Code" (Electrical Code). The "By Code" caveat extends to all commercial electrical work and is really a set of standards that ensure that all will (generally) work safely and properly.
My simplest recommendation would be First and Most Important is that there can be NO Possible Galvanic interactions of ANY Kind, Whatsoever with the tank, your installation or dissimilar metal interaction. The PH Probe if mounted 'in situ" must (especially for high flow rate) have a Turbulence Shield and should be totally ISOLATED FROM GROUND. The Second point is that a Faraday Shielded Transformer in the PSU is a MUST. The Transformer might well be an "Isolation" Transformer (Again with a Faraday Shield) and Well Grounded. The internal power supplies be separate fro the Analog portion and the grounds should be Split (separate WELL BYPASSED ANALOG POWER AND GROUND CIRCUITS) the design process is very similar to the requirements for medical devices because anything 'common' to both WILL AFFECT any measurements. Seems like overkill BUT it works. As a side but relevant topic when I started in the electronics business, professionally, I worked for a guy who told me "Design the device and make it work and work well, then start removing parts until it quits working (not critical parts but support parts)... put back the part that made it quit and then... You Might be close to a 'First Cut' at a working project design... If it helps I was involved directly in Irrigation, Chemigation, and Fertigation controllers (Pump and valve controllers, radio controlled) for 20 years. for explanation... Chemigation is typically liquid pest and fungal control chemicals injected into the irrigation water and fertigation is...) Again IMO (and experience) My information on pumps is admittedly 10 years old but still a good starting point as "I Been There, Done That"... more than once.

Doc

Thanks Docedison, your expertise surely is appreciated. I am a freshly graduated EE so I am still getting my feet wet in the business and many things are still new to me.

The transformer is remotely installed. I assembled a small electric board inside the building (about 5 meters away from the device itself) where I left everything like transformers, circuit breakers, solenoids, and the pumps are also a nice distance away. Inside the device box I only receive 24 VDC and I have a solid state relay for the (remote) solenoid which seems to have no effect on my results. Only PSU parts inside the box are some voltage regulators, capacitors and a full bridge rectifier, which I guess shouldn't be the cause for the problem.

However, everything is assembled in the same PCB and a single ground plane is shared for all components (both analog and digital), and they are physically connected (remotely) to the transformer center tap for 0V, as I wasn't able to achieve a stable virtual ground. I was aware from the start that this wasn't exactly the ideal setup but at the design stage I didn't anticipate it to be a big issue, and as it works fine in smaller samples, it still appears to be so.

What made me wonder is when you say "The PH Probe ... should be totally ISOLATED FROM GROUND.". Because I have the reference of the (combined) electrode - the "body" of the BNC connector, soldered to the PCB ground, as most designs I saw when I did my research did. Is this a problem? Or do you mean the "sensing" part of the electrode should be isolated from the ground/reference part? Because if it's the latter, it's not an issue, ground plane is isolated from the rest.

Tomorrow I will be installing that turbulence pipe (I got a 50cm long, 4cm diameter pvc pipe with a few small holes drilled in the bottom) to see if it helps. I'll post the results.

No, Not Quite. The Transformer should have a Faraday Shield internal to it's construction it is a foil Shield, carefully insulated and wrapping the core between Primary and Secondary windings the ends are not connected so it will not be a 'shorted turn' rather an electrostatic barrier between Primary and secondary. It is also mandatory to use a Good Quality dual winding common mode choke in the Primary winding with filter capacitors and sometimes in the secondary as well (Yes I have seen both utilized???) the Ground Lead is a part of the frame of the transformer and sometimes an electrostatic drain... a 1 M ohm resistor and 100 to 1000 pF in parallel from Ground to the metal case. All other grounds MUST Connect in a Star layout directly at the PSU Negative terminal (Or Common if you are using a Split Supply). The Star topology as you know forces all returns to one point rather than the more common "Daisy Chaining" this Grounds noise rather than 'sharing' it with everything else. This is also necessary because of thermo-electric (Seebeck Effect) precautions. I refer you to this Wiki article which should help especially if you ever need to design "Very Low Drift DC Amplifiers" it is one of several "Gotcha's" inherent.
http://en.wikipedia.org/wiki/Seeback_effect#Seebeck_effect and I remind you of what my Engineering Prof used to say... Good Design is a series of Successive Approximations to the Solution.

IMO

Doc

Hello again.

To my disappointment, the turbulence pipe didn't do anything. I got a 50 cm long pvc pipe, 4 cm diameter, closed on one end, and drilled 4 little 3 mm diameter holes on that end, to allow water to enter, and kept the rim above water level. All measurements done with the probe inside still suffered from the same variance, despite all tries (once again, when I take the pipe out of the water, that sample is 100% stable, if I immerse it again, the variance shows up). That makes me believe it's not PSU related noise.

I am using star grounding, my teacher at the instrumentation course made perfectly clear that daisy-chaining was bad pratice. One of the sides of my double-sided copper pcb is the ground plane and all ground terminals are soldered on that side. Then, that plane is connected through a wire to the transformer's center tap.

I will attach a picture of the important bits of the EAGLE project. Maybe I commited a horrid design flaw and haven't realized it.
IC6 is my instrumentation amplifier (an INA111), IC5 is merely a buffer ampop, and the different power supply components give 9v (IC1), -9v (IC2), 5v (IC3), 2.5v (IC4)

http://imageshack.us/photo/my-images/526/schematicx.jpg/ (R4 actually doesn't exist anymore, if I recall correctly)

Thank you.

Don't put any wire into this thing if there are animals in it. Copper is poisonous to marine life.

But it is an essential micro-nutrient also. Probably OK to use stainless steel though or gold plated electrodes.

Since the pH value should not vary quickly

Seawater pH should not vary much second to second, unless exposed to extreme pollution - it has it's own buffering capacity. Freshwater (eg river) has little buffering capacity compared to seawater and pH can vary dramatically with pollutant loads. Aquatic plants can alter pH even on a day/night cycle.

I think You are dealing with ground leakage currents, In other words there is a galvanic connection between your probe and the Mains return or neutral and the reason that I said that the PSU output cannot have any connection to earth ground, even an electrostatic one, thus the shielded transformer. Your Power Supply Must look like batteries to the instrument while following standard mains wiring isolation and safety, considering possibly reversed wiring, open Ground's and other "Unknown" catastrophes. Without that precaution the measurement must be done externally, That is not an issue however... You can always 'pump' a sample into a receiver and dump it when you are through. To test this hypothesis is simple in order to eliminate ground interaction (s)... connect a set of batteries to the device and try again, where the instrument is floating, not connected to anything else except the measurement sample. Your PSU Primary ground (Green Wire) should only connect to the transformer frame, Nowhere Else. I do need to say that you have to of course follow the applicable regulations in your country of origin. This device due to the nature of it's intended application is most very similar to a "Medical" Device in it's possible interactions with currents flowing from any other source, much like the necessary line isolation required for an EKG or EMG as whatever line leakage current flowing is also a part of your measurement current. The fluctuations might possibly be sampling artifacts of a big 60 Hz leakage current flowing between your probe and the local ground (the reservoir). IMO

Doc

Doc, I have a feeling you might have stroke the problem right on the head.

I've mentioned before that the PCB ground was connected to the transformer center tap. What I think I haven't mentioned yet, was that I also connected the center tap to the transformer frame, and thus to the green/yellow mains ground wire (I only did this because I thought it was the easier way to set the tap at 0V, because I was getting up to a 4V drift without it, thus getting the 12V and -12V I needed out of the two outputs, it's a 240V-24V transformer). So, my PCB ground (where the probe reference is also attached) is connected to center tap, which in turn is connected to the mains ground. Could this be the cause for that leakage?

I'll test tomorrow with some batteries just to test that hypothesis, and hopefully that will be the end of it. And if it does work, I have to find a way to have a stable center tap at 0V. If not, I think I'll just try to implement a way to pump a sample in a cup and cut the corners.

I'll keep you posted. Thank you.