Assuming you have interfaced to a digital caliper using a cable and level-shifter such as described on the previous page, you'll next need to understand the format of the data.
The imported digital calipers that I’ve tested so far all seem to use one pin for the clock and one pin for the data. These pins are often shared with the buttons on the front of the caliper. So, pressing a button will interfere with the data output. Yet, this also means that your project can trigger the functionality of the buttons by bringing the data or clock line low.
The following traces were captured using a logic analyzer. Unlike reading an official specification datasheet, this doesn’t tell us the true maximum and minimum timings; it only tells us the average timing of one example caliper. Keep that in mind by coding some slack.
Full logic analyzer trace of 24-bit digital caliper data format.
Above is one complete caliper packet when the caliper display read “0.00”. The clock pin is initially low.
The packet consists of a long start bit, a 23-bit group, a long middle bit, another 23-bit group, and then one long stop bit.
Each group is in least-significant bit order. They form a two’s compliment value of the caliper value in 10240ths of an inch. (The caliper isn’t actually this accurate -- the least-significant bits oscillate quite a bit.)
Oddly, the second group has the bits inverted. For example, notice the data pin is mostly high towards the end, even though the caliper reads “0.00”.
The first 23-bit group is the absolute position since the caliper received power. The second 23-bit group is the relative position based on when the clear button was most recently pressed.
Start bit and data bit lengths of 24-bit digital caliper data format.
The start bit of the first group (A->B) is approximately 58.76 µs.
Each additional data bit is approximately 13.02 µs (B->C).
Data changes during clock high. Data seems steady when the clock is low. But, it’s probably best to read on the clock’s falling edge.
First group and middle bit lengths of 24-bit digital caliper data format.
The first data group (A->B) has 23 bits with a total period of 299.42 µs. That’s 13.018 µs per bit, which is close to the 13.02 µs measured earlier. It means the clock is relatively steady.
The start bit of the second group (B->C) is 117.2 µs.
Second group and stop bit lengths of 24-bit digital caliper data format.
23 more bits (A->B). Here is an example of the data being analyzed.
Ending (B->C) doesn’t rise up until the next packet.
Data line glitch in 24 bit digital caliper data format.
Data glitches can occur, particularly around machining equipment. Your software should be prepared to discard data that doesn’t match the expected timing for start and stop bits (or total packet length).
However, if the data pin switches state when the clock is high, that’s legal. Therefore, to be safe, data should be read on the trailing edge of the clock.
Two 24-bit groups is not the only data format output by calipers. There are many other protocols.
Let’s take a look at another data format that I’ve encountered from an imported digital caliper...