To get an accurate trajectory on the ball, I wanna preset the RPMs on the shooting motor. I know you can just put in integer values like 1 for the motor speed, but what do these numbers mean? 1 meaning 1000 RPM?
The output 0-1 is just a power value, 0 being stopped 1 being full power. To do RPM control you need some type of feedback, like an encoder.
The numbers -1 to 1 only refer to the battery voltage as it is at the moment.
It won’t give you a specific RPM and will vary as you syphon power off to other motors (like your drivetrain), and as your battery gradually depletes itself during a match.
To get a consistent RPM you will need a feedback sensor and what’s called a PID software loop to maintain a set RPM.
For feedback you can use an encoder (some come in the Kit of Parts), or a light sensor that counts the passing of a marker on your spinning shooter wheel, or various other types of measuring sensors/devices.
If you are using CAN with Jaguars, then you can easily set speeds using their built-in control feedback loop system and plugging your encoder into your Jaguar. For Java, see the CANJaguar javadocs, and note the “control mode” variable, which you can set to kSpeed, setPID(), and set() method. You will have to tell it how many encoder codes your encoder will report per revolution as well.
If you want to see an example of making your own feedback loops for Victors, you can check out a (Java) class we wrote last year to do this here.
Have you successfully done this?
Here is a picture of periodic task that we have run on our test platform. It seems to perform quite well for maintaining desired RPM. YMMV.
The simple explanation is that we are using this like the “I” function in PID. This runs 100 times per second.
The 250 multiplier/divisor is found by reading your maximum rate count without feedback at full speed.
Okay I have never programmed an encoder before and I’m confused by the begin vi. Can someone please post a sample code for an encoder to set the desired RPMs? Thanks
With a drivetrain too? Or just a free-spinning wheel?
Our plan is to use the kit encoders direct-mounted to our flywheel shafts. Does anyone know if the manufacturer claim of up to 10,000 rpm is accurate? We’d rather not add the weight, complexity, and inefficiency of having to gear down an idler for the encoder to take rates.
Just the wheel
Define “success.” We did it on our drivetrain last year, with each wheel being controlled separately, and tuned the values using BDC-COMM. Were we able to control the speed of the wheels comfortably? Yes. But we faced typical Jaguar reliability issues that led us to replace them with Victors + homebrewed speed control code.
In this context, I guess I meant:
did you measure the actual steady-state output speed and confirm that it was indeed equal to the speed you were commanding?
was it stable?
was the dynamic response “good”? (I know, define “good”. How about a rough estimate of step response compared to voltage mode or %Vbus mode)
for a given speed command, did the controller hold the same output speed under different loads?
The reason I ask is that if you were successful, the folks at this thread would like to hear about it:
You can use a PID Controller and use RPM as the unit.
Your post is shown in the “threaded display mode” as being a response to my post#14. Was that intentional or inadvertent?
Heck, with CAN now fully going and err… reliable?.. you can use the Jaguar’s Speed interface to control RPM.
It’s legal this year, and it takes some of the overhead out of the programming, as well as making it respond better.
Just an idea.
I think Team Fusion is going this route.
Unintentional; I just use the “quick reply” button, so I just click the closest one.
Friendly suggestion: You might want to rethink that habit. Without any context in your post, the only clue regarding what you are responding to is the hierarchy in the threaded display mode.