I have to do this remote car project that has both a speed PID and a traction PID.
I have tachometers connected to the front wheel and the rear wheel, and I'm getting the angular velocity of both (can calculate linear velocity too).
Right now I'm trying to do the traction control. The professor made a c++ simulator with as close as possible parameters from the car, so we can simulate the PID before we implement it in hardware. The car goes really fast, using a 20k RPM motor, so straight hardware testing isn't the smartest thing to do. Theoretically it can reach 93km/h.
I'm having a hard time figuring out how to do the PID though. With his model, he's basing the mu on a wet environment. Ideal slip ratio is 0.2. I'm trying to get something out with the P then I'll later on tune the I and the D.
In his uncontrolled model, he gave the car a step input in voltage (12v). For the PID, this is what I have.
kp = 5.0;
slip_ratio_desired = 0.2;
slip_ratio_actual = y[3]; // calculated slip ratio from readings
e = slip_ratio_desired - slip_ratio_actual;
voltage = kp*e; // this then goes to the car
if(voltage>12) voltage = 12;
if(voltage< 0 ) voltage = 0;
This isn't getting me actual results. I'm getting both the front wheel and the rear wheel at the same speed which is a good thing, but the slip ratio goes down to almost zero. Around 0.01 or 0.02 for some reason. Also, I'm not using his initial step input anywhere in my PID, I'm just over writing that value, I'm not sure how to connect that in my PID. What I'm noticing is that the higher I set the P value, the higher the final speed of the car is, until it gets capped by the 12 volts.
Here are some graphs from the simulator plotted with matlab for P = 5 and P = 50.