Digital Calipers – Arduino Android Serial Connection

Sending the caliper data through a serial connection to an android tablet.
Sending the caliper data through a serial connection to an android tablet.

For a comfortable readout and interaction the measurements from the caliper are sent to a standard android tablet. Data is exchanged via a USB serial connection. To establish the connection Android provides UsbManager which can be used to get a device list and find the desired device based on vendorID and productID. To get those IDs something like lsusb for linux or USBView for Windows does the trick.

Once the device is found, permission to access has to be obtained from the user. BroadcastReceiver is used to handle the asynchronous response. After receiving permission UsbDevice is used to find the correct interface/endpoints for communication. Setting up BaudRate etc. can be done manually by using UsbDeviceConnection.controlTransfer(...) if the correct values for requestID and the parameters are known. They might have to be looked up in the documentation of the USB adapter and might need some fiddling around until the desired configuration works. An alternative is the use of a USBSerial library like can be used.

In my setup the communication runs at 115200 8N1 via the bulk transfer endpoints without any noticeable connection problems.
To organize the data transfer a very simple request response protocol is used. The microcontroller keeps waiting for a request from the Android host. The standard request (“0x01”) makes the controller read and send the value from the caliper. To get the value the controller polls on the clock line for a long enough pause between HIGH/LOW to make sure a new measurement begins. More polling on the clock and reading the data line retrieves the 24 data bits. The value is send back as a two byte integer to the Android host. The host keeps accumulating bytes until the response is completed and displays the value.

ToDo next: Upgrade the UI with features for resetting offsets etc. And then its finally time to attach everything to the lathe.

Digital Calipers – connector circuit

The caliper runs from a 1.4v battery and cannot be driven by the 5v typical for microcontrollers. Like many other devices the ATMEGA also has a 3V3 output. Some people report successfully running a caliper from 3.3v but with the current one this did not work.
So for the final connection between caliper and microcontroller there are two things to be done. The supply voltage has to be brought down to drive the caliper and the output signals (Clock, Data) have to be level shifted up to ~5v again.
For the power supply a shunt regulator with a 470Ω resistor and two diodes works fine. Shifting the signals back to 5v is done using two transistors (BC548C) each in an emitter circuit. For the flexible connection between caliper and circuit board a usb cable (A/B) is used.

to project page

Digital calipers for the Boley lathe

Simple digital caliper
Simple digital caliper

The idea is to use a digital caliper for measuring the movement of the cross slide on the Boley lathe. A cheap digital caliper is used as a first test. For this cross slide a 150mm standard caliper is sufficient. Instead of the manual hand calipers there are also attachable calipers available. However they cost about twice as much and for this specific lathe there was no version that could have been attached without heavy modifications.

For a comfortable use a larger digital readout is required. The caliper will be hidden under some parts of the slide anyway. Therefore the caliper will be attached to a microcontroller which in turn will communicate with a small tablet to provide feedback and handle Input/Output.

The first step was disassembling the caliper and soldering four wires to its data port. (Gnd, Data, Clock, Power) Checking on the Oscilloscope showed the Clock and Data signals working and revealed the 6×4 Bit protocol used by the caliper. The second step was the connection to the microcontroller (Arduino compatible development board with ATMEGA328P-PU) using a provisory voltage divider.

to project page