How to make digimatic indicator reading by using arduino mega.

Hello. my name is Han-Jin Kim of South Korea. I'm Ph.d student for materials and science.

Recently, I used digimatic indicator of Mitutoyo and read by using arduino mega.

The product signal information is below. file number 1.

(follow the drawing image is file number 2.)

[arduino code]

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;

unsigned long time;

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 = k;
sign = mydata[4];
value_str = 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;
}

  • Serial.print("Time: ");*
  • time = millis();*
  • time = time/1000;*
  • //prints time since program started*
  • Serial.print(time);*
  • Serial.print(" ");*
    if (sign == 0) {
    Serial.println(value,decimal);
    }
    if (sign == 8) {
    Serial.print("-"); Serial.println(value,decimal);
    }

digitalWrite(req,LOW);
delay(5000);
}
I used like this system. But, I bought a new one for similar version of digimatic indicator of Mitutoyo.
The signal information was changed to attached file 3.
there are 1mole cable that indicate RD output. and circle was changed. so I can not figure out this.
How can make new drawing and arduino code for new version of digimatic indicator.
1.png


Edit your entry and insert code tags. As you might have realized, the forum system is mangling your code because you didn't use the code tags for the code. And fix the indenting or use the IDE's Auto Format tool (Ctrl-T).

Provide a complete wiring diagram of your setup. We don't want to guess how you wired the part of the system that isn't part of drawing #2.