Laser measurment device

Hello everyone.

I am new to Arduino and to this forum.

Basically, I am trying to connect via RS232 Riftek Laser RF605 with Arduino board that will act as a controller. I just need to read a measurement and send the data via serial to another device.

I have a problem with connecting with a laser device. It seems I can not get the “answer” back via serial (rs232).

Between RF605 and Arduinoo i use “translator” MAX3232 device as RS232 has 12V states and TTL (arduino) 5V.

It is a simple device with DB9 plug and GDN, Tx, Rx, Vcc connected to Arduino.

I send a request but no data is coming back. I have checked many side things (cable connections, replaced converter and Arduino board);

Serial1.write(0x01); //send unit id
Serial1.write(0x86); //send request “measure” 01h OR 80h = 86h

This is my request send via serial1 line - but not getting anything open.

I am kind out of ideas for now how to solve that - any help will be appreciated.

As far as I found in documentation

Serial1.write(0x01); //send unit id
Serial1.write(0x86); //send request “measure” 01h OR 80h = 86h

this should return measurment.

Below is full sample code

void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}

void loop() {
if (Serial.available() > 0) {
char select = Serial.read(); //sending toDo command to Arduino from other devive
if (select == ‘1’) {
do_measure(); //option 1 means do_measure
}

}
}

void do_measure() {
Serial.println(“Request send”);
Serial1.write(0x01); //send unit id
Serial1.write(0x86); //send request “measure” 01h OR 80h = 86h
if (Serial1.available() > 0) {
Serial.println(“Data recieved:”); // I cant get here - seems no answer is generated.
char recievedByte[4];
for (int pom = 0; pom < sizeof(recievedByte); pom++) {
recievedByte[pom] = Serial1.read();
}
char data1 = (recievedByte[0] & 0x0F) + (recievedByte[1] & 0x0F) << 4;
char data2 = (recievedByte[2] & 0x0F) + (recievedByte[3] & 0x0F) << 4;
uint16_t measure = data1 + (data2 << 8);
Serial.print(measure);
}
}

looking at the data sheet the serial data format is 8E1 (8bit, even parity, 1 stop bit). Arduino default is 8N1 (8bit,no parity, 1 stop bit)

in you setup, try replacing Serial1.begin(9600) with Serial1.begin(9600, SERIAL_8E1)

Hello

Indeed I made a mistake. I have already fixed that and changed 8N1 to 8E1. I haven’t noticed that.

The device still is not responding.

After sending request to the device

Serial1.write(0x01); //send unit id
Serial1.write(0x86); //send request “measure” 06h OR 80h = 86h

There is no reply as Serial1 - is not returning any bytes to be read:

if (Serial1.available() > 0) {
Serial.println(“Data recieved:”); // I cant get here - seems no answer is generated.

I just have very last thought.

The device comes with RX,TH and Ground - common for RS232.

I am using a standard converter with a female plug (as an attachment).

I am connecting via male plug:

I have RX connected to 3 pin
I have TX connected to 2 pin

Maybe it should be changed as male is changed.

Confused on that:)

US-235_RS-232_male.jpg

Kassolari:
I am connecting via male plug:

I have RX connected to 3 pin
I have TX connected to 2 pin

Maybe it should be changed as male is changed.

Confused on that:)

just try reversing the wires on you arduino first to see if you get anything ie:

RX connected to 2 pin
TX connected to 3 pin

When I reverse on board side tx with rx I am getting some trash values.

I can also disconnect db9 plug and I am still getting some trash values not correlated with anything.

It is weird that values still appear when db9 is disconnected.. like air values.

I need to take a break to get fresh mind.. i am very flustrated with that.

PS

I am using Serial1 on Arduino Mega so I am using 18 & 19 ports.

You may need to jumper RTS (Request To Send) over to CTS (Clear To Send) if the device uses those flow control signals. You may need to supply DSR (Data Set Ready) or DTR (Data Terminal Ready) in case those flow control signals are used.

Did you remember to connect Arduino Ground to the Ground of the level converter?

Hello

Thanks for the answer. Any help is appreciated.

The device requires:

BaudRate = 9600;
DataLength = 8 Bits;
StopBits = 1;
Parity = Even;
HardwareFlowControl = None;

I have setup Serial1 as 8E1 - fixed.

I wonder about HardwareFlowControl - how to set this up on Arduino - cant find data on google.

I resoldered the pins:

Male DB9:

(RX) to 2pin, (TX) to 3pin , GND to 5 pin.

Now I try 2 solutions:

  1. I plug Male DB9 (from laser sensor) into RS232 converted (Max3232) and I connect Tx,Rx,Vcc,Gnd into Arduino.

Still no answer from device.

I have contacted manufacturer (and they try to help me)

This device uses low voltage: “Our device RS232 also not 12V logic. There is ±4.2V. It uses this chip: http://www.analog.com/media/en/technical-documentation/data-sheets/ADM101E.pdf

  1. I try to connect directly RD605 with Arduino as voltage logic are the same levels (0-5V).

Rx from RF605 to Arduino Tx, Tx to Rx and Gnd to Gnd.

Still no answer.

It is 3rd day I am working on this issue :slight_smile: and I really start not to have any idea what could be wrong.

My code is in the attachment - maybe somebody can take a look and tell me If I made some mistake.

Tommorow I will buy USB/DB9 converter and I will try to connect directly with PC (as they provide software).

I wonder if the device can be damaged… or I am doing something wrong all this time.

Thanks for help in advance.

rs232.ino (937 Bytes)

One thing to note:

Serial1.write(0x86); //send request "measure" 01h OR 80h = 86h

0x80 | 0x01 is 0x81, not 0x86. Fortunately, 0x86 is the right value for “Inquiring of result”.

Programming manual in case anyone else wants to play along:

Are you sure the device is set to factory defaults? Someone could have set the device ID or the baud rate to non-factory values. You may want to try other ID’s and baud rates. It should not take long to go through every choice:
ID from 1 to 127 and baud rate from 12400 to 1922400.

Hello

I bought USB - UART device and I plugged the laser into it and used manufacturer software to see if it works.

Surprisingly it did not work :)

So I have sent the device back to the manufacturer. Once I get a solution I will let You know.

Basically, it is only solution for precise (0.05mm) surface measurements for Arduino.

You send out the serial commands and then on the very next line expect an instant response. Is that reasonable with this device?