Pages: [1]   Go Down
Author Topic: Sparkfun 5DOF IMU w/ Ardunio  (Read 2781 times)
0 Members and 1 Guest are viewing this topic.
brooklyn
Offline Offline
Newbie
*
Karma: 0
Posts: 38
transpersonal
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello there,

I'm trying to build a motion controlled speech synthesiser. This will be part of a cyborg attachment on the body of a dancer - the idea is that as she moves her arms, she will trigger different vowel and consonant sounds, at different speeds, pitches, ect, generating a new language in real time.

I've got the Sparkfun 5DOF Analog Combo Board (http://www.sparkfun.com/products/9268) and an arduino duemilanova atMega 328. I've tried hooking up the sensor to arduino using the arduino code from here - http://www.glacialwanderer.com/hobbyrobotics/?p=261, more specifically this code here - http://www.starlino.com/imu_kalman_arduino.html

But the only data I'm seeing from the serial monitor, when hooked up, looks like this -

­­Þé× - FPS: 111.11
­ÞÓEî - FPS: 111.11
­Þ½CÒ   - FPS: 111.11
­Þ¦ ’ - FPS: 100.00
­Þ”\    - FPS: 111.11
­ÞŠ+ - FPS: 111.11
­Þƒ$.  - FPS: 111.11
­ÞlV' - FPS: 100.00
­Þbˆ& - FPS: 111.11
­ÞVDŽ# - FPS: 111.11
­ÞKXœ$ - FPS: 1

