Pages: [1]   Go Down
Author Topic: Rs232 comunication with an inclinometer 0729-1752  (Read 895 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26634
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What are you using for RS232 level conversion?

Code:
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.
« Last Edit: October 08, 2012, 07:58:27 am by AWOL » Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26634
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What are you using for RS232 level conversion?

Code:
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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26634
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26634
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26634
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

yeah this i already tried ^^
Logged

Pages: [1]   Go Up
Jump to: