Blue Rooster (QCC2) Easy C V5 PID Library

Hi everyone,

So I’ve been doing some volunteering at a local VEX robot camp we put on each summer for Middle/High Schoolers and I got a request to make the QCC2 PID Library available for use with EasyC. There is a header you include into EasyC to use it and there is some example code I wrote in EasyC V5 for it.

It is available on GitHub here.

I also updated the RobotC version to fix a bug that caused the slew rate parameter to not work as intended.

The updated RobotC version is available here along with our Gyro Library.

Hey Jason, cool to see you release this code. The turns QCC demonstrated at worlds were one of the best I’ve ever seen in Vex, and proved themselves in the finals :smiley:

I took a look at your RobotC code and had a few points I wanted to clarify:


float rate = gyroGetRate() - gyro.gyroOffset - gyro.rateOffset;

So I see you calibrated your gyroscope using gyroOffset, and rateOffset is correcting for drift. Shouldn’t rateOffset be a function of time? ie. gyro.rateOffset*time_since_calibration

It appears your gyroCalibrate function is more or less trying to detect a linear change-of-drift over some time (dT seems undefined as it’s just a loop without checking for time?). So I think it makes sense if, say it drifts upwards 1mV per second, calibrated at 1.700V, then after 10 seconds, your gyro would be at 1.710V, and your code execute it like this : 1.710 - 1.700 - 0.001 = 0.009. If you accounted for time, it would be 1.710 - 1.700 - 0.001*10sec = 0.000.

Am I thinking about this wrong or misunderstanding your code? Or is this a potential issue?

Regardless, good work, hope to see you competing next year :slight_smile:

Justin,

So the gyroOffset calibration and rateOffset calibration are the same thing: I just calibrate the gyro twice. It really is not necessary, just redundancy to let me sleep at night :slight_smile:

The Gyro sensor itself calculates angular rate of change, ie. degrees rotation per second, and is then output to a voltage proportional to that angular velocity. so dT is not needed to detect the rate of change, it already does it. Some people see the gyro as a sensor that detects rotation since that’s what the native sensor code in easyC/robotC is designed for. dT is only used and needed when an iteration of the function that adds to the angle is called. The gyroOffset value is the offset for the rate of change. I hope this explanation answers your questions.

As for competing in Nothing But Net, we’ll see what the future has in store for Blue Rooster.

Ohhhhh okay, I totally misunderstood what that variable did, that makes a lot more sense. Thanks!

Jason,
I clicked on the link for the EasyC code, but it goes to a page with an error on it. Can you repost or fix that somehow?
Thanks,
9791C

There was an extra quote affixed to the URL, this link works: GitHub - JMMcKinneyWPI/EasyCPIDLibrary

Sorry, I’m new to PID programming. I was looking through the code and I didn’t see any motor output. Do I have to set that myself or am I missing something?

To be honest, I’ve never even touched EasyC, but it would look as if the ‘filteredOutput’ function would return a motor value.

Yeah I got that, I was just making sure that certain motors were not already set to that speed.

The function pidExecute returns a float which is the value that you are looking for. I don’t have EasyC to look at the code in at this second but you should have access to that function whether you are using the graphical or text-based implementations.

Oh OK. Where do I Initialize my IME?