Thursday, December 15, 2011

Update: fail-Way v0.1

Hey look, an update. This is promising.

I've since tracked the problem with my Arduino to a fried diode (I'm assuming I tried to pull too much current through it) which I have since replaced with a piece of wire (since I can't readily buy a replacement). I just have to remember not to apply external power while connected to the computer.

The hardware is essentially the same. I just tried to use less rubber bands on everything (and instead went with electrical tape...)



With a working Arduino again I've continued my quest to make this thing balance. The first thing I did was try to optimize the code by removing all calculations not related to the roll axis (the one I'm using for my robot). I also added a line to convert gyro_roll readings from degrees/second to radians/second. It seems to react faster with radians, so I'll deal with those. It also fixed the problem I was having the the PD control code. Here is the most recent iteration:

Out1Raw += (int) rollCF * KP + rollR * KD;
Out1Srv = map(Out1Raw, -120, 120, 27, 163);
Serial.println(Out1Srv);
motor1.write(Out1Srv);

Lines:
1: PD control code from Shane Colton's SegStick instructable, with my variables
2: the motor controllers I'm using accept servo signals, so I use the Servo library and map the output to controller's range (27-163)
3: debug purposes
4: output to the motor controllers

I still haven't gotten this thing to balance, but I'm closer. It either oscillates rapidly or responds too slowly, so I'm hoping I can fix that by tuning Kd and Kp. I also have some sensor drift problems that are probably related to the unstable nunchuck mounting.

[maybe I'll make this a weekly thing, who knows...]

No comments:

Post a Comment