Rs232 comunication with an inclinometer 0729-1752

Good morning all,

I’m trying to comunicate the arduino with an inclinometer (rs 232 comunication, sensor have 4 pins vcc, gnd, rx, tx so a found that the comunication should be easy) then i need to send to the sensor what i want (‘X’ or 88 in ascii, then ‘Y’ or 89 in ascii) and recive the angles.
I tried with softwareserial with no results.
I think hardwareserial should work but i dont realy know how to use it. I have searched for it but i just found ready examples that i didnt understand nothing. Have anyone any tutorial, or something explained in detail ?
Do you have any other ideia how can i comunicate to the sensor ?

The sensor is the inclinometer 0729-1752, and one of the codes using Softwareserial that i tried to use was that:

#include <SoftwareSerial.h>
SoftwareSerial portOne(2, 3);
int ax = 88;
int ay = 89;

void setup()
{

Serial.begin(9600);
portOne.begin(9600);
}

void loop()
{

portOne.write(ax);
float x = portOne.read();
delay(100);
portOne.write(ay);
float y = portOne.read();
delay(100);

Serial.print(x);
Serial.println(y);

}

Thanks for all, any help with be very welcome.

What are you using for RS232 level conversion?

 float x = portOne.read();

The "read" method returns an "int" representing a single character, not a floating point number.
You need to buffer the characters representing the float, and use an explicit method like "atof" to convert from ASCII.

I dont really know if a level conversion is needed cause i guess the sensor already have a level converter,
And i did comunicate the sensor with the pc using realterm (but unfortunately i cannot use a pc for the aplication) without using a level converter, thats why i think its a software problem.

RS232 communication to an Arduino does need a signal level converter.
RSR23 levels can be up to +/- 25 volts, and are inverted with respect to the TTL levels the Arduino expects.

AWOL:
What are you using for RS232 level conversion?

 float x = portOne.read();

The "read" method returns an "int" representing a single character, not a floating point number.
You need to buffer the characters representing the float, and use an explicit method like "atof" to convert from ASCII.

Yeah, thats problaby the problem, so do i need to recive int by int and create a buffer for that ? the signal from the sensor is 16bits for angles and 10bits for temperature.

the signal from the sensor is 16bits for angles and 10bits for temperature.

In which case, I don't see why you're trying to read a float.

Do you have a link to this device?

Sure,

http://www.frederickscom.com/pdf/6200-006-rs232.pdf
thats the mini signal conditioner board, the sensor is sold already on it by the manufacter as the 0729-1752 that you can see here http://www.frederickscom.com/pdf/0729-17XX%202009-03-03.pdf, but the instructions is in the first link.

OK, so it is RS232, so you do need level conversion.
It doesn't say whether the result is big- or little-endian, you'll need to figure that out.
You just read two bytes and either shift the most-significant left by 8 bits, or multiply by 256.

No floats involved.

Ok i will try that, working or not i will post it here then,
thanks a lot.

BTW

int ax = 88;
int ay = 89;

is much easier to read as

char xCommand = 'X';
char yCommand = 'Y';

(or whatever "Command" translates to in Portugese)

AWOL:
BTW

int ax = 88;

int ay = 89;


is much easier to read as 

char xCommand = ‘X’;
char yCommand = ‘Y’;


(or whatever "Command" translates to in Portugese)

yeah this i already tried ^^