posted on Monday, April 14, 2008 1:30 AM |

I'm suffering a pretty wicked oscillation problem and I need to solve it.  What is happening is I need a rather large multiplier to get the skateboard to kick back up.  I realized I really didn't have any proper data logging built in so I just added in yet another text box on my diagnostic application.

image

Now with this data, I can do pretty graphs like this with Excel (yes this is the first time I've ever done a graph with excel:

image

Why care?  This allows me to possibly see how during the oscillation the major players are acting and see which is possibly causing the root of the cause and how to deal with it.

If anyone can see my flaw, please ping me.  My ProportionalMultiplier and DerivativeMultiplier are about 20 to get stuff to start working.  Stuff that is irrelevant was removed to keep the post short.

public void StartSelfBalancing()
{
    // checks and getting stuff setup, code removed for posting
    
    int leftMotorPower = 0;
    int rightMotorPower = 0;
    int speedOffset = 0;
    int turn = 0;

    double angle = 0;
    double motor = 0;

    while (IsUserOnSkateboard())
    {
        data = imu.GetImuData();

        double gyroDamped = dampenGyro(data.X_GyroCorrectedRadians);
        double Acceleration = data.X_AccelerationCorrectedRadians;

        angle = 0.9 * (angle + gyroDamped * (data.ChangeInTime.TotalSeconds))
            + 0.1 * (Acceleration + speedOffset);

        /* 'motor' is the base value of the motors, independent from turning speeds. */
        motor += dampenMotor(((ProportionalMultiplier * angle) -
                (DerivativeMultiplier * gyroDamped)));

        motor = verifyOverflow((int)motor, 512);

        //speedOffset = (int)(angle * .025); //0.025

        // gotta do this else turning won't work at max speed
        leftMotorPower = rightMotorPower = (int)motor;

        ///* Steering commented out for inital balance testing
        /* Factor in steering with motors*/
        leftMotorPower = -leftMotorPower + turn;
        rightMotorPower = rightMotorPower + turn;

        leftMotorPower = verifyOverflow(leftMotorPower / 4,  127);
        rightMotorPower = verifyOverflow(rightMotorPower / 4, 127);

        motorController.SetMotorSpeed(Types.Enums.MotorChannel.A, leftMotorPower);
        motorController.SetMotorSpeed(Types.Enums.MotorChannel.B, rightMotorPower);

        UpdateUserInterface(data, Angles.RadiansToDegrees(angle), motor, turn, leftMotorPower, rightMotorPower);
    }
    // shut down motors and IMU removed for posting
}

And my big ass Pelican case, god how could I forget how to ship this mofo.  I need to rubber cement in the foam but everything fits.  I should add in a box to carry tools too I think.  I also need to add in a spot for the batteries that are actually in the body of the skateboard right now, I don't want any power on it during transportation.  14 days before I have to ship it out!  And I'll be in LA for 4 of those days for the Microsoft Imagine Cup US final supporting my region's SDI team, from University of Iowa!

My skateboard in foam padding

My skateboard in foam padding

My skateboard in foam padding

Tags [ Coding Video Silverlight ]

Your Comments.

No comments posted yet.

Post Comment
Title *
Name *
Email
Url
Comment *  
Please add 2 and 1 and type the answer here: