Android Digital Readout Source Code

Monday, December 31, 2012
Main screen of the Touch DRO Androd app
Since posting the screenshots of my Android DRO application I've received a lot of feedback and a number of requests for the source code. As I said before, I intend to post the source code for the whole project, but the last few months have been insanely busy, and I didn't want to post broken code. Over the last few weekends I was able to clean the project up and get rid of the "failed experiments" code.

Arduino DRO Serial Protocol Considerations

Thursday, September 27, 2012

Last time I posted the schematic and firmware code for the Arduino DRO, for reading the iGaging scales. The plan is that the Arduino will read the positions and send it over UART to the app running on Android tablet via an inexpensive Bluetooth module. The nice part of using a serial-to-bluetooth adapter is that it's completely Plug-and-Play, so the hardware layer isn't too complicated. On the Arduino side we simply connected the Rx and Tx to the Tx and Rx on the Bluetooth board respectively, and provided power via Vdd and Ground. On the Android side all you need to do is to pair with the device. These Bluetooth modules use the so-called SPP (Serial Port Profile), also known as RFCOMM. When the controller is paired with the tablet it will behave like a regular serial port.

Arduino Wireless Digital Readout (DRO)

Sunday, September 23, 2012
Android Digital Readout Application
Application screenshot taken from Nexus 7

Recently I started working on a new version of my DIY digital readout project to that uses an Arduino DRO controller and an Android tablet. The DRO I'm building for my milling machine uses three inexpensive iGaging scales. (The whole set for my Hardbor Freight Mini Mill set me back less than $100 on amazon, in fact.) Since the bulk of the functionality is handled in the digital readout application, the controller design becomes much simpler, requiring only a few extra components. The parts list

In reality I've been toying with the software-based design for some time, and even wrote a basic desktop application on my computer. I scraped the idea of Windows application because without a touch screen the unit would be too cumbersome. When my Nexus 7 arrived in late July, it only made sense to use it for the DRO display unit. I've done some Android programming before, so it didn't take too long to get a basic app up and running. The app in the screenshot is a crude proof of concept, but I should be able to post a working version in a week or two.
As I mentioned before, my unit uses three iGaging scales and a controller based on Arduino UNO board to read them, as shown in the schematic below.

DIY DRO with Arduino and Android

Friday, September 21, 2012
Google Nexus 7 Running an Early Version of DRO Application

UPDATE October 2022: Since the time of the original posting, I've developed a few new designs that perform much better, work with more scale types and read the scales more reliably. The latest version uses an ESP32 wireless module. You can find the circuit diagram and instructions on the ESP32-Based DIY Digital Readout. Other designs that use MSP430 LaunchPad development board can be found in the Do-it-Yourself DRO Build Instructions

Having a full-featured DRO on a milling machine or a lathe would, no doubt, be very convenient. Unfortunately the cost of commercial units is very high, so the only way I could afford one would be to go the do-it-yourself route. My initial plan was to build a tradition digital readout unit using six 7-segment LED displays per axis and an ARM microcontroller (STM32VL Discovery Board). To build the first prototype I used the free version of Atollic Studio. Even though it was "crippled", compared to the full version, at least there was no code size limits. Well, as of the last version, Atollic added a code size limit so I decided to scrap the idea of an ARM-based DRO. Instead the DRO would consist of an Arduino-based scale driver and an inexpensive Android tabled as a readout display.

Arduino On a Beadboard - Uploading Your Sketches

Wednesday, February 22, 2012

A few days ago I posted some intructions on how to use a standalone Atmega328 (or Atmega168) on a breadboard. This approach offer a good cost reduction for Arduino-based hobby projects by reusing the USB-to-TTL circuit between the projects. The cost saving can be close to $20, but there is a small tradeoff in convenience. Instead of the customary "plug in the USB cable and click 'Upload' ", we will need to hook-up a few wires; nothing too bad, though. Let's look at two different approaches: using FTDI adapter and an existing Arduino board.

Building Arduino on a Breadboard

Sunday, February 19, 2012
Arduino on a Breadboard

In the previous post I showed threeways to reduce the cost of an embedded Arduino-based project: using one of the Arduino Pro variants, using a preloaded Atmega MCU and burning the bootloader yourself into  a blank Atmega MCU. For the first option, a “Pro” board with a Sparkfun's FTDI adapter all you need to do is to plug the board in (making sure that GND pin on the board matches that of the adapter) and you're good to go. The only drawback is the price tag of $20. The last option is the cheapest, but requires an AVR in-system programmed, and if you have an AVR ISP, chances are you don't need me to explain how to use it. The “Goldilocks” approach is to purchase the chips preloaded with Arduino bootloader. This approach provides a good balance between beginner-friendliness and cost. This is the option I will be using in my open source projects. In this post I will show you how to build a basic Arduino circuit on the breadboard.

