Quote:
Originally Posted by kamocat
I'm planning on wiring the encoder to both motors, and having the PID independent. Because both Jaguars are subject to the same conditions, I'm hoping I won't get significant integral windup. (Also, the integral is reset when the Jaguar output is "0")
|
Warning: I haven't tested this or tried to model it, but it should work in theory... Of course, the devil is in the details.
Try wrapping a control loop around the two control loops on the Jaguars to sync their voltages up. The pseudo code would be something like the following, and you can make it more complicated if the nieve implementation doesn't work. This is assuming that you are sampling the voltages of the two jaguars at the same time, and I'm not sure how much a difference in sample time between the two jaguars would effect things. Probably depends on how aggressive you are trying to sync the two.
Code:
v1 = jag1.getVoltage()
v2 = jag2.getVoltage()
error = (v1 - v2)
jag1.setX(goal - error * Kp)
jag2.setX(goal + error * Kp)
The basic idea is that you wrap a proportional loop around the two PID loops running on the jaguars in order to drive the voltage error between the two loops to 0. This should cause them to provide the same voltage to the two motors, and share the load nicely. It might also work if you try to drive the errors in the current that the two motors are drawing to 0, or something clever like that.