-
Notifications
You must be signed in to change notification settings - Fork 5
dfrph issues #10
Comments
Original C++ code appears to assumed 5v which is a very common theme for much of the sensor code I've looked over. I'm not 100% sure this is a safe assumption. The dropout on the sensor seems to be ~80% of the op amp rails. I tested this down to ~1v where this is no longer linear. I believe this is where the magical 3.5 value comes from in the original sensor C++ src - ie, pH scale of 14/(80% of 5v) = magic number of 3.5. This is a good example where voltage is not needed. The range of the adc (for default mraa edison) is 0 -> 1023, the dynamic range of the pH sensor is 0 -> 14, however, the op amp voltage range appears to be 0 -> .8 * Vref. My c src scales the raw counts by 1/.8 = 1.25 to account for the limited op amp range. The C++ source converts to voltage first, then pH. The max voltage which can come out of the pH sensor is .8 * Vref. @ 5v we have 3.5 pH/v. This will only return a correct value if the sensor is operated @ 5v. This is a great argument to use normalized values vs raw counts, ie 0.0 -> 1.0 since a raw ADC count is meaningless outside of the sensor src. I could be wrong with the above guess at the magic number's origin, but I've tested on hardware for a range of rail voltages for neutral pH and it appears to hold true. *note - in the original dfrph c++ sensor code, the aRes value uses 1 << adc #bits = (for default mraa) 1024. Since it's not possible to read a value of 1024 from a 10 bit adc, it would not be possible to achieve the max unit value from the sensor. I see the 1024 value throughout our sensor C++ code. We should try to write our math according to how values are interpreted. An adc read can be viewed as a normalized value (disregarding drop-out or offset from the sensor hardware): Value(units) = ADCraw/ADCmax * UNITmax float DFRPH::volts() in my mind should be: float DFRPH::volts() |
Fixed the loop that averages pH value. |
On 07/26/2016 06:55 PM, Noel Eck wrote:
Many of the original drivers always assumed 5v, since Arduino Uno and For this particular case, the device only operates at 5vdc, so you have http://www.dfrobot.com/wiki/index.php/PH_meter%28SKU:_SEN0161%29 In devices where both 3.3 and 5.0 are supported, I always allowed Now is a great time to fix these oversights. I like the fact that you may have figured out what the magic number
When we ordered this sensor, we also purchased 2 bottles of Standard
Well, they are both equivalent -- I guess it's just a matter of how you I spent some time looking around this morning, and there are many sites But, I also found other sites that suggest that 1023.0 is the proper With 1024, we introduce a small error (4.8mV), which of course gets Sparkfun actually has a nice page on this: https://learn.sparkfun.com/tutorials/analog-to-digital-conversion/relating-adc-value-to-voltage Explains it well. So, going forward we should compute voltage using |
Close... But two issues:
|
Again, w/o the double read, I cannot calibrate the sensor. We can address this in the c driver sync tomorrow. Sorry Jon, I'm not sure I understand what you mean by averaging over a number of samples. Maybe you mean raw adc reads and then convert to pH? I also don't see why all C sensors need to have a filtering method. Isn't this easy enough to do from a calling method where the user will have control over the sample period? |
On 07/27/2016 01:08 PM, Noel Eck wrote:
Ok, so I looked at the Sensor Notes - indeed I marked the pH sensors as **DFRobot pH sensors These (both pro and non-pro) fail on edison. It always reports 3.75v. So maybe you are seeing a different manifestation of this issue
In the past it's never been a problem... Yes, I mean reading in a number As I mentioned, many of these sensors are noisy, it's just the way it |
be tested on real hardware.
than the computed voltage it should be averaging over.
The text was updated successfully, but these errors were encountered: