Pages: [1]   Go Down
Author Topic: Connecting to a sensor via serial  (Read 517 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone know if i can make a serial conneciton to an ocean server sensor using NewSoftSerial ? and if not how can i connect?

I have an arduino duemilonave(328) and i would like to talk to an OSServer 5500 sensor.

here are the links to the sensor:
http://www.robotshop.us/content/PDF/OS5000_Compass_Manual.pdf
http://www.robotshop.us/content/PDF/Compass_OS5000_Family.pdf

I have tested it and it seems to work via a sample exec that connects via usb and outputs tilt values. So i think the sensor is working correctly

When i set up the circuit to talk to the sensor via serial- i do get continous readings back from the sensor but they are all garbled and do not represent readable strings like:^*&^@&^WEUYI....
 
I am using NewSoftSerial library and i was wondering if i can actually use this lib connect to this type of sensor. The factory default baud is 19200, 8, 1, N according to the specs. Any help or tips would be much appreciated  smiley

here is the simple code i wrote:
Code:
#include <NewSoftSerial.h>


NewSoftSerial mySerial(3, 4);

int baudRate=19200;

void setup()
{
  Serial.begin(9600);
 
  mySerial.begin(baudRate);
 Serial.println("setup");
}

void loop() {
  int incoming = 0;
  if (Serial.available()) {
    
        incoming = Serial.read();
  }
  if(mySerial.available())
  {
    Serial.print(mySerial.read(),BYTE);
  }
 
}



Logged

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

Quote
but they are all garbled and do not represent readable strings like:^*&^@&^WEUYI.

That sounds like either incorrect baud rate or an upside down signal. Is the output of your sensor RS232? If it is you will need an RS232 to TTL voltage converter between your sensor and the Arduino.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 149
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

first i would check the proper operation of the sensor with hyperterminal on a PC. If this works (baudrate correct), then i would set the baudrate of Serial to the same baudrate or higher as mySerial, may be the 64 Char buffer overruns, if the sensor transmits without any delay.

Good luck
Mike
Logged

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

yes i have been checking the baud rate but i believe that it is correct.
and yes the connection is rs232, but i do not have a converter. I just have taken the lines directly from the serial port and connected to the arduino. Perhaps this does not work. Yes your right i should be trying to connect to a pc's hyperterminal first and validate all bauds. Not sure what you mean by 64 char buffer overruns but will look into that too.
not sure what upside down signal is but ill look into that too
Thanks for the advise
Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 225
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To read RS232 signals, you need an interface like a MAX232 chip.  This converts the RS232 voltage levels to TTL levels the Arduino expects on its serial pins.

RS232 uses negative voltage to indicate a "1", whereas TTL signaling uses a positive voltage to indicate a "1".  The MAX232 chip performs this inverting for you.
Logged

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

So you have put a negative voltage into your Arduino. Logic says this has blown it up, however if you are lucky you may have got away with it.

Quote
Not sure what you mean by 64 char buffer overruns but will look into that too.

Don't bother with that we have found your problem, it's not using a voltage converter / inverter.
« Last Edit: September 10, 2009, 03:57:32 pm by Grumpy_Mike » Logged

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

ok thanks , i see the tutorial on max 232 and if its like the other ones looks simple enough.

luckily nothing has blown up chip still is working on usb  smiley-wink

Really appreciate the help guys
Logged

Pages: [1]   Go Up
Jump to: