Go Down

Topic: My pH experience (Read 792 times) previous topic - next topic

everone

Hi to all,

      I have started by asking the simplest question.

How do I get the items or similar items (shields and phidgets) to work just by them selves?

Going to start first with the pH Phidget 1130.
(Because it is the most important to me.)
 
     So first thing. Phidgets are a little different in the way they report data back to the device.
I originally found good info about this here http://forum.arduino.cc/index.php?topic=57924.0
ill give a thanks to that user. (mapiram)

     You will need the above info so look at it. I'm not gonna re write it because looking for information will strengthen your understanding in the end. so even though I have given you the place to look you still have to put a little effort in to get and understand the info.
your welcome.

Please make sure you understand how to utilize the Arduino before attempting a project. I like www.udemy.com courses but there are plenty of free resources out there. But remember when you pay for something you can expect support.

If you don't understand the other post ask and ill address your issue.

So back to the Phidgets pH 1130 and interfacing to your Arduino.

I stated by grabbing a set of jumper wires.

Red = 5v

Black = GND

White = Read (this will go on my A0 pin on my Mega)

I hooked my device through a bread board. When looking at the pics to ignore the wires I don't mention.

Wires


everone

Wires


jbike

The Sketch in the Arduino IDE (Examples/Analog/AnalogInOutSerial.ino) should show some values on the serial monitor. You might test the pH of some known reference liquid, and see if it needs the correction factor mentioned in your post (adjusted value = read value * 1.024).

everone

Ok so you should have your pH Phidget 1130 attached to your Arduino now.

    Lets talk about code.
Here is what I have come up with.


void setup() {
 // put your setup code here, to run once:

     Serial.begin(9600);
}

void loop() {
 // put your main code here, to run repeatedly:

                              // read the input on analog pin 0:
  int input = analogRead(A0)*(5.0/1024.0);
  int pH = (input*3.56)-1.889;
                             // print out the value you read:
 Serial.println(pH);
 delay(1);                   // delay in between reads for stability

}

So here we will be printing our value to the console. Later we will be printing to our display.

We set the serial with the Serial.begin(9600);            to be run once.

Then we run the read function.    

int input  = anologRead(A0);

This is going to read our Analog value from A0 (which remember from the other post is currently 0-1000)
See the following from Phidgets.com
The pH formula is listed as follows:

pH = 0.0178 * SensorValue - 1.889

SensorValue is an abstraction used by Phidgets because small decimal numbers in the range of 0-5V are not as intuitive as using the numbers 0-1000.  

The Arduino uses a range that is 0-5v = 0-1024 where as 0 = 0v and 1024 = 5v.
To get the Phidget to work correctely in the specified range we need to convert the SensorValue back into voltage. So we are going to use the function analogRead(A0)*(5.0/1024.0);

so our int looks like this now

int input = analogRead(A0)*(5.0/1024.0);

This gives us our input reading inbetwen 0-5v
Now we are going to turn this into a pH reading using the following.

int pH = (input*3.56)-1.889;

We now have a pH value.

Good luck



everone

The Sketch in the Arduino IDE (Examples/Analog/AnalogInOutSerial.ino) should show some values on the serial monitor. You might test the pH of some known reference liquid, and see if it needs the correction factor mentioned in your post (adjusted value = read value * 1.024).
Not Sure if the new post answers your question/statement.
But yes you have to convert back to voltage because 0-999 and 0-1023 are not directly proportional.
so to bring the ratio back into range we turn it into the directly proportional voltage range 0-5v.

allanhurst

And of course the arduino 5v ref may not be exactly 5v - measure it and scale appropriately.

regards

Allan

zoomx

#6
Apr 08, 2016, 03:01 pm Last Edit: Apr 08, 2016, 03:03 pm by zoomx
I believe that you should use fresh buffers to calibrate and you need to measure also fluid temperature.
Remember that float and double have equal dimension on Arduino: 4 bytes.

everone

And of course the arduino 5v ref may not be exactly 5v - measure it and scale appropriately.

regards

