# Editing Mer/Documentation/BME Protocol

**Warning:**You are not logged in. Your IP address will be recorded in this page's edit history.

The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision | Your text | ||

Line 103: | Line 103: | ||

One might wonder how bme authors came up with numbers like 2252.362 and 2.81361. One hypothesis would be that someone measured a voltage for two adc8 values (perhaps one near the top of the range and one near the bottom), and used a straight-line fit for the rest. If the mV field is calculated by rounding to nearest int rather than flooring, and the two voltage measurements were both an integer number of mV, then there is exactly one pair of integer points that matches the data: adc8 of 238 was 3222mV, while 576 was 4173mV. Thus, without yet having looked for other simple models, it seems most likely that this mV field is calculated by some expression equivalent to mV = 3222 + round((adc8 - 238) * ((4173 - 3222) / (576 - 238.))), i.e. mV = 3222 + round((adc8 - 238) * (951 / 338.)); where the rounding function can either be C99 round or floor(x+.5), or rint with some rounding modes, so long as 3697.5 rounds to 3698. | One might wonder how bme authors came up with numbers like 2252.362 and 2.81361. One hypothesis would be that someone measured a voltage for two adc8 values (perhaps one near the top of the range and one near the bottom), and used a straight-line fit for the rest. If the mV field is calculated by rounding to nearest int rather than flooring, and the two voltage measurements were both an integer number of mV, then there is exactly one pair of integer points that matches the data: adc8 of 238 was 3222mV, while 576 was 4173mV. Thus, without yet having looked for other simple models, it seems most likely that this mV field is calculated by some expression equivalent to mV = 3222 + round((adc8 - 238) * ((4173 - 3222) / (576 - 238.))), i.e. mV = 3222 + round((adc8 - 238) * (951 / 338.)); where the rounding function can either be C99 round or floor(x+.5), or rint with some rounding modes, so long as 3697.5 rounds to 3698. | ||

- | Accordingly, some uses of this “instantaneous voltage” field would do well to convert to an integer adc8 value (or convert to an integer adc8 value then convert back to a non-integer mV value), in order to avoid uneven steps between values (sometimes 2mV between neighbouring values and sometimes 3mV). This can be done as adc8 = 238 + round((claimed_mV - 3222) * (338 / 951.)). | + | Accordingly, some uses of this “instantaneous voltage” field would do well to either convert to an integer adc8 value (or convert to an integer adc8 value then convert back to a non-integer mV value), in order to avoid uneven steps between values (sometimes 2mV between neighbouring values and sometimes 3mV). This can be done as adc8 = 238 + round((claimed_mV - 3222) * (338 / 951.)). |

The '''“Battery monitor check voltage (mV)”''' field has similar values to the “Instantaneous battery voltage (mV)” field, but without obvious regular spacing. I (pjrm) don't know how it's calculated. | The '''“Battery monitor check voltage (mV)”''' field has similar values to the “Instantaneous battery voltage (mV)” field, but without obvious regular spacing. I (pjrm) don't know how it's calculated. |

Learn more about Contributing to the wiki.