Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Hacking Digital Calipers (notion.so)
204 points by sohkamyung on July 4, 2019 | hide | past | favorite | 35 comments


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) 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.


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/


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.


So I think you don't need to measure the capacitance per se. Instead you use the capacitances to make a series of (AC) voltage dividers. The lines that are individually broken out (call these the vernier lines) will have different degrees of coupling to the sense node, depending on the caliper position. Assume the capacitance of the sense node is fixed. The controller pulses each vernier line in sequence and measures the sense node in turn. The higher the capacitance of a given vernier line, the more voltage will couple across to the sense node. The highest pulse tells the controller which vernier position it's in, so the absolute voltage levels don't matter, conceptually speaking.

As for the distance between plates, a caliper ought to be made to a high degree of repeatability. PCB thickness not so much though, probably 10%? To first order capacitance goes as ~1/d. But again, the measurement is relative, not absolute. As long as all the capacitances are affected by the same distance factor, the scheme still works.

Anyway, that's an informed guess based upon those scope shots.


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...


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


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.


At least he didn't use a raspberry pi for this.


Yeah and he used an ESP32 but didn't make it wireless?


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


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...


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. :)


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!


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)?


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.


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?


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.


For a lot of products of this class that come out of Shenzhen, the answer to that question is a təˈmɑːtəʊ/təˈmæto sort of thing.


It's universal at this point. Who knows who originally designed that style of case.


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.


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?


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.


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.


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

No need to second-guess anything.


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.


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.


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.


As a dumb workaround to just read the article, opening the print preview dialog makes it scrollable with the keyboard. Though, Ctrl-P seems to be intercepted to... search? sigh.


I sent the discussion to the Notion support


Middle mouse click to open a link in a new tab also tries to open the link in a popup window, which Firefox promptly blocks and warns you about.


Started using Notion for a new job just over a week ago... and Notion is terrible.

Literally the worst web application I've ever used, and that's saying something. Even the most basic Markdown supporting wiki outclasses it by far.

Using Firefox, the simplest things are completely broken (eg middle mouse click to open a new tab doesn't work).

Page up/down (as you mention), let alone home and end keys. All broken.

Apparently they weren't aware of the problem, and test on Chrome, Firefox, and Safari.

Yet this is basic 101 functionality. So pretty solidly doubt they have any kind of release testing at all.

If anyone out there is considering Notion, for a not-100% Chrome using audience, look elsewhere. It's crap and will actively annoy your audience.


Agreed. The content of the article is fantastic, but I encountered this usability issue too. Home/End didn't work either.


I agree. Also (using the Notion iPhone app), the copy link in the menu doesn’t work, and the keyboard gets stuck open.


I also couldn't highlight text in Firefox for Android


Can not even middle click to open a link. It breaks everything about usability.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: