![]() |
|
||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
![]() ![]() ![]() ![]() |
[Projects] SWIBR - Progress!
Ok, so my mouser and sparkfun orders came in! Got a lot of nice stuff. I started assembling the whole thing now although I'm still waiting on the geartrain to come in from Canadia. I assembled the H-bridge and it works great! Blue and Yellow LEDs show the output signal. I soldered up the gyro and accelerometer to their own breakout boards. Not too fun considering the pads are 0.5mm. But it can be done! Plus doing it myself saved me like $30 that SparkFun charges for their design. I have the basic code for the uC written for controlling the PITCH axis only. It uses 1D Kalman filtering and a PID Control loop. I won't be able to tune it until the robot is built but it's a good start. I based my code on the Kalman code published by Tom @ http://tom.pycke.be. The PID loop was written using Wikipedia as a reference.
#define GYRO_PITCH 0
#define ACEL_X 2
#define ACEL_Z 3
#define FILTERAMT 10
struct Gyro1DKalman
{
float x_angle,x_bias;
float P_00,P_01,P_10,P_11;
float Q_angle, Q_gyro;
float R_angle;
} filterPitch;
float deltaTime, startTime, lastTime;
int gyro_vals[FILTERAMT];
int acelx_vals[FILTERAMT];
int acelz_vals[FILTERAMT];
int filterIndex = 0;
float GYRO_PITCH_NEUTRAL = 773;
float ACEL_X_NEUTRAL = 544;
float ACEL_Z_NEUTRAL = 553;
float calGyroPitch = 0, calAccelX = 0;
float calCount = 0;
float lastAngle = 0.0;
float P = 0.0;
float I = 0.0;
float D = 0.0;
// Initializing the struct
void init_Gyro1DKalman(struct Gyro1DKalman *filterdata, float Q_angle, float Q_gyro, float R_angle)
{
filterdata->Q_angle = Q_angle;
filterdata->Q_gyro = Q_gyro;
filterdata->R_angle = R_angle;
}
// Kalman predict
void ars_predict(struct Gyro1DKalman *filterdata, const float dotAngle, const float dt)
{
filterdata->x_angle += dt * (dotAngle - filterdata->x_bias);
filterdata->P_00 += - dt * (filterdata->P_10 + filterdata->P_01) + filterdata->Q_angle * dt;
filterdata->P_01 += - dt * filterdata->P_11;
filterdata->P_10 += - dt * filterdata->P_11;
filterdata->P_11 += + filterdata->Q_gyro * dt;
}
// Kalman update
float ars_update(struct Gyro1DKalman *filterdata, const float angle_m)
{
const float y = angle_m - filterdata->x_angle;
const float S = filterdata->P_00 + filterdata->R_angle;
const float K_0 = filterdata->P_00 / S;
const float K_1 = filterdata->P_10 / S;
filterdata->x_angle += K_0 * y;
filterdata->x_bias += K_1 * y;
filterdata->P_00 -= K_0 * filterdata->P_00;
filterdata->P_01 -= K_0 * filterdata->P_01;
filterdata->P_10 -= K_1 * filterdata->P_00;
filterdata->P_11 -= K_1 * filterdata->P_01;
return filterdata->x_angle;
}
void setup()
{
analogReference(EXTERNAL);
Serial.begin(9600);
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
for(int i=0;iAnd here is a quick video of the controller in action! Posted on 2009-10-22 @ 21:31
[Projects] SWIBR - Parts ordered!
Soooo I placed the initial orders (and hopefully final ones) for the parts I think I'll need for SWIBR. Well, at least the ones I will buy on the interwebs. Parts purchased for the bot so far: Mouser:
SparkFun:
Solarbotics:
So aside from all the other stuff I bought along with these purchases, and the materials I will need from local places (metal, etc), also excluding current components I have, I'm up to $42.18 so far. Not too bad. Posted on 2009-10-18 @ 16:47
[Projects] Iron Man - Update #8, More Negatives!
[Projects] Iron Man - Update #7, Negatives
[Projects] Iron Man - Update #6 (Video!)
Latest update on the helmet, this time with a video... Posted on 2009-10-10 @ 19:00
|
||||||||||||||||||||||||||||||||||||||||||||||||||