Three Easy Ways to Reduce Arduino Project Cost

Arduino Pro Mini, Atmega 328 with Arduino Ominiloader Uno and a blank Atmega328P  

In response to the reader feedback I'm going to use Arduino for the DIY DRO Project and the stepper motor driven power feed. Arduino makes a great choice for beginners, in large part due to the standardized form factor and self-contained hardware. The flip side is that the boards cost between $35 and $70. “Wasting” a full-blown board for each little project gets expensive quickly. Every “mainstream” Arduino board comes with a USB-to-TTL adapter on-board that adds about $15-$20 to the board price. Having the adapter is convenient for prototyping, but in a “deeply embedded” projects this is a waste of money. Once you buy your first Arduino board or an “FTDI” adapter, the USB circuitry can be omitted. There are many ways to implement a minimalistic Arduino controller, but the most common ones are:

DIY Digital Readout Project Update - Display Boards Are Here

Wednesday, February 15, 2012
Ten brand-spanking-new LED display PCBs
for the DRO project

A week or so ago I finished laying out the LED display PCB for my DRO project. I built one unit some weeks ago using a prototyping board, but when a friend asked me to built one for her husband, I decided to bite the bullet and make a proper circuit board. This is by no means necessary, but wiring three MAX7221 on a prototyping board isn't my favorite pass time. Additionally, by using surface mount parts I was able to squeeze 24 digits (three rows of eight digits) and six tactile switches into a 5.75” x 3” board, whereas the initial prototype took 7”x5” prototype board for 18 digits (6x3) and no buttons.

Tramming Harbor Freight/Grizzly Mini Mill Column and Head

Saturday, February 4, 2012

Yesterday I installed the "Large Table Assembly" and the "Air Spring Kit" from, so today was the time to tram the column and the head. I've seen some people tramming the column by attaching a dial indicator to the quill and adjusting the column unti the reading on both end of the table are equal. There is one huge flaw with this method: it doesn't tram the column, it trams the spindle. If you look carefully, the head is composed of two castings. The part that holds the bearings and the spindle is held by grou long bolts, and, you guessed it, is not always parallel to the dovetails. A tell-tale sign that your mill has this problem is when you jobber drill bits miss the spot that you started with the started drill bit. Essentially the head is perpendicular to the table but the column being at the angle offsets the head in the X axis as you move it up and down.

Alignment Problems with Large Table Assembly

While tramming the head on my mini mill (after installing the larger table), I came across an unexpected snag. I attached the dial test indicator to the spindle with a quill-style holder and prepared to zero it out on the right side of the table, but I noticed that swinging it across the table changed the reading. In fact, after zeroing the indicator on the front of the table, the probe didn't touch the surface on the back. Checking the column with a square showed a 1/8" runout over 6". Apparently something went terribly wrong, so I started troubleshooting. I took the column off the table, cleaned the surface, ran a file across the edge to make sure there were no burrs.

X2 Mini Mill Table and Air Spring Installation Progress

As I mentioned in the previous post, I bough a large table assembly and air spring upgrade kit. Yesterday I had a few hours to work on my mini mill, and this is a quick update on the progress. Installing the table is actually a trivial exercise: unbolt the three hex screws holding the column bracket to the table and bolt it to the new on. Since I'm installing the spring kit as well, so I ended up taking the whole mill apart.

Large Table Assembly for X2 Mini Mill

Tuesday, January 31, 2012
Mini Mill Large Working Table Next to The Stock Model

I've had my Harbor Freight mini mill for over a year. Overall I like the mill, and can't imagine living without it, but after I started making some larger parts for my CNC router, I keep bumping into the limited Y and Z travel. I was almost set on getting an X3 mill, but one evening, while browsing LittleMachineShop's catalog I noticed that they had a "Mini Mill Large Table Assembly" for $299.95 (roughly $340 shipped). According to the description, the table provides 30% of extra movement on both axes. Long story short, I placed my order last Thursday and today UPS dropped (literally) the package at my garage door. The table came preassembled in a standard wooden shipping box, bolted down to the bottom board with two bots. UPS managed to seriously bust the box, but luckily the contents were undamaged. I haven't had a chance to install it yet, since I'm doing some other upgrades at the same time.

LED Display for DIY DRO - Introduction to MAX7219/7221

Friday, January 27, 2012

This is the first part of a tutorial on driving MAX7221/7219 display drivers with STM32VLDiscovery board. In this part we will cover the basics, i.e. how 7-segment display work, how the shift registers work and how to talk to MAX7221/7219 chip. In the next section I will post the source code for STM32 Value Line Discover board and explain the kay points. 

