You are correct of course, I have been reading too many bits of code the
majority being 24bit.
Richard
toggle quoted message
Show quoted text
On 30/11/2019 18:59, BuffaloJohn wrote:
The code is written for a 20 bit value and a 1 bit sign. If you look
at the code, you will see this. The 21st bit is the sign. Then the
rest of the bits are ignored. All the chinese inexpensive calipers
seem to use the same format.
Again, if you read the code, you will see he creates an unsigned
integer [value] and then he converts it to a float with a divisor,
which for mm is 100 and for inches is 2000. So, that means the output
is 0.01mm per bit for mm and 0.0005" per bit for inches.
Yes there are caliper data formats that are as you have said, this is
not one of them. His code works - his is not a 23bit signed value.
On Fri, Nov 29, 2019 at 11:55 PM Richard <edelec@...
<mailto:edelec@...>> wrote:
?From what I have seen a scale will be read as 24bits ones compliment
therefore having 23bits of data plus a sign bit. It will typically
have
a raw unit of measurement of 1/20480 of an inch. Having read the raw
value it would be displayed in inches by multiplying by 125/256
and for
millimetres by 127/1024. As the bit value equates to a probably very
noisy 0.000048828" it makes sense to lose some of the lower bits.
I intend having a play with some hardware and software.
Richard
On 29/11/2019 22:53, BuffaloJohn wrote:
> 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:
>
> Resolution
> 0.01mm = 0.00039"
> 0.0005" = 0.0127mm
>
> Accuracy
> accuracy 0.001" = 0.0254mm
>
> Buffalo John
>
> On Fri, Nov 29, 2019 at 11:22 AM Chuck Pickering
<chunk07@... <mailto:chunk07@...>
> <mailto:chunk07@... <mailto: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.
>
>