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.
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