Fw code not working

Hi guys, I made a control loop for my flywheel but it isnt working. I think its something to do with my potentiometer not working? All it does is click and my control loop isnt working. Is my potentiometer not working correctly?

1 Like

posting the code will always help ppl identify your problem

1 Like

potentiometers have a limit of 270 degrees. if you force them past that they break. You should use either an encoder or the built-in encoders inside the motor.


Iā€™d recommend throwing that potentiometer out immediately to avoid confusion in the future, as it will not function properly after being over rotated.



Shaft Encoder


Potentiometers have a higher degree of precision but a limited degree of rotation. This makes them perfect for lifts and other systems which only require a limited degree of rotation. Encoders have unlimited degrees of rotation but less precision over potentiometers. As well as being bigger. They are much better suited for srives or flywheels which can spin continuously in a single direction.


My flywheel works perfectly fine with a potentiometer :wink:

I am kidding, potentiometers have a limit but the limit breaks easily. And if you surpass the limit too many times the potentiometer is doomed to break. I had to replace the cap bots potentiometer 2-3 times before realizing huh, I should probably add hard stops.

If you want to measure the speed of your flywheel, use an encoder, then do something like this:

int lastFlywheelPos = 0
int Velocity = 0

int flywheelPos = EncoderInDegrees;

Velocity = flywheelPos - lastFlywheelPos;

lastFlywheelPos = flywheelPos;