Introduction: Interfacing a Digital Micrometer to a Arduino & VGA Monitor

Picture of Interfacing a Digital Micrometer to a Arduino & VGA Monitor

Update: Igaging Origin Series use a Mitutoyo cable and output the Mitutoyo 52 bit datastream. The code and schematics below work with SPC Digimatic Calipers, Micrometers, Dial indicators, and Scales from both companies.

Discuss a variety of manufacturer's data formats and interfacing for all microcontrollers and SPC enabled measuring systems, like scales, micrometers, calipers, dial indicators, and more.

https://groups.yahoo.com/neo/groups/spc_dro/

We had a project that required connection to a digital micrometer with a data output jack. The idea was to connect a microcontroller to the micrometer, to read the measurements and make decisions based on the readings. The micrometers that we used are made by Mitutoyo, and have a funky 52 character data stream in reverse bit order. The microcontroller we chose is the Arduino, and we used a 4D systems uVGA-II to take serial output from the Arduino and display it on a VGA monitor.

Order a prebuilt interface kit:

Breadboard
male shrouded header to fit mitutoyo cable
PN2222A
(2) 10k Ohm Resistors
6 pin male header (wires to Arduino)

Now includes an onboard Arduino Nano clone with usb cable. No seperate Arduino needed.

Major Components:

Mitutoyo 293-335 Coolant Proof LCD Micrometer, Friction Thimble, 0-1"/0-25.4mm Range, 0.001mm/0.00005" Graduation, +/-0.00005" Accuracy, SPC Output

and

Mitutoyo 05CZA662, Digimatic Cable, 40", With Data Switch for Coolant Proof Micrometers

OR

Mitutoyo Absolute LCD Digimatic Indicator ID-C, Calculation Type, Inch, #4-48 UNF Thread, 0.375" Stem Diameter

OR

Mitutoyo 500-171-30 Advanced Onsite Sensor Absolute Scale Digital Caliper, 0-6" Range

OR

Mitutoyo 572-211-20, Horizontal Digimatic Scale Unit, 0 -6" X .0005"/0.01mm, With Output



µVGA-II(SGC) PICASO QVGA/VGA/WVGA Graphics Controller

Arduino Mega or compatible

Protoshield recommended

2 PN2222A transistors
four 10k Ohm resistors
2x5 shrouded header
one momentary pushbutton

Step 1: Mitutoyo Cable Schematic

Picture of Mitutoyo Cable Schematic

This is a diagram showing how the Mitutoyo cable is wired. There is a red "data" button on the micrometer end of the cable that we were not using in this application, so we decided to use it as a "menu" button.

Step 2: Connecting the Cable to the Arduino

Picture of Connecting the Cable to the Arduino

The Arduino connects to the Mitutoyo cable with a few components. A 2x5 shrouded header that mates to the female plug on the cable, a PN2222A transistor, and two 10k Ohm resistors. One resistor is used with the PN2222A to protect the micrometer (or caliper) from excessive voltage, the other to bias the "menu" button to +5vdc.

I've included datasheets for the PN2222A and drivers for the CH340 based Arduino Nano that we now use.

Step 3: Reading the Mitutoyo Output

Picture of Reading the Mitutoyo Output

The heavy lifting part of the code (thanks to Mark Burmistrak for his modifications from my original), that reads the data stream, reassembles it in correct order and prints a measurement is as follows:

int req = 5; //mic REQ line goes to pin 5 through q1 (arduino high pulls request line low)
int dat = 2; //mic Data line goes to pin 2
int clk = 3; //mic Clock line goes to pin 3
int i = 0;
int j = 0;
int k = 0;
int signCh = 8;
int sign = 0;
int decimal;
float dpp;
int units;

byte mydata[14];
String value_str;
int value_int;
float value;

void setup() {

Serial.begin(9600);

pinMode(req, OUTPUT);

pinMode(clk, INPUT_PULLUP);

pinMode(dat, INPUT_PULLUP);

digitalWrite(req,LOW); // set request at high

}

