Metering – Instrument Projects

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/

Interfacing a Digital Micrometer to a Arduino & VGA Monitor

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.

Breadboard

male shrouded header to fit mitutoyo cable – https://amzn.to/2SIIeSL

PN2222A – https://amzn.to/2Mk8XEf

(2) 10k Ohm Resistors – https://amzn.to/2YnbCU7

6 pin male header (wires to Arduino) – https://amzn.to/32VdaEf

optional momentary push-button switch – https://amzn.to/2JWBeyS

Step 1: Mitutoyo Cable Schematic

Mitutoyo Cable Schematic Interfacing a Digital Micrometer to a Arduino & VGA Monitor

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

The Arduino connects to the Mitutoyo cable with a few components. A 2×5 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.

Step 3: 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;
long value_int; //was an int, could not measure over 32mm
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

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.

For More Details: Interfacing a Digital Micrometer to a Arduino & VGA Monitor

Tags

Related Articles

Leave a Reply

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

Back to top button
Close
Close