Help decoding Serial Data from Mitutoyo Protractor [Solved]

Hello everybody,

I'm having a lot of issues trying to send to the serial monitor the output from the Mitutoyo Protractor PRO-3600.

According to the manual, the PRO-3600 has a 5V serial output, 9600 bps 8N1 with ASCII format. However, I'm not getting the right values. Some values are higher than 127.

The manual is here

The output format: XXX.XX , 9 bytes as I understand.

I wrote a simple sketch in a MEGA2560:

#define REQ 5

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial3.begin(9600);

  pinMode(REQ, OUTPUT);
  digitalWrite(REQ, LOW);
  delay(100);
  
  Serial.println("Ready!");
  
  digitalWrite(REQ, HIGH);
}
int count = 0;
void loop() {
  // put your main code here, to run repeatedly:
  while(Serial3.available() > 0)
  {
    byte c = Serial3.read();

      Serial.print(c, DEC);
      Serial.print(" ");

    if (count++ == 8)
    {    
      Serial.println();
      count = 0;
    }
  }
}

The serial monitor shows:

Output:

105 235 159 163 151 151 229 235 0 
105 251 171 163 159 145 229 235 0 
106 203 153 163 151 153 229 235 0 
106 139 159 163 153 147 229 235 0 
106 219 153 163 149 145 229 235 0 
105 219 159 163 153 149 229 235 0 
106 251 155 163 151 155 229 235 0 

Byte number:

 0   1   2   3   4   5   6   7  8

Byte 0, sometimes change while moving the PRO-3600 between 105 and 106, I'm guessing that byte represents the sign.

Bytes 4, 6, 7 and 8, never change. So, according to the format, I'm guessing that they represent the decimal point, carriage return and line feed. The '0' I don't know.

The maximum value showed in the PRO-3600 display is 90.0° and the minimum is 0.00°

Do you guys have any idea of what I'm doing wrong?

Thanks in advance!

Efel

The output may be 5V but it's RS232. You need a RS232/TTL converter or some level changing circuitry. When negative level signals are received the response of the USART is undefined. RS232 operates of +/- signals as detailed on p.8 in the manual. TTL operates on 0/5V.

Byte 3 (not 4) is likely the interpretation of a decimal point while 6 and 7 appear to be . The zero appears because you are reading 9 bytes. The first byte is likely lost as the signal expected to begin reception (typically a high-low transition) is not being received correctly. In all, the data is garbage because of the RS232/TTL level issue. Get the convertor, they're about a buck.

According to the manual, the PRO-3600 has a 5V serial output, 9600 bps 8N1 with ASCII format.

That means CHARACTERS.

    byte c = Serial3.read();

So, why are you not reading CHARACTERS?

From the manual: "Pro 3600 Serial Port The Pro 3600 has an ASCII-format RS-232 compatible serial port for remote angle readout." This means that the logic levels are inverted, and they go negative. Try using the SoftwareSerial library which has a way to invert the logic:

SoftwareSerial Pro3600Port(RXPin, TXPin, true);  // The 'true' means to invert the signal

In theory, applying -5V to an input pin could damage the Arduino. A diode in the data line with the anode (+) pointing to the Pro 3600 and the cathode (-) pointing to the Arduino should block the negative voltage. This might require a pull-down resistor (10k?) on the input pin.

You are getting data because the Serial input ignores framing errors. ANY high-going edge will be taken as the beginning of a Start Bit. The Arduino will read the next 8 pulse times and present it as a byte. Since the logic is inverted, it's seeing any Mark to Space transitions as a start bit and returning whatever is after that. Your data is inverted and shifted.

DKWatson and johnwasser, thanks a lot for your replies

DKWatson:
The output may be 5V but it's RS232. You need a RS232/TTL converter or some level changing circuitry. When negative level signals are received the response of the USART is undefined. RS232 operates of +/- signals as detailed on p.8 in the manual. TTL operates on 0/5V.

Byte 3 (not 4) is likely the interpretation of a decimal point while 6 and 7 appear to be . The zero appears because you are reading 9 bytes. The first byte is likely lost as the signal expected to begin reception (typically a high-low transition) is not being received correctly. In all, the data is garbage because of the RS232/TTL level issue. Get the convertor, they're about a buck.

DKWatson, you are absolutely right!

Thanks a lot for let me know my mistake. Here in my location is not fast/easy to get the converter, I ordered it online, and in couple days it will arrive, then I will continue the final implementation.

In the mean time, I tryed the suggestion from johnwasser, just a little bit different.

johnwasser:
From the manual: "Pro 3600 Serial Port The Pro 3600 has an ASCII-format RS-232 compatible serial port for remote angle readout." This means that the logic levels are inverted, and they go negative. Try using the SoftwareSerial library which has a way to invert the logic...

I don't why the SoftwareSerial didn't work. However, I used a NPN transistor to invert the logic and the Serial3. Now, I have the correct output.

:slight_smile:

-   1 8 . 6 1 
 
 
-   1 9 . 5 6 
 
 
-     5 . 6 7 
 
 
-     6 . 1 5 
 
 
-     2 . 7 0 
 
 
+     0 . 1 5 
 
 
-     0 . 5 6

Thanks again guys!

Kind Regards!

I don't why the SoftwareSerial didn't work.

Which pins did you try it on ?

UKHeliBob:
Which pins did you try it on ?

Hello UKHeliBob,

I tried in several pins, 10 and 11, according to this link -> https://www.arduino.cc/en/Reference/SoftwareSerial

So maybe the board is damage.

Regards!