Go Down

Topic: Rs232 comunication with an inclinometer 0729-1752 (Read 994 times) previous topic - next topic

finthugo

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.

AWOL

#1
Oct 08, 2012, 02:54 pm Last Edit: Oct 08, 2012, 02:58 pm by AWOL Reason: 1
What are you using for RS232 level conversion?

Code: [Select]
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.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

finthugo

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.

AWOL

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.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

finthugo


What are you using for RS232 level conversion?

Code: [Select]
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.

AWOL

Quote
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?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

finthugo

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.

AWOL

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.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

finthugo

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

AWOL

BTW
Code: [Select]
int ax = 88;
int ay = 89;
is much easier to read as
Code: [Select]
char xCommand = 'X';
char yCommand = 'Y';
(or whatever "Command" translates to in Portugese)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

finthugo


BTW
Code: [Select]
int ax = 88;
int ay = 89;
is much easier to read as
Code: [Select]
char xCommand = 'X';
char yCommand = 'Y';
(or whatever "Command" translates to in Portugese)


yeah this i already tried ^^

Go Up