Pages: [1]   Go Down
Author Topic: RS232 Serial Tilt Sensor  (Read 908 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm new to using Arduino, and I've been trying to hook up a tilt sensor that communicates in RS232. I know the Arduino Duemilanove board uses TTL, not RS232, but I have a converter.

The problem is I can't seem to actually get the data from the sensor. The sensor I'm working should return 2 sets of data as it rotates around the x and y axis. I've other sensors on the board (potentiometer, etc) for practice and have gotten them to work. However when using this tilt sensor, I get just end up with a string of zero's. Now and then, when I move the sensor quickly, i''l get a -1.  :-/

My guess is that Arduino is trying to read both sets of data as a single one? I'm guessing there should be a way to tell the board to seperate them, but I haven't been able to find anything. Has anyone ever run into this kind of problem before?
Logged

UK
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2883
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You've not mentioned the device you're using, or the shown us your sketch - it is very hard to comment in cases like this.
Logged

Per Arduino ad Astra

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 509
Posts: 31452
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I get just end up with a string of zero's.
How do you know?
You are supposed to put it into the serial input but that is being used to allow you to see what you are receiving through the serial monitor.
What you need to do is to use another pin and software serial to read and maybe talk to your sensor.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey, sorry about the missing stuff from before.

My sketch is just the sample for the Serial.read()
http://arduino.cc/en/Serial/Read

The sensor I am using is this:
http://www.spectronsensors.com/datasheets/SDS-102-2104.pdf

 Forget what I said earlier about the string of zeros. It was a string of 1s, and it was because I was trying to read the Rx pin as digitalRead(0). I don't think that string of 1s actually means anything because I got the same thing if the sensor wasn't hooked up at all.


Grumpy_Mike, I think I get what you are saying, that the board cannot take in some serial data if I am trying to view the serial monitor at the same time, is that correct?

The goal of all this is for the board to turn 2 servos to compensate for the tilt of the sensor, but before I hooked up the servos I wanted a way to see if the data was actually being received correctly by the board. I have the RS232 sensor connected to the TTL converter, connected to the Tx/Rx pins on the Arduino board. Does the software serial define 2 new pins for serial communications? Effectively giving me 2 Rx and 2 Tx pins?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 509
Posts: 31452
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
that the board cannot take in some serial data if I am trying to view the serial monitor at the same time, is that correct?

Correct.

Quote
Does the software serial define 2 new pins for serial communications? Effectively giving me 2 Rx and 2 Tx pins?

Yes that's what it does.
Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Silly people!

I refer to the sensor manufacturer. On their "data sheet", they say "consult factory for.... comms protocol info".

But that's going to be worth the trouble. After you get it, send them a "suggestion" that they publish it!

Anyway... back to getting your device working...

I'd be tempted to start your work by hooking the sensor directly to a PC, and use a serial monitor on it... Hyperterminal should be okay, if you use Windows.

As for connecting an Arduino to both a PC and a second serial device at the same time, the notes in....

http://sheepdogguides.com/arduino/FA1serial.htm

.... may be useful, although in that case, the Arduino is outputting to the serial device, not reading from it. Not a lot of changes needed, though. I'm afraid that the page cited covers more than you are interested in, but within it is some useful-to-you stuff.
Logged

Pages: [1]   Go Up
Jump to: