Encoder rotation is 0


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.


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


Here is my program file. Sorry if it is messy or weird.
DriveCodeANd 6 point blue.vex (15 KB)


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.


well, this has an issue

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

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

    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.


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.


I’ll try your idea


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


I moved the set cursor and brain.print to the pid right after the speed is set.
DriveCodeANd 6 point blue.vex (15 KB)


It’s here:

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

and here:

void SetSpeed(int power)

You keep reseting the encoder right before printing.


Thanks. I didn’t see that.