void loop() {

digitalWrite(req, HIGH); // generate set request
for( i = 0; i < 13; i++ ) {
k = 0;
for (j = 0; j < 4; j++) {
while( digitalRead(clk) == LOW) {
} // hold until clock is high
while( digitalRead(clk) == HIGH) {
} // hold until clock is low
bitWrite(k, j, (digitalRead(dat) & 0x1));
}

mydata[i] = k;

}
sign = mydata[4];
value_str = String(mydata[5]) + String(mydata[6]) + String(mydata[7]) + String(mydata[8] + String(mydata[9] + String(mydata[10]))) ;
decimal = mydata[11];
units = mydata[12];

value_int = value_str.toInt();
if (decimal == 0) dpp = 1.0;
if (decimal == 1) dpp = 10.0;
if (decimal == 2) dpp = 100.0;
if (decimal == 3) dpp = 1000.0;
if (decimal == 4) dpp = 10000.0;
if (decimal == 5) dpp = 100000.0;

value = value_int / dpp;

if (sign == 0) {
Serial.println(value,decimal);
}
if (sign == 8) {
Serial.print("-"); Serial.println(value,decimal);
}

digitalWrite(req,LOW);
delay(100);
}

Step 4: A Few More Auxiliary Schematics

Picture of A Few More Auxiliary Schematics

There are a couple more external connections that we added. First, a pair of "sample" buttons (foot and finger) for taking sample measurements of 3 points of a gear before averageing and using the final average number (and rejecting if the samples are too far apart). Second, a reset circuit for the uVGA Card.

Step 5: Output to VGA

Picture of Output to VGA

We used a uVGA-II (SGC) module from 4D to take the serial output of our Arduino, and display it on a typical vga monitor. The code to do this can be seen in the final step of this instructable. A special thanks to Rei Vilo for his assistance in this section - https://github.com/rei-vilo and http://reivilohobbies.weebly.com/

This has been replaced with the uVGA-III.

In your Arduino sketch, when you want to send data to the uvga module, use a statement like this:

uvga("N", value);

where N is the name of the variable on the uvga, and value is a variable containing the value you want passed.

At the end of your sketch (after the closing bracket of void loop) you have the following function:

int uvga(char* x, int y){
delay(50);

Serial3.print("$");

Serial3.print(x);

Serial3.println(y, DEC);

}

I'm using Serial3 on a Mega 2560, but you can use softserial and a UNO.

The code running on the uvga accepts that serial "packet", and puts the value passed into the variable that was passed, where it can then be displayed on the screen. Example code for the uvga is attached. It's a plain text file. You will need 4D's Workshop software and a USB to TTL cable to upload code to the uvga.

Step 6: Complete Code With Measurement Sampling and Vga Output

Picture of Complete Code With Measurement Sampling and Vga Output

If you would like to see how we applied this particular solution, we are using it to generate bin numbers for gear sets, based on measurements. Attached is our completed code, which was developed with the assistance of many others from the Arduino, 4D, and Arduinohome forums.

More details are available at http://tech.groups.yahoo.com/group/arduinohome/files/Arduino%20-%20VGA%20-%20Micrometer/

And http://arduinotronics.blogspot.com/2012/03/arduino-to-vga.html

The smaller file is just the code needed to display the raw readings from the micrometer. Divide the variable "num" by 1000 to get output in mm.

Step 7: Now in GFX Mode (4DGL)

Picture of Now in GFX Mode (4DGL)

We just did a major upgrade to the project. The screen output looks the same, but all the graphics processing has been moved to the uVGA-II. We bought a programming cable from 4D systems, and uploaded the new PmmC file which switches the card from SGC mode (dumb mode) to GFX (co-processor mode). This has greatly sped up the operation of the program. We also integrated a "packet" serial transmission function which sends data to the uVGA-II in serial packets, with a start symbol, a packet ID (designating which variable on the receiving end the data is destined for), and a end of packet symbol). This makes multiple destination data passing very reliable.

Details on this phase of the project can be found at http://4d.websitetoolbox.com/post?id=5858304, and we are grateful for the input from 4DSYSFAN and others.

Comments

aarontulin (author)2017-03-26

Based on the comments this hasn't been an issue for anyone else but the code above wouldn't read the bits correctly for my igaging caliper, mic or dial indicator. My oscilloscope showed the right data coming in but the arduino wasn't reading it correctly.

The solution turned out to be very easy. I changed the i variable for loop to close on the line after "mydata[i] = k;" vs "value = value_int / dpp;" as it's shown above.

strider98107 (author)2016-05-19

Hello,

Great job. I want to get "continuous" readings from my iGaging IP-54 depth gauge. I have the SPC cable from iGaging. From my noob status it looks like your void section does the measurement, so I wonder if the void section is looped, how many samples per second could I expect to get from this? (using iGaging with Arduino Uno).

Thank you!

Bob

sspence (author)strider981072016-05-19

