Interesting to look at where all this came from, I found you code matches another I found, and there were lots of other references.
It seems that your calipers use the chinese protocol. That protocol does not have a bit that indicates units as far as I can tell from the other sources, so unless you see something in the bits above the sign bit, you would be better off picking mm or inches and doing the math. If, per chance. you find something in the bits above the sign, and you see that one of those bits change when you change units, you have found the units bit.
Remember, most of these devices have +/- 0.001" accuracy. Some of the calipers I found have 0.001" (0.025mm) listed, some say 0.001" (0.03mm). In any case, the calipers are not accurate to LSB of the readout, so a numeric conversion of units is fine:
On Fri, Nov 29, 2019 at 11:22 AM Chuck Pickering <chunk07@...> wrote:
I can't seem to get the two sketches combined to read the units bit and calculate the measurement based on that bit. Here is the two sketches that work, one for mm, one for in. Both depend on the mm/in switch be set to the measurement unit you want displayed. Am I missing something thinking I can do this? The only difference in the two sketches is how it converts the data to inch or mm. I think I might need to input the value of the units bit instead of reading it from the data.