1. 3 weeks ago

    I’m using c++ pro and I’m trying to make an open loop motor control. I got the sub class that jpearman made and my pid was not working. When I went to debug the problem and I print the value of the motor encoder on the brain screen and it was zero the whole time after moving the wheel it was connected to. It was working before the sub class I added from jpearman with the regular motor class. So I don’t really know how to fix the problem.

  2. jpearman

    Dec 29 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888

    Post a simple example that demonstrates the problem and I will have a look.

  3. Here is my program file. Sorry if it is messy or weird.

  4. Jpearman, also I was printing the values of my front left motor and it was zero. So it might be something I did wrong with the sub class or something I did in my cpp.

  5. jpearman

    Dec 29 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888
    Edited 3 weeks ago by jpearman

    well, this has an issue

    while(true)
        {
        Brain.Screen.print(Frontleft.rotation(rotationUnits::rev) * 10000);
        }

    as it will print off the end of the screen, add a setCursor call

    while(true)
        {
        Brain.Screen.setCursor(1,1);
        Brain.Screen.print(Frontleft.rotation(rotationUnits::rev) * 10000);
        }

    also, why multiply by 10000 ?
    otherwise when I move the FrontLeft motor I see the rotation change.

  6. That was to test the rotation and I was trying to get the revolution to be able to be multiplied by the kP because I needed a value higher then 12000 for mili-volts.

  7. I'll try your idea

  8. It worked, however when I ran it with wheels moving forward it showed 0 the whole time.

  9. I moved the set cursor and brain.print to the pid right after the speed is set.

  10. callen

    Dec 29 Braintree, MA, USA
    Edited 3 weeks ago by callen

    It's here:

    SetSpeed(Drv.speed);
    Brain.Screen.print(Frontleft.rotation(rotationUnits::rev) * 10000);

    and here:

    void SetSpeed(int power)
    {
        EncoderReset();

    You keep reseting the encoder right before printing.

  11. Thanks. I didn't see that.

 

or Sign Up to reply!