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

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

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

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

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

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

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)

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.

Quote

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

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

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.

Change your transformer to a shielded type ground the frame to earth ground for fire/litening safety through grounding. You must I think keep the PSU and earth grounds separated, sometimes it is necessary to use a transformer with a high voltage type insulation for safety reasons particularly in sensitive situations where other equipment is connected as well, data loggers, RS485 Comm, 4 - 20mA loops... all are possible sources of interaction. It thus unfortunately becomes incumbent on the designer to make sure that the equipment's design isn't a part of someone else s faulty or shortsighted design work. Much the same should be said of software as well there are many obvious issues with software engineers trying to design hardware without a good idea of how the hardware must be supported. or how to condition analog as well as digital signals. I don't think much more need to be said about good by-passing methods ass these are required parts of any design. IMO

Doc

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

Doc, you nailed it. It was indeed an issue with ground leakage currents. I took out the connection between the center tap/device ground and the transformer chassis/ground and it worked like a charm . A small variation still occurs but it's in the order of 0.02-3 pH and it's negligible, it must be as you said from stratification of the water or other factors.

The only worry I have now is that my center tap will not be at 0 V and will have some drift, I've had that happen sometimes during testing stage (and hence why I connected to mains ground). What is a good practice to ensure that it, and therefore my PCB ground, will stay at 0 V? I didn't really want to have to buy another transformer.

Thank you so much! I honestly don't think I would have figured it out by myself. Living and learning .

The transformer is perhaps not as big a deal as you might think. There are split bobbin transformers that will fill most of the bill naturally. The PSU must look like a battery to the PH measurement equipment and I think you have perhaps one too many grounds. Perhaps a small capacitor somewhere is causing an offset to the input by charging to the absolute (peak) offset between the common or return leg of the power supply and the mains. Actually what I think is that you are seeing just that, it would only take a hundred pA of equivalent bias or leakage current. If you design your tool to operate stably from batteries and design your PSU to be an totally isolated battery most of your work will be done. IMO (Addition to text) After some thought, the noise in your measurement could be a need for modifying the sampling period ( take 3 or 4 measurements every minute or so and average the result per sample interval) sampling or low-passing the probe signal as the variations could well be 60 and 120 Hz sampling artifacts, noise that periodically occurs within the sampling period that is not directly related to the sampling period will look like small time variant changes in the sampled signal... Noise If you place a low pass filter between the PH meter analog end and the digitizing element (the A/D input) with a corner frequency of 10 Hz or so... I think most of the noise will disappear. Again IMO

Doc

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

Awesome job nailing this Doc, and I am glad that this is resolved as I am quite sure this information will help others as well. I will definitely add in this information to my pH tutorial for those that will be mains powering these types of interfaces. Actually this is quite good information in general, as if could be overlooked quite easily. Keep us posted on this project Androxys!

Sorry for no updates but I had other efforts to delve in and went back to this one a few days ago, only to find out that I am having problems again.

It was all working fine after fixing the ground leakage issue Doc pointed out. However, after about 3 to 4 weeks of usage, I was reported that the measurements were oscillating again. I went to the site and the situation was terribly worse than ever before.

Not only was the ph oscillating (by about 2 ph, in addition to being lower much than the expected set point, it should be around 8.20 and measurements went from 5ish to 8 ), but also the temperature sensor was reporting temperatures from 50ºC to 60ºC, when it should be 24ºC (and I had never had any trouble with the LM35 before).

First thing I checked was the power supply to see if it had a ground-neutral short. No such thing. After some research and a few hours in the think tank, I thought I had come up with a plausible theory. My guess was that I had a ground loop in the system which hadn't been problematic before. But now maybe my LM35 had acquired some condensation in the conductor (as I had used a cat5 with a plastic cap/epoxy on the sensor), which changed the capacitance, and that was adding noise which would go into the ph line through the ground loop, explaining both sensors going bonkers. However, I ran some tests where I only used one sensor and the other value was fixed, and I still have terrible variation in the water tank. Again, on a water sample from a bottle, it works great, so the problem involves the tank again.

After a few hours of trying different things, I realized that for some reason, the hose that is adding water into the system is the one responsible for my LM35 going bananas. I don't know why suddenly it does when it didn't before, maybe there was some change in the electrical installation of the pumps, but I doubt. If the hose as much as touches the water, a lot of noise is added into the system. Also, if the hose stays in the air and the water is dropped in the tank, it also adds noise (water carries the charge).

So, this solves the temperature problem, BUT the ph values still have a variation of 0.4 (when I should be looking at a 0.01 at most, as it did last time everything was working fine). I also thought it might have to do with a dirty sensor, I still haven't managed to get a hold of another to try it, but I still doubt it.

I also thought about adding a low pass filter to the entrance, however I'm not so sure about it. After designing it and looking at the bode amplitude plot, I realised that, as I'm doing a 200 value averaging for every measurement, the speed of every one of those 200 value measurement is faster than the bode plot takes to reach it's peak value. So every measurement would be undercut by a lot. And then there's the problem with high impedance and the filter probably will degrade the signal even further before it gets to the amp-op. And I kind of gave up on it. However I might be wrong, my filter design skills haven't been used a lot lately.

I measured the DC input to the arduino (for the ph) and the value is stable, however I also have a large enough AC value in it and that's probably the noise I'm having.

Anyone has any thoughts about what could be doing it? Or a nice filter solution?

Just out of curiosity, and a little desperation, I am going to try to fit a LPF in there, with a 100K resistor, 50 nF capacitor, for a T of 5 ms and a cutoff frequency of ~30 Hz. I wanted it to be lower but I don't want a large T. See what happens. I will later have you know how that went.

André

EDIT: two low pass-filters at 10 Hz before the ADC (one for each sensor), a severe cleaning of the ph probe, and a new lm35 solved my problems. Didn't manage to find the noise source though. Thanks for all the help guys.

EDIT 2: Just remembered I hadn't updated the post, for future reference to anyone who might need to know. Actually I did find the source. Some variation still shows up (despite the 10 Hz LPF) in windy conditions, even with a turbulence shield. In fact, the responsible for the noise is the water tap that inserts water in the system for recirculation (not the tap particularly, but the water in itself), because if I close the tap, the noise is gone. I guess it has to do with the waves that form in the water bay where the water is captured through a pump, on windy conditions. My mech. engineer uncle suggested that the waves could change the pressure in the pump's inlet which would variate the work, and it somehow was interfering with the system, maybe a cavitation effect or a low frequency noise.