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.
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
I took a look at your RobotC code and had a few points I wanted to clarify:
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
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
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.
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?
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.