Digital scale and Arduino DRO

March 2015 (updated 13 January 2016)

Update 13 January 2016

I am officially abandoning this project, but will leave my notes here in case they are useful to someone. Instead I am going to flog my two scales and buy a complete 3-axis DRO off eBay from a Chinese seller, for slightly more than I paid for the scales for this project.

In the end, I just want working DROs for my mill – with time so limited I can’t justify expending more of it on this project.

After months of work I have two problems that I cannot address:

The bits received by the Arduino do not match the bits I see on my logic analyser. I suspect this is just an issue with my code, but it may be a hardware problem. If this were the only problem then I would persist with the project. However…

The bits I see on my logic analyser do not match the number displayed on the scale reading head. For lower numbers (say, below 200), they are out by <5. For higher numbers (1000 and up) they are out by a couple of hundred (so a couple of millimeters). Maybe I damaged the reading head, maybe the number on the reading head is derived using some arcane algorithm… in the end, if the data coming out of the reading head is incorrect, then there is little point continuing.

Ideas, suggestions, comments are all very welcome.

Project Notes

Useful online resources:

  • Instructables post on how to interface an Arduino with digital calipers, including circuit diagram
  • a similar post on Nut & Bolt, including a comment on interfacing with two or more calipers
  • a brief but excellent post on the data formats of various Chinese manufactured scales (I have assumed that mine are Chinese)

Work completed as of 28 March:

  • digital scales installed on my Hobbymat mill – page on this to be published soon….
  • settled on a base design including:
    • die-cast aluminium project box which will be mounted to the mill head, and include the display and buttons
    • 20×4 LCD display with I2C interface
    • 4 x ATtiny85’s to collect data for 3 x axis digital scales plus spindle speed sensor
    • ATMEGA328P to get values from the ATtiny’s, and drive the LCD
    • a logic level converter, to convert 1.8V data pulses from the scale to 5V to be read by the microcontrollers – I did not use the hack of running the microcontroller at lower voltage, as I needed to combine several scales and 5V was just easier especially for debugging… more on this logic level converter later…
  • I set up a test rig for the electronics and coding, using a spare scale destined to be a DRO for my lathe:
    • drafted some code to drive the LCD and get the data from the scale – some fiddling to get it working properly but no major issues
    • I hooked up my IkaLogic 2 logic analyzer to the scale, and found that the data protocol for this scale was different to anything else I have seen online – no big deal but I may need to adjust the code further for the scales installed on the mill, as the protocol may be different again…

Updates 12 July 2015:

Notes on scale wiring (left to right on scale):

  • Test scale:
    • Gnd – black
    • – white
    • – red
    • 1.8v – yellow
  • X-axis (300mm):
    • Gnd – black
    • – red
    • – white
    • 1.8v – yellow
  • Y-axis (150mm)
    • Gnd – black
    • Data – red
    • Clock – white
    • 1.8v – yellow

The test scale (a normal 150mm caliper) worked fine with the logic level shifter I was using – an Adafruit 4-channel I2C-safe Bi-directional Logic Level Converter (BSS138). However when I hooked up the 300mm X-axis scale, it powered up OK but appeared to be stuck at zero. Some further fiddling revealed ‘H’ and ‘INC’ appearing on the reading head’s LCD display, these are modes that should only be activated when data or clock pins are set to the display input voltage (1.8v). A quick check with the multimeter revealed that this was in fact the case. In fact all of the pins on the level shifted were showing positive voltage (either 1.8v or 5v).

I went to Adafruit’s site and had a look at the schematic – sure enough this device includes pull-up resistors. So, where there is floating voltage on either side of a channel, the other side is pulled high.

Further testing with a jumper wire on the test scale showed that it does not have the mode function, therefore the high voltage on the data/clock pins did not zero the scale as with the X-axis.

I tried pull-down resistors on the ATMega input pins but it just gave me 1/2 of 5v.

So, now I need to fab my own shifter, with pull-down resistors. Maybe this also explains why I got an unexpected sequence of bits…

19 July 2015

After some hours of googling for a voltage level-shifting solution which would not trigger the scale’s mode functions, I found what looks like a solution using two NPN transistors and some resistors here. While this looks like it would work, it involves quite a few components – a little further searching and I found a device that I had previously found and discounted: an Adafruit breakout for the TXB0108.

This little puppy can be used with external pull up or down resistors, and is 8-channel so can manage DROs for all three axis scales and a tacho (if necessary).

Have ordered one.

27 December 2015

Well, the TXB0108 didn’t work out – I just couldn’t get a signal on my logic analyser. After posting on the Arduino forum I got a very helpful suggestion: to use an op amp. After a couple of false starts I found the MC34074, a quad-channel op amp that will can be powered by a 5V single supply.

I created a reference voltage of 1.1V using voltage-dividing resistors from the 5V supply. This worked a treat and I was finally able to get clear and consistent signals on my ScanaLogic logic analyser.

I found that the scale was outputting two 24-bit words every 300ms or so. After some experimenting I found that the number on the scale LCD display started at the 4th bit of the second 24-bit word. Also interestingly, the scale is outputting a signed integer, using Two’s Compliment (as described here in the Arduino Playground).

9 January 2015

After much messing about the with the code I have finally got my Uno to print the value received from the scale onto a 20×4 LCD. The BitMath section in the Arduino playground was very useful for this.

Problem is that the number received by the Arduino does not match the number received by my logic analyser. The bits received by the Arduino seem to be consistently missing a bit – usually it is the 8th bit but for smaller values it is a random (but reasonably consistent) bit.

More work needed…

13 January 2015

After months working on this project I am officially abandoning it…



Leave a Reply

Your email address will not be published. Required fields are marked *