As I mention in the post on DRO Design Considerations, I decided to use standard 7-segment LED display for the position readout. Since the DRO is targeted at a small milling machines, 6 digits per axis is more than enough *. This means that we need to drive 18 dits total, and by far the most convenient way is provided by Maxim 7221/7219 shift registers. Many hobbyist are intimidated by these ICs, but under the hood they are very simple. Both chips use SPI protocol to receive data and can drive up to 64 LEDs, or 8 7-segment displays. MAX7219 and MAX7221 are almost identical, with one minute difference: MAX7219 is not SPI-compliant. I will elaborate on this a bit later, but for this project they are interchangeable.

Reading Grizzly iGaging DRO Scales with Arduino

Thursday, January 19, 2012

As I'm waiting for the parts for my do-it-yourself Android DRO, I'll start doing some proof-of-concept prototypes with the parts I already have. So, first things first - we need to figure out how to read the Grizzly/iGaging scales. The easiet way to reverse engineer the protocol is to connect a logic analyzer (Open Lgic Sniffer in my case) and see what's happening in the wires. The screenshot below gives a good idea how those things tick (no pun intended).

iGaging 21 Bit protocol captured by Open Logic Sniffer
21 Bit Protocol Capture

A Better DIY Power Feed for X2 Mini Mill

Wednesday, January 18, 2012
Power Feed Prototype on a Bread Board

Power feed is generally pretty useful, and a Mini Mill model can be had for about $150 from, but as usual, I want more than an off-the-shelf model could provide. I'm making some part for my CNC router and will have to do repeated passes to a specific position. Initially I was going to rig-up some sort of adjustable limit switch, but after some experiments discovered that they are not very repeatable (at the leas the ones I had). A stepper motor, on the other hand, could be programmed to stop after a predefined number of steps. I didn't want to do a full CNC conversion, so I decided to go with a simple microcontroller-driven driver that would let me set 0-position and then jog the table to that position multiple times.

Let’s Get Stated with the DRO Project

Sunday, January 15, 2012
First of all, after sleeping on the design for a few nights I decided to break the project into two stages. The first stage will be to make a functional DRO with basic DRO functionality. The second stage will be the stepper control and CNC functionality. The main reason is that the DRO will be useful by itself, and I think doing a proper G-code interpreter and stepper controller will take some time. As an added benefit, this makes for a smaller initial money outlay.

More Microcontroller Options for DIY DRO

STM32VL and STM32F4 Discover Boards
In yesterday's post I compared Arduino, LPCXpresso and few other microcontroller options for my digital readout project, but I completely forgot about my two newest toys: STM32VLDiscovery and STM32F4Discovery. I got them just a few weeks ago and haven't even had a chance to play with either, but they show a lot of promise.
These are ST Micro's evaluation boards for ARM Cortex-M3 and ARM Cortex-M4F microcontrollers. Mouser sells them for $9.88 and $16.25 respectively, placing them well within the reach of most hobbyists. Both boards come with built-in ST-Link/V2 programmer/debugger, and Unlike LCPXpresso's LPCLink, ST-Link is not locked into any particular IDE. There are even some reports of people using it with GNU C compiler and debugger. Better yet, the ST-LINK/V2 can be used to program any STM32 chip by manipulating a couple of jumpers.

Microcontroller Choice for the DIY DRO

Saturday, January 14, 2012

Arduino UNO, TI MSP430 Launchpad, FEZ Domino, LPCXpresso and MSP430F2132

The core of the DRO is the microcontroller, so that's where I will start. After some "back of the envelope" calculations, here are the basic requirements:

DIY Digital Readout Design Considerations

Friday, January 13, 2012

In my last post I mentions that I'm starting to work on a new DIY project - a “Digital Readout on steroids” for my Harbor Freight (Sieg X2) mini mill. I imagine it will be one of my “constantly evolving” projects, i.e. there likely won't be a “done” state, and new features will be added as I think them up. For now I pretty much made up my mind on what will be included in the initial version, but I will try to leave some space for future improvements. The first step will be to prototype the hardware and get the basic low-level functionality working, i.e. reading the scales, writing the position etc. I will make the design as modular as possible, so the parts can be reused or easily replaced if the magic smoke runs out. The unit will consist roughly of the following building blocks (I will go into more details in future posts...)

Some Ideas for the DIY DRO Project

Thursday, January 12, 2012
I bought my mini mill in January of the last year, and it didn't take long to realize that 16TPI lead screws with their silly 0.0625” per revolution were, to say the least, suboptimal. In other words dialing anything that involved more than one revolutions sucked really bad.
After some spelunking on the forums I was set on getting a DRO, but my puny toy budged wouldn't bear anything more than a Shumatech DIY DRO kit with a set chinese calipers. These kits are great value for the money, and with their new DRO-550 design running OpenDRO software they are simply a "cant's meow", but at that time Shumatech didn't have any in stock. Luckily one of the GrizHFmill goup members pointed me to Grizzly T23012 12" Digital Scale with Remote Readout scales. These work the same way as digital calipers, but have a remote display with a magnetic base (and are much easier to mount).