Skip to main content
Answer next question, strikeout mfr instructions, note pin DO
Source Link
slash-dev
  • 2k
  • 14
  • 12

The schematic only shows one trim pot (R23), and it does, as you suspect, set a level for the LED to illuminate. More of a GOOD/BAD indicator, and is available on pin DO.

According to my secret source, you are supposed to put the probe in the pH 7.0 reference solution and, with Offset defined to be 0.0, run the program and display the calculated pH value. You may need to decrease the trim pot gain to get smaller (the smallest?) numbers. Now take that displayed value and modify theEdit - official but totally bogus: Offset constant in the sketch to be 7.0 minus the displayed value. If the displayed value is 8.1,

#define Offset (-1.1)

Build and upload the modified sketch. This time, put the probe in your pH 4.0 reference solution and adjust the gain pot until the displayed value is as close to 4.0 as you can get. This will calibrate it for mostly acidic solutions.

According to my secret source, you are supposed to put the probe in the pH 7.0 reference solution and, with Offset defined to be 0.0, run the program and display the calculated pH value. You may need to decrease the trim pot gain to get smaller (the smallest?) numbers. Now take that displayed value and modify the Offset constant in the sketch to be 7.0 minus the displayed value. If the displayed value is 8.1,

#define Offset (-1.1)

Build and upload the modified sketch. This time, put the probe in your pH 4.0 reference solution and adjust the gain pot until the displayed value is as close to 4.0 as you can get. This will calibrate it for mostly acidic solutions.

The schematic only shows one trim pot (R23), and it does, as you suspect, set a level for the LED to illuminate. More of a GOOD/BAD indicator.

According to my secret source, you are supposed to put the probe in the pH 7.0 reference solution and, with Offset defined to be 0.0, run the program and display the calculated pH value. You may need to decrease the trim pot gain to get smaller (the smallest?) numbers. Now take that displayed value and modify the Offset constant in the sketch to be 7.0 minus the displayed value. If the displayed value is 8.1,

#define Offset (-1.1)

Build and upload the modified sketch. This time, put the probe in your pH 4.0 reference solution and adjust the gain pot until the displayed value is as close to 4.0 as you can get. This will calibrate it for mostly acidic solutions.

The schematic only shows one trim pot (R23), and it does, as you suspect, set a level for the LED to illuminate. More of a GOOD/BAD indicator, and is available on pin DO.

Edit - official but totally bogus: According to my secret source, you are supposed to put the probe in the pH 7.0 reference solution and, with Offset defined to be 0.0, run the program and display the calculated pH value. You may need to decrease the trim pot gain to get smaller (the smallest?) numbers. Now take that displayed value and modify the Offset constant in the sketch to be 7.0 minus the displayed value. If the displayed value is 8.1,

#define Offset (-1.1)

Build and upload the modified sketch. This time, put the probe in your pH 4.0 reference solution and adjust the gain pot until the displayed value is as close to 4.0 as you can get. This will calibrate it for mostly acidic solutions.

Responded to next question
Source Link
slash-dev
  • 2k
  • 14
  • 12

# Edit 1: Iterate?

Edit: It's not clear, but I also wondered if this procedure is supposed to be iterated. Go back to 7 and make sure that adjusting the gain didn't change Offset. Then test the pH 4 solution again; the gain pot may require a small(er) change. If it seems to be diverging, um, don't do that. ;) I think it would diverge only if the probe had an inverted response, which would probably mean it's bad.


# Edit 2: Fix the formulas in the provided sketch.

Edit 2: The schematic shows a non-inverting op amp with PH+ on the input, and p_AOUT on the output. The (adjustable?) gain is

Step 1: Determine the reference voltage

Step 1: Determine the reference voltage

Step 2: Set the gain pot.

Step 2: Set the gain pot.

Step 3: Calculate and print pH

Step 3: Calculate and print pH


# Edit 3: "Next question is how to convert this into a suitable formula?"

Ok, if you don't want to fix the formula in the code, you can fit a linear or quadratic curve to your data. Linear is actually recommended as "good enough", and that is effectively the change suggested in Edit 2. If we just use your data points, though, this would be the linear approximation:

float adjustedPh = phValue * 1.627 - 2.499;

...and the quadratic approximation:

float adjustedPh = (-0.01796 * phValue + 1.8056) * phValue - 2.94;

Edit: It's not clear, but I also wondered if this procedure is supposed to be iterated. Go back to 7 and make sure that adjusting the gain didn't change Offset. Then test the pH 4 solution again; the gain pot may require a small(er) change. If it seems to be diverging, um, don't do that. ;) I think it would diverge only if the probe had an inverted response, which would probably mean it's bad.

Edit 2: The schematic shows a non-inverting op amp with PH+ on the input, and p_AOUT on the output. The (adjustable?) gain is

Step 1: Determine the reference voltage

Step 2: Set the gain pot.

Step 3: Calculate and print pH


# Edit 1: Iterate?

It's not clear, but I also wondered if this procedure is supposed to be iterated. Go back to 7 and make sure that adjusting the gain didn't change Offset. Then test the pH 4 solution again; the gain pot may require a small(er) change. If it seems to be diverging, um, don't do that. ;) I think it would diverge only if the probe had an inverted response, which would probably mean it's bad.


