Issues with PID for Flywheel

Although smart motors have an embedded PID, sometimes it fluctures by quite a lot. Thus, we decided to build our own PID algorithm tuning Voltage for the Flywheel. We ran into some issues and hope someone here can shed some light.

(1) the Flywheel PID that tunes Voltage makes lots of noises.

I suspect this is because the input Voltage changes too quickly ( 10 ms) and by too much.
The internal PID of Smart Motor does not have this problem.

(2) The velocity returned from the smart motor changes too much
We meaure the velocity every 10ms. Sometime the velocity jumps from 270RPM to 410RPM within 10 ms. This does not sound reasonable as the acceleration is too high. Do you guys smooth the RPM measurement using some filters?

(3) Equilibrium voltage to maintain the speed
We estimate the input Voltage that is needed to maintain our Flywheel at the target speed. The flywheel is first accelerate to the target speed using 12 Voltage and then switch to the equilibrium voltage. It is suprising to me that after switching to the equilbrium voltage right at the target velocity the flywheel velocity drops suddently.

(4) One-side PID
At the normal stage, we keep the input voltage at the equilibrium voltage. If the flywheel slows down because of shooting a disc, the volatilty will be increased proptionally according to a P loop. If the Flywheel speed is above the target velocity, we don’t lower the input voltage. It kinds of like a Bang-Bang + PID. Any potential issue with this?

Any comments or suggestions are appreciated. Thanks!

Many different things can cause this including a bad PID loop that oscillates or friction but it’s likely due to the following points you make

This does happen and in my experience a filter is extremely necessary when using any PID based flywheel control. I used a SMA where you take the average of the past n number of points but there is also Sylib which has more advanced filters and flywheel control.

For points 3 and 4 I’m going to explain to you what a feedforward control is for PID. What you have is very close but no quite there. Feedforward uses your equilibrium voltage (the rough voltage needed to maintain the desired speed and adds it to PID. Basically, you add the equilibrium voltage to kp*error so the flywheel will correct it’s error and recover faster.

Using bang-bang upto a certain threshold is a popular way of speeding up the flywheel faster.


EcstaticPilot, thanks for the great points.

I also feel the function motor.velocity() does not return the speed accurately.

we implemented all the ideas, but it still does not work well. In particular, the second and third disk lose speed quickly, which means the PID recovers slowly. Below is our code. Any comment is appreciated. Thanks.

target_vol = Estimate_FlyWheel_Voltage(flywheel_speed)
speed = 0
flywheel.spin(REVERSE, 12, VOLT)
while speed < flywheel_speed*0.99:
    wait(10, MSEC)    
    speed = math.fabs(flywheel.velocity(RPM))

flywheel.spin(REVERSE, target_vol, VOLT) #Mainain the target velocity
init_pistol_pos = pistol.position(DEGREES)
alpha = 0.5
real_speed = speed 

while True:
    if math.fabs(pistol.position()-init_pistol_pos) > disks*360-1:
    wait(10, MSEC)
    speed = math.fabs(flywheel.velocity(RPM))
    real_speed = real_speed*(1-alpha) + speed*alpha
    vol = max(min(target_vol + (flywheel_speed-real_speed)*kp,12.0),0.0) 
    flywheel.spin(REVERSE,vol, VOLT)


This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.