Another Open Source pH module

I'm still working through this to try to get it reliable at 100 KHz. As it turns out, rpi doesn't really support clock stretching, so I occasionally see a bad reading. The cause seems to be rpi reading the floating line after an ACK as a 1. It occurs less than 1% of the time, but that's enough to cause a problem.

1578149522711.png


I think some more optimizations in the I2C interrupt may be able to resolve this. If not, it looks like I'll have to switch to a different mcu.
 
I'm still working through this to try to get it reliable at 100 KHz. As it turns out, rpi doesn't really support clock stretching, so I occasionally see a bad reading. The cause seems to be rpi reading the floating line after an ACK as a 1. It occurs less than 1% of the time, but that's enough to cause a problem.

1578149522711.png


I think some more optimizations in the I2C interrupt may be able to resolve this. If not, it looks like I'll have to switch to a different mcu.
That’s a bummer. Is this a known thing ? Given rpi is so popular I would expect folks have some workaround for this . Or this should be a well known/documented. I’ll do some research
 
The clock stretching issue seems to be known, and it often works depending on how much stretching is needed.

I think I finally got it though; I just finished 10 million read cycles without any errors!
 
The clock stretching issue seems to be known, and it often works depending on how much stretching is needed.

I think I finally got it though; I just finished 10 million read cycles without any errors!
Nice. All my reading led to dtoverly configuration to basically readjust Pi's i2c clock to a lower rate.
 
I was able to get consistent good readings by slowing the i2c bus down to 50 kHz, but I didn't think that was really an acceptable step. I think I've finally crossed the last hurdle tonight! I'm excited to get this one done, and I'm feeling a bit inspired to try an ORP module next.

For some reason, I never add test points to my first prototype boards, so I end up with hack bodges to help troubleshoot problems. In this case, I repurposed the LED and ADDR pins as debug outputs (+ hot glue). I was able to use those with a logic analyzer to figure out what was taking time in the I2C interrupt. I also removed any other hardware that could be causing any kind of interference.

IMG_20200105_222536.jpg


These are the main issues I encountered.

1. ST peripheral library seems to be too slow to use for I2C. Instead, I'm directly programming against registers.
2. ST's optimized app note for I2C relies on significant clock stretching as a slave transmitter. I had to optimize the operations and orders of tasks in the I2C interrupt to prevent clock stretching at 100 kHz.
3. RPI has a bunch of noise on the I2C pins during startup, before I2C is actually ready. That was causing some issues since my board was starting in less than 1 ms and interpreting the noise as valid I2C communication.

I've learned so much making this board, so it's been very fulfilling so far.
 
Hi Michael,
I'm getting raw values of:
pH 2.5 : 3500
pH 9.5 : 4000

Does seem right?

Cheers
Chris
 
Cheers guys.
Is the number a translation of millivolts. i.e does a change in each unit represent 1 mV ?

Might need to reed the docs more. ATM I'm getting up to a 12 point variation between readings. Even after some averaging.
So roughly 0.2 pH
 
Cheers guys.
Is the number a translation of millivolts. i.e does a change in each unit represent 1 mV ?

Might need to reed the docs more. ATM I'm getting up to a 12 point variation between readings. Even after some averaging.
So roughly 0.2 pH
Id try redoing the 2.5 calibration. Something doesnt seem right with it.
How long between readings are you getting the 12 point variation?
Can u post a graph?
 
The calibration solutions were vinegar and borax. Just ballpark stuff to make sure the software was reading values something close.
FWIW this isn't using ReefPi. Just some hacked up python script.
Just put it in pH 7.0 calibration solution.
Reading is 3820. 15 point variance.
Now trying the git-hub source program (C). getting values between 3805 and 3840 over a couple seconds.
 
Is there a value that translates to a theoretical ideal pH probe 0 volt (pH 7.0)? and 177mv (pH 4.0)?
Trying to work out some offsets and probe condition.
I get around 3838 at pH 7.0
 

IF YOU HAD TO TAKE A REEFING EXAM, WOULD YOU PASS?

  • Yes!

    Votes: 32 45.7%
  • Not yet, but I have one that I want to buy in mind!

    Votes: 9 12.9%
  • No.

    Votes: 26 37.1%
  • Other (please explain).

    Votes: 3 4.3%

New Posts

Back
Top