# Edit 2: Fix the formulas in the provided sketch.

The schematic shows a non-inverting op amp with PH+ on the input, and p_AOUT on the output. The (adjustable?) gain is

Step 1: Determine the reference voltage

Step 2: Set the gain pot.

Step 3: Calculate and print pH


# Edit 3: "Next question is how to convert this into a suitable formula?"

Ok, if you don't want to fix the formula in the code, you can fit a linear or quadratic curve to your data. Linear is actually recommended as "good enough", and that is effectively the change suggested in Edit 2. If we just use your data points, though, this would be the linear approximation:

float adjustedPh = phValue * 1.627 - 2.499;

...and the quadratic approximation:

float adjustedPh = (-0.01796 * phValue + 1.8056) * phValue - 2.94;
Break Edit 2 into steps
Source Link
slash-dev
  • 2k
  • 14
  • 12

This is the "center" of the probe swing about pH 7.0. You need to determine the reference voltage, at

Step 1: Determine the reference voltage

At pH 7.0, fromprint out the raw analogRead return value - print it out, before inverting it. (The pot wiper should be at it's limit. Which way, I don't know. Changing the gain pot shouldn't change the analogRead very much at the low-gain end. If it does change it, turn it to the other extreme.)

#define CENTER 522
int avgValue=0;
for(int i=2;i<8;i++)  // take the average value of 6 center samples
  avgValue += (buf[i] - CENTER);
float voltage = (((float)avgValue) / 6.0) * (5.0 / 1024.0);

Step 2: Set the gain pot.

NextThis is determining the slope, but you need to maximize the swing for the most extreme pH you want to read, say 4.0. Using the 4.0 reference solution, adjust the gain pot so that the displayed voltage is close to +2.5V, say +2.25V to make sure it's not pegged at 1024. (Let's see, slope is negative, 4.0 is < 7.0, so voltage should increase...) With that reading, you can calculate the pH/V:

Step 3: Calculate and print pH

And now you should be ableModify the original computation to calculate and printuse the pH/V slope:

This is not even close to phValue = 3.5*voltage + Offset. -_-   I have found several source now that echo my original answer. Totally wrong, and wrong to the point of misleading. I do think thisthese steps will do it, though. It sounds good in my head, anyway. :D

This is the "center" of the probe swing about pH 7.0. You need to determine the reference voltage, at pH 7.0, from the raw analogRead return value - print it out before inverting it. (The pot wiper should be at it's limit. Which way, I don't know. Changing the gain pot shouldn't change the analogRead very much at the low-gain end. If it does change it, turn it to the other extreme.)

#define CENTER 522
int avgValue=0;
for(int i=2;i<8;i++)  //take the average value of 6 center samples
  avgValue += (buf[i] - CENTER);
float voltage = (((float)avgValue) / 6.0) * (5.0 / 1024.0);

Next, you need to maximize the swing for the extreme pH, say 4.0. Using the 4.0 reference solution, adjust the gain pot so that the displayed voltage is close to +2.5V, say +2.25V to make sure it's not pegged at 1024. (Let's see, slope is negative, 4.0 is < 7.0, so voltage should increase...) With that reading, you can calculate the pH/V:

And now you should be able to calculate and print pH:

This is not even close to phValue = 3.5*voltage + Offset. -_-   I do think this will do it, though. It sounds good in my head, anyway. :D

This is the "center" of the probe swing about pH 7.0.

Step 1: Determine the reference voltage

At pH 7.0, print out the raw analogRead return value, before inverting it. (The pot wiper should be at it's limit. Which way, I don't know. Changing the gain pot shouldn't change the analogRead very much at the low-gain end. If it does change it, turn it to the other extreme.)

#define CENTER 522
int avgValue=0;
for(int i=2;i<8;i++)  // take the average value of 6 center samples
  avgValue += (buf[i] - CENTER);
float voltage = (((float)avgValue) / 6.0) * (5.0 / 1024.0);

Step 2: Set the gain pot.

This is determining the slope, but you need to maximize the swing for the most extreme pH you want to read, say 4.0. Using the 4.0 reference solution, adjust the gain pot so that the displayed voltage is close to +2.5V, say +2.25V to make sure it's not pegged at 1024. (Let's see, slope is negative, 4.0 is < 7.0, so voltage should increase...) With that reading, you can calculate the pH/V:

Step 3: Calculate and print pH

Modify the original computation to use the pH/V slope:

This is not even close to phValue = 3.5*voltage + Offset. -_-   I have found several source now that echo my original answer. Totally wrong, and wrong to the point of misleading. I do think these steps will do it. It sounds good in my head, anyway. :D

correct vendor's code, based on schematic
Source Link
slash-dev
  • 2k
  • 14
  • 12
Loading
Add iterative possibility and shorted pins note
Source Link
slash-dev
  • 2k
  • 14
  • 12
Loading
Added #define example
Source Link
slash-dev
  • 2k
  • 14
  • 12
Loading
Source Link
slash-dev
  • 2k
  • 14
  • 12
Loading