Allan
So we would rely heavily on the assumption that the Arduino team has built and designed for accurate and consistent voltage regulation. I have tested though and have no reason to believe this is not true that they have done so. i personally across all of my boards have seen less than .02 plus which is completely acceptable. If one were overly concerned they could monitor the voltage and have the voltage returned to the equation. Since 5v = 14pH even if you had a negative of 4.97v max input it would only effect the output at around 13.97 pH so you would be well within any reasonable expectation of such a device as we are working with. if this limitation was true you would design your specific circuits of your product to regulate at an even higher level of accuracy then the Arduino team does. Voltage above 5v makes no difference to the pH calculation.

everone

I believe that you should use fresh buffers to calibrate and you need to measure also fluid temperature.
Remember that float and double have equal dimension on Arduino: 4 bytes.
Hi,

    So not sure what you mean by "fresh buffers"? i assume you mean just buffer that hasn't been used?!
if so, then yes of course. I use lab grade buffers for Calibration from my Water Toxicology lab. yet there is no calibration built into this yet, so it is more of just reference.

     Thank you for mentioning temperature. it is important but was not necessary at this point of the document and will be addressed once i introduce RTD temp readings. here is a small abstract about temp and pH.

The Neutral pH is 7 at 25C and about 6 at 100C at room temperature ~7 meaning there are about 10-7 moles of H+ per liter of water at room temperature. As the temperature increases, the ability of water to ionize in this way increases and so the concentration of H+ in solution will increase (and hence the pH will drop).

Room temp is considered 25 degrees Celsius.

So to conclude we are only concerned above 25C.

Lastly can you elaborate on your mention of Float VS Double. i understand the difference and i understand that Arduino assigns only 4bytes which is why i stuck with Double instead of Float as Float would Make no difference in the outcome on Arduino.?  !

Delta_G

#9
Apr 12, 2016, 01:39 am Last Edit: Apr 12, 2016, 01:43 am by Delta_G
So to conclude we are only concerned above 25C.

And below 25C the pH of neutral water is higher than 7 because autoionization is less as temperature drops so there's less H+ and the pH is higher.  So you should also be concerned with temp below 25C if you want to be really accurate. 

And beyond the actual pH changes with temperature, temperature also affects the electrochemistry in your probe.  Your response slope will change with temperature, as will the membrane permeability, and the equilibrium in your reference cell. 
Ad hoc, ad loc, and quid pro quo.  So little time - so much to know!  ~Jeremy Hillary Boob Ph.D

everone

And below 25C the pH of neutral water is higher than 7 because autoionization is less as temperature drops so there's less H+ and the pH is higher.  So you should also be concerned with temp below 25C if you want to be really accurate. 

And beyond the actual pH changes with temperature, temperature also affects the electrochemistry in your probe.  Your response slope will change with temperature, as will the membrane permeability, and the equilibrium in your reference cell. 
Yes, you are correct. I miss-spoke when i said that we are only concerned with temp above 25C.   
     ill add just a little more information for people who are looking to have a better understand of pH and temperature.

   Generally speaking 25C is the temperature used for compensation on devices that do not have a temperature input. ?!

Find a great little bit here.

http://chemwiki.ucdavis.edu/Core/Physical_Chemistry/Acids_and_Bases/Aqueous_Solutions/The_pH_Scale/Temperature_Dependent_of_the_pH_of_pure_Water

Please support UCDavis.

zoomx

Since the pH varies with temperature, 25C was chosen to be the reference temperature. It is usually the reference temperature for other measurement.

Buffers change slowly with time but they change and usually there is an expiry date printed somewhat like food.

You will find temperature correction in Phidgets web site, in the same page where there are the other information about your board.

everone

Since the pH varies with temperature, 25C was chosen to be the reference temperature. It is usually the reference temperature for other measurement.

Buffers change slowly with time but they change and usually there is an expiry date printed somewhat like food.

You will find temperature correction in Phidgets web site, in the same page where there are the other information about your board.
You are correct about all of this good information.

  However you did not answer about the meaning of your statement regarding float and double?!

   Please elaborate on your mention of these?!

zoomx

Looking at the formulas you can see that there are numbers with as lot of decimals. Arduino can represent these values with only 4 bytes (float and double on Arduino has the same dimensions) and I suspect that they are insufficient. I don't know if this can be an issue, maybe not.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy