Code needed for PID pH control Will pay $

Hello Arduino Folks!

I have an :

Arduino Uno started kit
Gravity analog pH meter
2x 12v peristaltic pumps

Im looking for a code to control pH in a small vessel to maintain pH7 using a PID control strategy using the 12v pumps to pump acid or caustic as needed.

Can anyone help with this?

Thanks,
JBot

What is affecting the pH in the solution, other than the two pH adjusters?
Assuming this is a watery solution, what else will be dissolved in the water?
Why don't you use a buffer solution?

Hi Wvmarle,

Thanks for you reply.

Just to give some background. I am building an experiment to test the strength of different solutions . The pH of liquid I am measuring will be manipulated by the addition of acid or caustic then the I will measure the response of the system to achieve neutrality.

The pumps will pump different buffers in depending on the pH measured. I have different strength buffers I want to test.

That is why I am looking for a PID control code.

I hope this explains it.

What you're asking for doesn't make sense to me, I'm a chemical engineer though not really active in the field.

"Strength of a solution" is ambiguous, and without context has no meaning. I'm guessing you're looking for the concentration of either an acid or a base.

What you're describing sounds to me very much like you're actually trying to do a titration: take an acidic or alkaline liquid, add a base (e.g. NaOH solution) or acid (e.g. HCl solution), and measure the pH as you go. At some point the pH will jump several points with a tiny amount of liquid added - but won't go to pH=7. This is the point you're normally looking for.

Now you know how much titration liquid has been added, which allows you to calculate how much acid or base the original solution had.

PID control totally doesn't make sense here as it sounds like you don't want to keep the pH of a liquid constant, you want to test a reaction. That's pretty much the exact opposite.

You are correct, I want the rig to maintain the pH of a liquid.

The purpose of the code I am looking for is to take one input (analog pH sensor) and generate an output ( to either acid pump or base pump) based on a set point to maintain a neutral pH using PID control.

I am looking for someone who can build this code for me. What the liquid is or how strong the reagents are should be irrelevant to the code.

The requirement of PID control implies this is a dynamic system, prone to disturbances, and with (near) continuous addition of the pH adjustment liquids.

What are the dynamics here? What happens to the container of solution the acid and base are added to? How well is the container mixed at all times?

Do you know how to dial in a PID control? As that's always the hard part. The nature of the liquid matters big time at this point.

Is it always to be pH 7? Or also higher/lower pH?

You also mention you're working with buffer solutions - if the solution is a buffer or acts like one, that makes a huge difference to the controls.

Hi Wvmarle - Thanks for all the interest in my post. My ask is very simple, I think maybe I over complicated things by giving too much information in my original post.

My ask is:

PID code for an arduino to maintain a constant neutral pH or a liquid.

One input - Analog pH
Two possible outputs. - output to acid pump or output to caustic pump depending on input.

Can you write this?

Thanks

Sure. But are you sure you have the right components? The PHmeter has a response time of "<2mins" - how fast do you expect his to react? And what's the budget? The last question is vital, as you virtually have given no information on the circuit and the expeted behaviour, the time constraints, no datasheets, no schematics etc.

I think at this point existing parts aren't too relevant: parts cost will be lost in the noise on this project. Unless OP's requirements are really loose, or the supplier gets lucky, this is a five-figure project just based on the amount of time it will take to dial in the control system.

OP: the issue isn't the code, I could have this written for you by tomorrow if you wanted. The problem is adjusting the control parameters and getting the system working the way you need it to.
I didn't see a stirrer/mixer anywhere in your parts list: I would suggest adding one to save on the hair-pulling.

Joybot:
You are correct, I want the rig to maintain the pH of a liquid.

The purpose of the code I am looking for is to take one input (analog pH sensor) and generate an output ( to either acid pump or base pump) based on a set point to maintain a neutral pH using PID control.

I am looking for someone who can build this code for me. What the liquid is or how strong the reagents are should be irrelevant to the code.

This isn't a good way to try to control pH. I think maybe you should study up on solution chemistry first. Not just the basic web page type stuff, but take an analytical chemistry course. All you're going to end up doing with this is making salt.