Pages: [1]   Go Down
Author Topic: Razor 9DOF  (Read 524 times)
0 Members and 1 Guest are viewing this topic.
Ontario
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Starting from scratch is an understatement!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello
I have the Sparkfun Razor 9DOF SEN-09623 which uses the 3.3V 8MHz ATmega 328
I downloaded the code through the sparkfun pages and it works well enough when running through the FTDI basic serial to USB converter. When I try to run it through an Arduino board it seems that I need to hold down the reset button or connect the CTS pin to reset.
The problem I am facing is when the reset is not pressed or used the rest of my software on the Arduino works fine but the razor card doesn’t transmit and when I use the reset for the Razor the rest of the program stops.
Not going into details on the code is there a few lines that I can insert into my code on the Arduino which will allow me to take data from the Razor and still allow me to use the Arduino for my original task?

Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having a hard time understanding the problem as stated.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Ontario
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Starting from scratch is an understatement!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is that I had difficulty getting the Razor board to communicate through serial 0Rx/1Tx to the Arduino.
What I have now found out was:

1)   I am on the wrong page. Should have posted this probably in the sensors page.
2)   It was not clear to me at the time but RX0 and TX1 are used by the USB. So by using SoftwareSerial I am now getting something through to the Arduino from the Razor. Now I just need to make it make sense.
I should be getting this:  (Acquired through 3.3V FTDI basic board)

!,  AN:0,  0,  0,  X 9,  Y 5,  Z 241,  284,  -183,  -175
!,  AN:0,  0,  0,  X 10,  Y 4,  Z 240,  284,  -183,  -175
!,  AN:0,  0,  0,  X 11,  Y 3,  Z 242,  284,  -183,  -175
!,  AN:0,  0,  0,  X 13,  Y 3,  Z 240,  284,  -183,  -175

But I get this:

19

9

9

82

83

83

166

33

So now the question is how do I make it look correct?
Here is the code:

#include <SoftwareSerial.h>

// software serial #1: TX = digital pin 2, RX = digital pin 3
SoftwareSerial portOne(2, 3);

int stuff1;

void setup()
{
  // Start the hardware serial port
  Serial.begin(9600);
  // Start software serial port
  portOne.begin(9600);
}

void loop()
{
  if (portOne.available())
  {
    stuff1 = portOne.read();
    Serial.println (stuff1);
  }

}
Logged

Torino, Italy
Offline Offline
Sr. Member
****
Karma: 2
Posts: 309
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

are both the boards communicating at the same speed?

shouldn't you declare stuff1 as char?
Code:
char stuff1;

With your code, each incoming character will be implicitly casted into an integer, having value of the ASCII value of the incoming character.
Logged

Ontario
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Starting from scratch is an understatement!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got it working now to the point where it sees the output properly. Its just a bit out of alignment.


#include <SoftwareSerial.h>

SoftwareSerial portOne(2, 3);  // software serial #1: TX = digital pin 2, RX = digital pin 3

String stuff1="";  //  string to hold input

void setup()
{
  Serial.begin(9600);  // Start the hardware serial port
  portOne.begin(9600);  // Start software serial port
}

void loop()
{
  if (portOne.available()>0)  // Read serial input
  {
    int inChar = portOne.read();   
    if(isDigit(inChar));  //convert byte to char and add to string
    {
      stuff1 += (char)inChar;
    }
      if (inChar == '\n')  // if you get a new line print string then the value
    {
      Serial.println (stuff1.toInt());
     // Serial.print ("String: ");
      Serial.println (stuff1);
      stuff1 = "";   // clear string for new input
    }
  }
}



Thanks
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

When posting code, PLEASE, wrap it in "code" tags.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49365
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
int inChar
as opposed to
char inInt?
Logged

Pages: [1]   Go Up
Jump to: