For memory we are planning to use the Spark Fun Logomatic V2 SD logger. This will work correct?
The other issue of concern is that I integrated my code with my coding for servos and they seem to glitch even with all the print statements removed but the command byte one (d). I tried to switch the transmit and receive off of serial (0,1) and use another digital set on the Duemilanove (6,7) but I have had no luck. Any suggestions as to where I am going wrong? It compiles but I dont receive relevant data. Thanks
[#include <NewSoftSerial.h>
int RXpin = 6;
int TXpin = 7;
NewSoftSerial IMU = NewSoftSerial(RXpin,TXpin);
typedef unsigned char byte;
byte incomingByte = 0; // for incoming serial data
byte incomingByte1 = 0; // for incoming serial data
byte incomingByte2 = 0; // for incoming serial data
byte incomingByte3 = 0; // for incoming serial data
byte incomingByte4 = 0; // for incoming serial data
int EulerX = 0;
int EulerY = 0;
int EulerZ = 0;
int i;
int t = 0;
int servo1 = 4;
int servo2 = 2;
int pulseWidth1;
int pulseWidth2;
void servoPulse1 (int servo1, int EulerX) {
pulseWidth1 = ((EulerX * 10.9) + 1500); // Converts angle to microseconds
digitalWrite(servo1, HIGH); // Set servo high (turns it on)
delayMicroseconds(pulseWidth1); // Wait a very very small amount
digitalWrite(servo1, LOW); // Set servo low (turns it off)
//delay(20); // Typical Refresh cycle of servo (20 ms)
//Serial.println (pulseWidth1, DEC);
}
void servoPulse2 (int servo2, int EulerY) {
pulseWidth2 = ((EulerY * 10.9) + 1500); // Converts angle to microseconds
digitalWrite(servo2, HIGH); // Set servo high (turns it on)
delayMicroseconds(pulseWidth2); // Wait a very very small amount
digitalWrite(servo2, LOW); // Set servo low (turns it off)
//delay(20); // Typical Refresh cycle of servo (20 ms)
//Serial.println (pulseWidth2, DEC);
}
float Convert754(byte bits25_32, byte bits17_24, byte bits9_16, byte bits1_8);
char d;
float Convert754(byte bits25_32, byte bits17_24, byte bits9_16, byte bits1_8)
{
unsigned char bytes[4];
float floatval;
bytes[3] = bits25_32;
bytes[2] = bits17_24;
bytes[1] = bits9_16;
bytes[0] = bits1_8;
floatval = (float)bytes;
return floatval;
}
void setup()
{
pinMode(servo1, OUTPUT);
pinMode(servo2, OUTPUT);
pinMode(6, INPUT);
pinMode(7, OUTPUT);
// set the data rate for the SoftwareSerial port
}
void loop() {
Serial.begin(115200);
IMU.begin(115200);
delay (10);
d = 206; // DEC for 0xCE (Euler Angle) change for desired output see Microstrain Protocal
IMU.print(d);
Serial.println (d, DEC);
delay(810);
if (IMU.available() >= 0){
for (i=0; i<1; i++) {// read the incoming byte:
incomingByte = IMU.read();
Serial.print("\n\nHeader: ");
Serial.println(incomingByte, DEC);
}
Serial.print("\n");
for (i=1; i<5; i++) {
if (i==1) { incomingByte1 = IMU.read(); }
if (i==2) { incomingByte2 = IMU.read(); }
if (i==3) { incomingByte3 = IMU.read(); }
if (i==4) { incomingByte4 = IMU.read(); }
}
Serial.print("Euler Angle About X: ");
EulerX = (float)( Convert754(incomingByte1, incomingByte2, incomingByte3, incomingByte4)*180/3.14);
Serial.print(EulerX, DEC);
Serial.print("\n");
for (i=5; i<9; i++) {
if (i==5) { incomingByte1 = IMU.read(); }
if (i==6) { incomingByte2 = IMU.read(); }
if (i==7) { incomingByte3 = IMU.read(); }
if (i==8) { incomingByte4 = IMU.read(); }
}
Serial.print("Euler Angle About Y: ");
EulerY = (float)( Convert754(incomingByte1, incomingByte2, incomingByte3, incomingByte4)*180/3.14);
Serial.print(EulerY, DEC);
Serial.print("\n");
for (i=9; i<13; i++) {
if (i==9) { incomingByte1 = IMU.read(); }
if (i==10) { incomingByte2 = IMU.read(); }
if (i==11) { incomingByte3 = IMU.read(); }
if (i==12) { incomingByte4 = IMU.read(); }
}
Serial.print("Euler Angle About Z: ");
EulerZ = (float)( Convert754(incomingByte1, incomingByte2, incomingByte3, incomingByte4)*180/3.14);
Serial.print(EulerZ, DEC);
Serial.print("\n");
IMU.flush();
}
delay (10);
servoPulse1(servo1, EulerX);
servoPulse2(servo2, EulerY);
}
][/code]