Thank you for your replies
@crossroads I know I am chewing off more than I can bite but I have already tried and successfully varied the speed of a dc motor using a potentiometer and the arduino.
@dafid Thanks for the procedure. I managed to read the inputs using the code given here
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1284738418
********** sketch ******************
// Main module K_bot angles in Quids, 10 bit ADC -------------
// 4 - Checking sensor data format display raw sensors data
#include <math.h>
#define GYR_Z 2 // Gyro Z (IMU pin #7)
#define ACC_X 0 // Acc X (IMU pin #1)
#define ACC_Y 1 // Acc Y (IMU pin #2)
int STD_LOOP_TIME = 9;
int sensorValue[3] = { 0, 0, 0};
int sensorZero[3] = { 0, 0, 0};
int lastLoopTime = STD_LOOP_TIME;
int lastLoopUsefulTime = STD_LOOP_TIME;
unsigned long loopStartTime = 0;
void setup() {
analogReference(DEFAULT); // Aref 5V
Serial.begin(115200);
delay(100);
calibrateSensors();
}
void loop() {
// ********************* Sensor aquisition & filtering *******************
updateSensors();
// ********************* print Debug info *************************************
serialOut_raw();
// *********************** loop timing control **************************
lastLoopUsefulTime = millis()-loopStartTime;
if(lastLoopUsefulTime<STD_LOOP_TIME) delay(STD_LOOP_TIME-lastLoopUsefulTime);
lastLoopTime = millis() - loopStartTime;
loopStartTime = millis();
}
void serialOut_raw() {
static int skip=0;
if(skip++==40) {
skip = 0;
Serial.print("ACC_X:"); Serial.print(sensorValue[ACC_X]);
Serial.print(" ACC_Y:"); Serial.print(sensorValue[ACC_Y]);
Serial.print(" GYR_Z:"); Serial.println(sensorValue[GYR_Z]);
}
}
// Sensors Module ---------------------------------------------------------------------
void calibrateSensors() { // Set zero sensor values
long v;
for(int n=0; n<3; n++) {
v = 0;
for(int i=0; i<50; i++) v += readSensor(n);
sensorZero[n] = v/50;
}
sensorZero[ACC_X] -= 205;
}
void updateSensors() { // data acquisition
long v;
for(int n=0; n<3; n++) {
v = 0;
for(int i=0; i<5; i++) v += readSensor(n);
sensorValue[n] = v/5 - sensorZero[n];
}
}
int readSensor(int channel){
return (analogRead(channel));
}
However I am having a hard time trying to understand the output in the serial monitor.
when X points upwards, Y points to the left and Z goes into the plane.
I get the following serial monitor output.
ACC_X:204 ACC_Y:0 GYR_Z:119
ACC_X:205 ACC_Y:0 GYR_Z:126
ACC_X:205 ACC_Y:0 GYR_Z:122
ACC_X:205 ACC_Y:0 GYR_Z:119
ACC_X:204 ACC_Y:0 GYR_Z:121
ACC_X:205 ACC_Y:0 GYR_Z:115
ACC_X:205 ACC_Y:0 GYR_Z:122
ACC_X:205 ACC_Y:0 GYR_Z:120
ACC_X:205 ACC_Y:0 GYR_Z:120
ACC_X:205 ACC_Y:0 GYR_Z:122
ACC_X:205 ACC_Y:0 GYR_Z:127
ACC_X:204 ACC_Y:1 GYR_Z:118
ACC_X:205 ACC_Y:0 GYR_Z:125
ACC_X:205 ACC_Y:0 GYR_Z:132
ACC_X:205 ACC_Y:0 GYR_Z:123
ACC_X:204 ACC_Y:1 GYR_Z:113
ACC_X:204 ACC_Y:0 GYR_Z:123
ACC_X:205 ACC_Y:0 GYR_Z:123
ACC_X:205 ACC_Y:0 GYR_Z:117
ACC_X:205 ACC_Y:0 GYR_Z:121
ACC_X:205 ACC_Y:0 GYR_Z:126
ACC_X:205 ACC_Y:0 GYR_Z:120
ACC_X:204 ACC_Y:0 GYR_Z:118
ACC_X:204 ACC_Y:0 GYR_Z:122
ACC_X:204 ACC_Y:0 GYR_Z:121
ACC_X:205 ACC_Y:0 GYR_Z:125
sorry for such a long post. I could not figure out how to paste for forum.
Thanks a lot