[PATCH] Visualisation of individual oxygen sensor data for CCR dives

Jef Driesen jef at libdivecomputer.org
Wed May 10 05:07:59 PDT 2017

On 2017-05-10 11:33, Anton Lundin wrote:
> On 10 May, 2017 - Jef Driesen wrote:
>> I've implemented the scaling factor now. See attached set of
>> patches. It took me a bit longer than expected because there were a
>> few cases where the ppO2 still ended up being zero. And that turned
>> out to be for dives without external O2 sensors enabled (e.g. fixed
>> setpoint mode). But the tricky part was that the external PPO2 bit
>> seems to be reversed. According to the documentation [1] external
>> PPO2 is 1 and internal PPO2 is 0. But based on the data I have, it
>> seems to be the opposite.
>> BTW, I wonder if we should ignore the setpoint value when external
>> O2 sensors are used? Are setpoint still used in such case?
> Do we have any data from a Shearwater running as solenoid controller?
> Ex. On the JJ-CCR's they use a Shearwater Petrel with sensors which
> controls the o2 solenoid to try to get the o2 sensor values to match
> your configured setpoint.

I have data from several Petrels, but I have no idea how they were being 
used. Is it possible to detect this somehow based on the data itself?

> That said, I think setpoint values are still interesting to see, to
> validate how well the controller did manage to try to keep the o2 close
> to the setpoint.

After looking at the data, I had the impression that the setpoint value 
is "unused" because it seems to just contain some "dummy" value (for 
example the last used value, or some default value).

I'll illustrate with an example dive from Steve's Petrel (*). This dive 
has a fixed setpoint of 0.70 on every sample, but the ppo2 values range 
from 0.32 to 1.74!

(*) I can send you the data if you want to take a look. I don't know if 
Steve is okay with sending his dives to a public mailinglist, so I 
didn't attach it to this email.

To me that doesn't look like the dive computer is even trying to keep 
the ppo2 close to the setpoint. At least not to the setpoint value 
that's stored in the sample. Hence my question whether this value is 
relevant or not?

> Attached is the last iteration I did of the sensors patch. It has some
> minor differences from the one you included, but most of them isn't 
> that
> relevant.

The part where you add 1024 to the calibration value is actually worse 
then the original version where you only did that if the value is 
smaller than 1000. It works (although not perfect) for the Predator, but 
it breaks for the Petrel because it doesn't need any correction at all. 
The variant with the if < 1000 works for the Petrel because the values 
are always greater than 1000, and also for some Predators, but not all 
because sometimes the values are greater than 1000 too. So if you want 
to do it correctly, then you would need to check on the model as I did 
in the third patch. If you want, I can move that code from the third 
patch to the second one.

The SENSOR_AVERAGE is maybe a good idea to keep around. Might come in 
handy once we have a way to communicate the type of value (sensor vs 

> The only relevant information is that the adc offset value is probably
> in 0.025 mV as unit.
> Thats party based on the information in
> https://www.shearwater.com/wp-content/uploads/2016/07/O2-Offsets-Public-Notice-RevA.pdf

The info in the comments is indeed useful knowledge, but since we're not 
using the adc values, it's pretty pointless to store them in the parser 
struct. It's just a waste of space there. I know it's only a few bytes, 
but I see no good reason to clutter the code with unused stuff.

> The only real comment about the code is that I would have liked to see
> the calibration factor kept as a int, and just change the unit factor
> from .00001 to .000022, between the models.

What would be the advantage of that? That would mean yet some other 
field to store the scaling factor, or doing some "if (model == 
PREDATOR)" when calculating the ppo2. Now it's just done once in 
advance, making the conversion from millivolt to ppO2 independent of the 
model. I'm even tempted to pre-multiply the value with the 100000.0 
factor too, to get rid of an extra


More information about the subsurface mailing list