Best Velocity Flywheel Control

Hello,

I have a dual flywheel and I have tried RobotC’s in-built PID only. I eventually took it off because it just made it worse, so as of now it is not using any velocity control. I’m trying to figure out the best velocity control. I’m trying to figure out how I can get it to launch at least 2 balls per second if not faster and still have around a 95% accuracy rate. It currently does 1 ball in a little over 1 second and scores in average, 27 or 28 out of 32.

Any advice is appreciated.

full court

thx, but when I tried PID, it didn’t work too well.

Could it be because I didn’t tune it. If so, how do you tune RobotC’s inbuilt PID feature? Where can you adjust the constants?

What do you mean by “slop in your gears”

so I’m understanding that you mean that one problem could be that when the first gear turns, the flywheel wont turn because it is too stiff. I have tested that many times and that doesn’t seem to be a problem. It spins smoothly; both the wheel and the gears.

ok got it

so is there a way to prevent this slop, or at least accommodate for it in the PID?

ok

ok, that’s a good idea

but are quad encoders able to function at such high speeds? Isnt there a maximum speed that they can accurately read, or is that not a problem

so it should be fine then. Ok thx. I will test this out and post my results in a few days.

sure thx

I would recommend that you take a look the Take Back Half (TBH) algorithm. It is a new velocity controller to VEX this year (at least most of us) and it is very effective once it is tuned. The difference in TBH and PID is that TBH only has one constant to tune rather than three like PID. This makes it a lot faster to tune. TBH is essentially an I controller although it acts more as a P controller with an overshoot control. If you have any questions, don’t hesitate to ask. :slight_smile:

Thanks

Could you please explain in further detail what TBH is and what it stands for so I understand how it works. I honestly have no idea about what it does or how to program it.

I have another question. Does TBH increase the firing rate, the accuracy, or both?

Take a look at this thread.
https://vexforum.com/t/team-929w-early-season-robot-reveal/29823/1

It should increase both.

If you have any questions after taking a look at the link and a few other TBH threads, I’ll be happy to help. I can also help walk you through how to write your own TBH program if you still need help, just PM me. :slight_smile:

thank you

I have tested the PID again and it actually has increased the firing rate by a lot. Our accuracy has improved a lot too. However, these were with the default values in the RobotC PID program. (I am still trying to fully understand how to create my own PID). Whenever I try to tune the values, the wheels just stop working. If I restore the “default values”, it then starts working again. Though it works, it ddoes have a little oscillation. I appreciate any advice on how to fix this.

I actually have never used the built-in PID on the flywheel before. How is it? I tried using it once, and it wrecked my internal motor gears as the motors span in the opposite direction to compensate for overshooting. What was your accuracy and fire rate before and after using built-in PID? I had tried using my own PID loop, but due to how long it took to tune, I strayed away from it and went back to TBH.

It is actually very effective. It has sped up our launching rate to about .5 sec per ball and has made it very accurate. I haven’t yet done a test run with all 24 preloads available in a match and seen its accuracy, but from what I have done, its accuracy is around 95%. Before the PID, the launching speed was around 2 secs per ball. Before the PID, the flywheels acted very weird, and they missed around 7-8 out of 24.

To avoid destroying your motor gears, try putting an output restriction on the PID loop so it can’t spin the motors the wrong way. You could also add a ratchet which would further reduce the risk of motor damage.

The way you’re describing it, it sounds like your P constant is very high or you need to increase I. I did an initial tune of our flywheel yesterday using this method, and it’s working really well.

To change the constants, you need the Super User menu level enabled in ROBOTC (Window > Menu Level). Now, if you go to Motors and Sensors Setup, you’ll see a new tab called PID Settings. In that tab, you’ll see a section called PID Settings for Motors in This Single Program. This should list all the motors that have PID enabled. If you double-click an entry, you’ll be able to change the constants and a few other values. Then, tune the loop using this method (I think it works well).

The oscillation you have probably means that your P constant is too high, or I might be too low. The default constants for PID in ROBOTC are pretty high, so lower values should be better.