Shooter Motor Stopping Problems

I am a newish programmer and I am trying to create a program that can keep out shooter motors at a constant RPM. We want this s,o when we are shooting multiple balls at once the RPM’s of our motors will not lower causing shooter inconsistencies. I guess I was wonder if there was an easier way to do this. I have attempted PID’s but was unsuccessful. Also the program will not stop. When I press the start button the shooter runs but when I release the button it dose not stop.

If you want to post your code we can help you debug the problem.

What kind of feedback do you have on the shooter, e.g., encoder, light sensor, etc.)?

What kind of motor controller is powering it?
What kind of motor?
Is the motor geared for 50% power, or are you expecting to run it flat out or direct drive?

We are using encoders and are using victor’s to power our Motors. In my code i am powering at around 75%

Also there should be a link to a google docs in my first question that has the code on it. you should just be able to click on it


Edit: You’re going to have to post what’s in the various other cases, or we’re not going to make a lot of sense of your code. And spread things out a bit inside some of those. It’s impossible to see where all the wires are going.

Edit2: Okay, at the very least, your problem is the while loops. Once you enter that bigger while loop, it’s going to run forever, and the joystick code outside it will never run again. So it’s never going to get updated values for the joystick buttons. The joystick read commands need to be inside that while loop for it to work. I think the inner one is probably a bad idea as well, it’s going to keep running forever, and the bigger while loop will never run a new iteration till the smaller one finishes.

Do You think that Trying to figure out PID’s would be a better option. If so how would i go about doing it because i was using some of the sample code and was not working quite right. when we ran at low rpm’s it freaked out but was somewhat stable at high RPM’s

So do you think that PID’s are a better option. Or maybe something ells. What ells could we use.

Can’t even see that your link in the first post even exists, thanks for the re-link Kevin.
It doesn’t appear to be a usable snippet after it’s gone though google docs.

Some things to add to what Kevin has already pointed out:

It looks like you have this in
You cannot have any loops in
Teleop needs to execute and be gone every 20ms.
Code like this belongs in Periodic instead.

The loops you have are unthrottled.
They need a bit of time delay or they will drain all the life out of your roboRIO.

PID is a good option if you can figure it out. I wish you were using Talon SRX controllers on your shooter, because you can tune and test that through the roboRIO web interface, but c’est la vie.

If you can’t figure out PID, you could try adapting the bang-bang control in this whitepaper:
It’s from a few years ago, so some of the VIs are likely wrong, but it shouldn’t be too hard to make it work.

Here’s an example of a simplistic bang-bang shooter using just one channel of the encoder you already have.
It can give you an idea of how it works before filtering.
Average RPM will be a bit higher than your target RPM depending on the mass of your shooting wheel (heavier wheel=better performance), but most people are picking target RPMs arbitrarily anyway-as long as the value remains consistent.

This can add PID in place of the 0 or 1 to give smoother performance at the cost of a slower return to the target RPM.

The Wait time delay is what I was talking about throttling loops so they don’t suck up all roboRIO CPU resources.

So i could plug in my encoder to where the counter is? or use the counter i guess i don’t know what it does. Sorry i’m kind of new at this so i don’t understand a lot of things.

Just comment out the Encoder and use the same DIO input as one of the Encoder channels A or B. You can’t Open two things on the same DIO input.

A counter just counts encoder ticks from one channel. It doesn’t care about the direction you get from comparing Encoder A & B channels.

You can configure your encoder as a counter.

If you enter Mark’s simple bang-bang example into LabVIEW, you’ll be able to click on the icons you don’t understand (like the counter) and you’ll get pop-up help explaining what they do.

If you use a bang-bang controller make sure you have your motor controller set for coast mode, not brake mode.

How far away from your team is the closest FRC team? If you reach out them they likely would be willing to help get you on the right path.

Ok I understand now. Thanks i have been trying to figure out this shooter problem for a long time. Ill try that and see how it works.