The reading is continuous (void loop be definition is looped) and real time. I have not counted the samples per second, but it's faster than the eye can see.

sspence (author)2016-04-14

If you could. greentrust@gmail.com

sspence (author)2016-04-14

do you have a spec sheet for both? The website says the new one has the SPC data output. What voltage differences do you see?

sspence (author)2016-04-14

The product specs claim it's a digimatic protocol, so it "should" work. I don't have one of those to test.

ArichardsonWP (author)2016-04-01

Hello,

Have you finish the code that would allow for multiple calipers to measured at once? Also do you know how to read if the caliper is either positive or negative?

Thank You

sspence (author)ArichardsonWP2016-04-01

Yes on both counts. I'll try to get the code posted shortly.

ArichardsonWP (author)sspence2016-04-01

Thank you for the reply, I am looking forward to seeing it. Awesome project by the way.

perfo (author)2015-09-12

hello, great instructable.

Two questions please.

Are you intending at any point in to making this a 3 (or 4) axis reader? and any tips how I would identify (before I purchase) if a prospective calliper or micrometre would be compatible with this?

for $15 it's not worth me losing sweat and tears trying to build my own but I would need three axis on the same VGA output. OR serial/ i2c or some sort of output I could connect to a raspberry pi and make my own three axis display. I believe a lot of the cheap Chinese calipers etc use a different protocol but I'm not sure which ones are which...

Thanks again for the info...

sspence (author)perfo2015-10-02

Now that I have the Igaging SPC connectivity working, I have more time to build a VGA output 3 axis reader. Still need one?

sspence (author)sspence2016-01-17

Just finished the 2 interface board. Two such boards will give you up to 4 instrument measurements.

appsman (author)perfo2015-09-25

If a 3-axis machine DRO for use with Chinese caliper (or even higher quality) scales is what you're after, then search TouchDRO. I've built set ups for a mill and a lathe, and it is a killer way to a DIY DRO.

sspence (author)appsman2015-09-26

I looked at TouchDRO, and it's not what I'm looking for. I want more control over what I can do with the signals I'm reading, for activating other equipment, inventory and process control. The Arduino gives me that. I can easily measure a dozen different devices, and save data to a mysql database, display on a vga monitor, and direct other processes to happen. I'm currently reading micrometers, calipers, and scales, and will be expanding the number and types of data formats I can read. I'm working on Igaging Origin series now.

sspence (author)perfo2015-09-12

This particular project only works with the Mitutoyo calipers and micrometers. It would be easy to use three gauges,and read all three axis. I'm presently working on a companion piece that works with Igaging equipment. Poor man's DRO if you will.

sspence (author)2015-09-17

Now trying to do the same project with an Igaging Origin SpeedMic. Igaging is not being helpful with the pinout or the data spec.

storeyc (author)sspence2015-09-28

Shumatech has a write-up about the iGaging interface here - http://www.shumatech.com/web/21bit_protocol?page=...

I have a mitutoyo and am thinking I'll try your example to log data to a PC. I specifically want to automate height profiles as a function of length. This looks like a great way to do it cheaply. Thanks for sharing!

sspence (author)storeyc2015-10-01

The interface for the Igaging Origin SPC series is not 21 bit, it's the same as the Mitutoyo 52 bit protocol. Igaging bought the SPC interface from a third party.

gtoal (author)2015-09-30

If you want to add software support for another brand of micrometer, these guys reverse engineered a cheap chinese device: http://robocombo.blogspot.com/2010/12/using-tis-launchpad-to-interface.html and published the specs for the 24bit data stream. I'm not 100% sure, but I suspect (from a quick eyeball with a scope) it may be compatible with the cheap micrometer sold at Harbor Freight, which I've seen priced anywhere between $8 and $16 depending on their convoluted sales and coupon promotions...

EndresLPS (author)2014-12-22

Hi !

Could you please send me a link here to buy the complete kit ?

Thank you !

sspence (author)EndresLPS2015-09-10

A link to the kit is listed above! It's $15 for the interface board, and comes assembled.

sspence (author)2012-05-24

Questions, advice, or general observations appreciated. Please vote if you like this instructable.

About This Instructable

54,308views

38favorites

License:

Bio: Professionally, I'm an IT Engineer (Executive Level) and Electronics Tech. I'm a Amateur Radio Operator (KK4HFJ). I lived off grid, with Solar (PV ... More »
More by sspence:DIY I2C LCD Display with InputsRaspberry Pi & the Neo 6M GPSEarthquake / Vibration Sensor
Add instructable to: