
Hacking Digital Calipers - sohkamyung
https://www.notion.so/Hacking-Digital-Calipers-3ee7726f11ca431694dc70a1977516e4
======
anonymfus
So looking at SAMDcaliper.py I see that you just print these numbers as on US
keyboard layout. That has two major problems:

1\. If user's computer has a different keyboard layout that will enter garbage
instead of numbers. For example, in Russian keyboard layouts there is usually
a letter "ю" on the key which is used for dot on US keyboards, so instead of
7.31 you will get 7ю31.

2\. Excel accepts numbers only if they are entered with a proper decimal
separator which depends on Windows number format settings which are part of
regional settings. So for example in Russia (and apparently most of the world:
[https://en.wikipedia.org/wiki/File:DecimalSeparator.svg](https://en.wikipedia.org/wiki/File:DecimalSeparator.svg))
decimal separator is comma instead of dot, so even if user would switch to US
keyboard layout Excel will not accept the numbers with decimal dots, it will
think that they are just strings.

Both problems can be solved by using numpad keys instead: they are the same in
all keyboard layouts and KEYPAD_PERIOD key will enter a proper decimal
separator for Excel to accept.

------
michaelt
I looked into the sensing mechanism used by these cheap digital verniers [1] -
which involves overlapping capacitive plates.

What I couldn't figure out was how precisely the sensing worked, because it
looked like it would have to measure capacitance at the femtofarad levels, and
nothing I had access to could measure a capacitance that small - or monitor
the sensing process without adding enough capacitance to mess it all up. It
also looked like it'd be really sensitive to the distance between the plates,
but it didn't seem to control that particularly precisely.

If anyone here knows how they measure such small capacitances and how control
for the distance between the plates, I'd be fascinated to hear more about it!

[1] [https://www.mjt.me.uk/posts/digital-vernier-
teardown/](https://www.mjt.me.uk/posts/digital-vernier-teardown/)

~~~
AstralStorm
You measure discharge times repeatedly ensuring the capacitor is never fully
charged. Presuming you know the impedance, temperature and charge voltage you
can get very precise. It's a frequency counter after all.

Distance control is sort of weak which is why these are no good against
vibration.

Another way is to use contact resistance with very accurate bridge temperature
corrected voltmeter. More expensive. Essentially a potentiometer.
Dimensionality is less important, but contact still is. To do that you need a
high-ish impedance wiper you can slide over.

------
syntaxing
Really interesting! I recommend checking out Yuriy toys [1]. He's famous for
making an Arduino based DRO with these type of calipers. He goes in depth in
his reverse engineering process too which was a fun read.

[1] [https://www.yuriystoys.com/p/arduino-basic-dro-
controller.ht...](https://www.yuriystoys.com/p/arduino-basic-dro-
controller.html?m=1)

------
pantalaimon
Using an extra CPU just so you can write your logic in python seems …
excessive.

~~~
russdill
You could honestly due the whole thing with an attiny45, including the USB
HID. But it's a hacker one off, you do what you know.

------
scribu
Hardware noob question: How do you figure out when a packet of 24 bits
_starts_?

From the diagram in the post, the clock signal seems to just be identical
blocks of 4 bits.

Edit: Found the answer in one of the linked articles:

> Between each series of 24 bits there is a longer period during which CLK
> remains HIGH

~~~
abetusk
For others who are to lazy to link follow the linked article from the original
article, there is a section of code in the function "loop" (modified for
readability):

    
    
        void loop () {
    
          // if clock is LOW wait until it turns to HIGH
          //
          while (digitalRead(clockpin)==HIGH) {}
          
          tempmicros=micros();
          
          // wait for the end of the HIGH pulse
          //
          while (digitalRead(clockpin)==LOW) {}
          
          // if the HIGH pulse was longer than 500 micros
          // we are at the start of a new bit sequence
          //
          if ((micros()-tempmicros)>500) {
            decode(); //decode the bit sequence
          }
        }
    

so it looks like the 24 bit sequence is indicated by a 500 us pause between a
falling edge and a rising edge of the data stream.

[1]
[https://sites.google.com/site/marthalprojects/home/arduino/a...](https://sites.google.com/site/marthalprojects/home/arduino/arduino-
reads-digital-caliper)

~~~
unwind
I love that the input is using inverted logic due to the voltage translation
needed, but the code and comments don't mention this.

To me it looks like an obvious bug and first glance, since the CAPITALIZED
sigal states don't match between code and comments.

Glad I read the article first. :)

------
Baeocystin
Nice to see what model caliper Harbor Freight cloned, too. :D My cheapie HF
special has the exact same case & access port. Time to find out if it is
electrically the same as well!

~~~
pbhjpbhj
Isn't it more likely white-labelled, ie the same product sold under a
different brand, than it is cloned (reverse engineered from a product that's
on sale)?

~~~
zrobotics
White labelled: these same calipers are also avaliable at most auto parts
stores. Unfortunately they are all absolute garbage in my experience, simply
due to poor battery life. Removing the battery when storing is almost
required, as I have found they tend to drain the button cell in ~2 weeks even
in standby. On the plus side, they are actually relatively accurate; all 3
pairs I have tested meet their specs when measuring guage blocks.

~~~
semi-extrinsic
These cheapo ones seem to be around $20, while a proper Mitutoyo is $120.
Those last forever, as do the batteries in them. Why not get the good one?

~~~
Baeocystin
It's nice to have loaners, or ones you can share with people and not worry too
much about it. And I'd rather have three in convenient locations that just one
good one, as the accuracy is the same. That being said, the cheapies I have
don't have the battery issue mentioned above, either. That would get annoying.

------
chimi
Or you could do it with a camera watching and extract the numbers from the
image. I've considered this route many times for many types of devices.

------
mosselman
How is the board powered? By the same cell as is already in the calipers? What
is that thin connector called that runs from the SAM32 to the calipers?

~~~
ThatPlayer
The board is probably powered by USB, because if the whole point is to emulate
a keyboard and type in the numbers, then you're going to have USB anyways.

~~~
alias_neo
Not necessarily, ESP32 has WiFi and Bluetooth so you could emulate a Bluetooth
keyboard or so something entirely different using WiFi.

But yes, I suspect USB like you suggest.

~~~
unwind
Uh, the actual article says it's USB, and talks about HID implementation and
so on.

No need to second-guess anything.

------
paranoidrobot
While the article is interesting, it's a site that's annoying.

I use the keyboard to navigate articles frequently. This site intercepts
keyboard commands - page up/down does nothing, arrow keys select specific
elements rather than letting me scroll down. Worse, the article does not load
at all if you turn javascript off. I spent a few minutes trying to figure out
where the actual content loads from (since the page itself doesn't contain it
and just references JS) - but gave up.

I can't see why they've made these choices, it doesn't seem to give any better
UX than just having HTML and some CSS would.

~~~
omgmog
I would guess that it would be because Notion is mostly designed to be used as
a personal note-taking/todo/trello app (which it's great at!)

Though it's possible to "publish" or share your notes it doesn't look like a
well designed use of the platform.

~~~
userbinator
More irritatingly, Google's cache appears to have it available, but says "404"
if you actually try to access the cached version (my usual workaround for
these JS-only-app-sites.)

 _Though it 's possible to "publish" or share your notes it doesn't look like
a well designed use of the platform._

If you are actually editing the content then I agree that using JS makes sense
and could be obligatory; but then, sharing/publishing content in what should
obviously be a read-only form should really turn it into a static page. It'd
save them some bandwidth too, given that readers really do not need all the
functionality the JS has. (The app-*.js on that page is over 4MB!)
Unfortunately common sense is not so common.