The data seems to react to motion (by increasing the distance between the unreadable characters and the FPS text, but it's unusable. What I need are some integers to trigger my speech synthesiser (a Speakjet). I've tried using the graphing code on the previous link, and it seems to be reacting to the sensors movement, but still is unusable to me.

There is this code - http://www.starlino.com/imu_kalman_arduino.html, in which he uses a program called Serial Chart to read the serial data in integers, but it's for PC. I have a mac. Has anyone used this board before with success? Any tips? I'm hoping I can get some analog data without too much trouble.

Any help appreciated, you guys are the best.
« Last Edit: February 25, 2011, 04:03:10 pm by john also » Logged

New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Post YOUR actual code.  Without that it's impossible to say why it isn't working the way you want it to.
Logged


New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, based on the output you posted, it appears you're using the code from the hobbyrobotics link you posted.

That code is writing the raw sensor data out the serial port, not human readable data.  Change your write()'s to print()'s and you'll be able to read the values from the Serial Monitor window.  Doing that will not work with the graphing app he also provides though.
Logged


brooklyn
Offline Offline
Newbie
*
Karma: 0
Posts: 38
transpersonal
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hmm, I changed them to serial.print() like you said, now i'm getting a lot of data that looks like this  -

57005335270375279245272 - FPS: 90.91
57005335276371279246273 - FPS: 90.91
57005336279360279251275 - FPS: 100.00
57005327278356279262280 - FPS: 90.91
57005318283367279270284 - FPS: 100.00
57005329301372279274284 - FPS: 90.91
57005333308380279272285 - FPS: 100.00
57005334299394279268283 - FPS: 90.91

where's my xaccel, yaccel, ect?


this is what my code looks like now -

Code:
// Maurice Ribble
// 6-28-2009
// http://www.glacialwanderer.com/hobbyrobotics

// This app just probes two external sensors (ADXL330 and IDG300) and
// then sends that data over a serial connection.  I used a sparkfun
// breakout board to make using these chips easier.
// http://www.sparkfun.com/commerce/product_info.php?products_id=741

// I wrote a processing.org app that reads in this data and graphs it
// on a pc.

#define X_ACCEL_APIN 0
#define Y_ACCEL_APIN 1
#define Z_ACCEL_APIN 2
#define V_REF_APIN   3
#define Y_RATE_APIN  4
#define X_RATE_APIN  5

void setup()
{
  Serial.begin(115200);
}

// If this is defined it prints out the FPS that we can send a
// complete set of data over the serial port.
#define CHECK_FPS

void loop()
{
  int xAccel=0, yAccel=0, zAccel=0, vRef=0, xRate=0, yRate=0;
  unsigned int startTag = 0xDEAD;  // Analog port maxes at 1023 so this is a safe termination value
  int loopCount;

#ifdef CHECK_FPS 
  unsigned long startTime, endTime;
  startTime = millis();
#endif
 
  // Can't do more than 64 loops or could overflow the 16 bit ints
  // This just averages together as many sensor reads as we can in
  // order to reduce sensor noise.  Might want to introduce add
  // a smarter filter her in the future.
  loopCount = 12;  // 12 gives a little over 100 FPS
  for(int i = 0; i< loopCount; ++i)
  {
    // It takes 100 us (0.0001 s) to read an analog input
    xAccel += analogRead(X_ACCEL_APIN);
    yAccel += analogRead(Y_ACCEL_APIN);
    zAccel += analogRead(Z_ACCEL_APIN);
    vRef   += analogRead(V_REF_APIN);
    xRate  += analogRead(X_RATE_APIN);
    yRate  += analogRead(Y_RATE_APIN);
  }
  xAccel /= loopCount;
  yAccel /= loopCount;
  zAccel /= loopCount;
  vRef   /= loopCount;
  xRate  /= loopCount;
  yRate  /= loopCount;

  Serial.print(startTag);
  Serial.print(xAccel);
  Serial.print(yAccel);
  Serial.print(zAccel);
  Serial.print(vRef);
  Serial.print(xRate);
  Serial.print(yRate);
 
#ifdef CHECK_FPS 
  endTime = millis();
  Serial.print(" - FPS: ");
  Serial.println(1.f / (endTime-startTime) * 1000);
#endif
}

Logged

brooklyn
Offline Offline
Newbie
*
Karma: 0
Posts: 38
transpersonal
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, those strings of numbers must just be strings of data un-separated by anything, of course. Thanks so much for the help. I'll be sure to post a video of this gesture-controlled language generator when it's finished.
Logged

brooklyn
Offline Offline
Newbie
*
Karma: 0
Posts: 38
transpersonal
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

new code, new problems...

so here is my new code, i'm now trying to control the speakjet based on readings from the 5DOF. but the program doesn't seem to send the right code to the speakjet. when the if function is triggered, it just resets the speakjet, instead of what i've got in the speakjet.serial command. is this something to do with having multiple serial communications at once? can i do 9600 w/ the speakjet and 115200 w/ the 5DOF? is there a special function for that?

Code:
#include <SoftwareSerial.h>
SoftwareSerial speakjet = SoftwareSerial(0, txPin); //serial communication for speakjet

#define RES  3 //pins for speakjet
#define txPin  2

#define X_ACCEL_APIN 0 //input pins for 5DOF
#define Y_ACCEL_APIN 1
#define Z_ACCEL_APIN 2
#define V_REF_APIN   3
#define Y_RATE_APIN  4
#define X_RATE_APIN  5

#define IY 128 // these are the command codes for different speakjet sounds
#define IH 129
#define EY 130
#define EH 131
#define AY 132
#define AX 133
#define UX 134
#define OH 135
#define AW 136
#define OW 137
#define UH 138
#define UW 139
#define MM 140
#define NE 141
#define NO 142
#define NGE 143
#define NGO 144
#define LE 145
#define LO 146
#define WW 147
#define RR 148
#define IYRR 149
#define EYRR 150
#define AXRR 151
#define AWRR 152
#define OWRR 153
#define EYIY 154
#define OHIY 155
#define OWIY 156
#define OHIH 157
#define IYEH 158
#define EHLL 159
#define IYUW 160
#define AXUW 161
#define IHWW 162
#define AYWW 163
#define OWWW 164
#define JH 165
#define VV 166
#define ZZ 167
#define Zh 168
#define DH 169
#define BE 170
#define BO 171
#define EB 172
#define OB 173
#define DE 174
#define DO 175
#define ED 176
#define OD 177
#define GE 178
#define GO 179
#define EG 180
#define OG 181
#define CH 182
#define HE 183
#define HO 184
#define WH 185
#define FF 186
#define SE 187
#define SO 188
#define SH 189
#define TH 190
#define TT 191
#define TU 192
#define TS 193
#define KE 194
#define KO 195
#define EK 196
#define OK 197
#define PE 198
#define PO 199
#define P0 0
#define P1 1
#define P2 2
#define P3 3
#define P4 4
#define P5 5
#define P6 6
#define FAST 7
#define SLOW 8
#define STR 14
#define RLX 15
#define PIT 22
#define SPD 21
#define VOL 20
#define BND 23
#define RST 31
#define REPEAT 26


void setup()

{ pinMode(txPin, OUTPUT);
 
 speakjet.begin(9600); //talk to speakjet

  // initialize serial communication:
  Serial.begin(9600);
  pinMode(RES, OUTPUT); //to get rid of "ready" sound

  digitalWrite(RES, LOW); //reset speakjet
  delay(100);
  digitalWrite(RES, HIGH);
  
  Serial.begin(115200); // serial comm for 5DOF
}

// If this is defined it prints out the FPS that we can send a
// complete set of data over the serial port.
#define CHECK_FPS

void loop()
{
  int xAccel=0, yAccel=0, zAccel=0, vRef=0, xRate=0, yRate=0;
  unsigned int startTag = 0xDEAD;  // Analog port maxes at 1023 so this is a safe termination value
  int loopCount;

#ifdef CHECK_FPS  
  unsigned long startTime, endTime;
  startTime = millis();
#endif
  
  // Can't do more than 64 loops or could overflow the 16 bit ints
  // This just averages together as many sensor reads as we can in
  // order to reduce sensor noise.  Might want to introduce add
  // a smarter filter her in the future.
 
 loopCount = 64;  // 12 gives a little over 100 FPS
  for(int i = 0; i< loopCount; ++i)
  {
    // It takes 100 us (0.0001 s) to read an analog input
    xAccel += analogRead(X_ACCEL_APIN);
    yAccel += analogRead(Y_ACCEL_APIN);
    zAccel += analogRead(Z_ACCEL_APIN);
    vRef   += analogRead(V_REF_APIN);
    xRate  += analogRead(X_RATE_APIN);
    yRate  += analogRead(Y_RATE_APIN);
  
}
  xAccel /= loopCount;
  yAccel /= loopCount;
  zAccel /= loopCount;
  vRef   /= loopCount;
  xRate  /= loopCount;
  yRate  /= loopCount;


  Serial.print("xAccel = "); //send 5DOF data to serial monitor
  Serial.print(xAccel);
  Serial.print(" yAccel = ");
  Serial.print(yAccel);
  Serial.print(" zAccel = ");
  Serial.print(zAccel);
  Serial.print(" vRef = ");
  Serial.print(vRef);
  Serial.print(" xRate = ");
  Serial.print(xRate);
  Serial.print(" yRate = ");
  Serial.print(yRate);
  
#ifdef CHECK_FPS  
  endTime = millis();
  Serial.print(" - FPS: ");
  Serial.println(1.f / (endTime-startTime) * 1000);
#endif

 (xAccel >= 400) speakjet.print(BYTE, OW); // send some syllables to speakjet if xAccell is over 400
                   speakjet.print(BYTE, AYWW);
                   speakjet.print(BYTE, AYWW);
                   speakjet.print(BYTE, OWWW);
                   speakjet.print(BYTE, IYUW);  
delay(200);

}

« Last Edit: February 25, 2011, 04:16:46 pm by john also » Logged

New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
(xAccel >= 400) speakjet.print(BYTE, OW); // send some syllables to speakjet if xAccell is over 400
                   speakjet.print(BYTE, AYWW);
                   speakjet.print(BYTE, AYWW);
                   speakjet.print(BYTE, OWWW);
                   speakjet.print(BYTE, IYUW); 
delay(200);



Was there a copy/paste error, or is that your actual code?  If it is, I'm thinking it should look like this instead:
Code:
    if(xAccel >= 400){
                   speakjet.print(BYTE, OW); // send some syllables to speakjet if xAccell is over 400
                   speakjet.print(BYTE, AYWW);
                   speakjet.print(BYTE, AYWW);
                   speakjet.print(BYTE, OWWW);
                   speakjet.print(BYTE, IYUW); 
     }
delay(200);

Logged


brooklyn
Offline Offline
Newbie
*
Karma: 0
Posts: 38
transpersonal
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

ah yes, that was a mistake in the code - but adding in those brackets didn't change anything.
Logged

Pages: [1]   Go Up
Jump to: