|
Thread scheduler for PID period control ?
We are trying to optimize our custom PID loop and appear to be getting conflicting data that I am hoping someone can clarify.
1) From numerous CD threads, I believe that the standard teleopPeriodic time is initiated from the drivers station at approximately a 20ms rate. However, at least two threads mention a 50ms periodic rate (older IFI rate?).
2) I have seen several threads which recommend using a separate thread based on the OS scheduler for tighter tolerance. Team 358 "Timing is Everything" white paper is an excellent reference. 10ms seems like a common period for PID.
3) The PID_control class does use the scheduler to create its own thread. I thought I saw on CD the default period was 20ms, but the Java Docs say it is 50ms.
So now here is our confusion.
4) We set up a timed PID thread with period 10ms. We set up a delta time measurement in both the teleop periodic and timed PID loops and plotted the delta times. The timed loop was 20ms +/- 4ms and the periodic was closer to 50ms +20/-10ms. Setting the period to 20ms gave about the same response.
This was done using Java on the older 8 slot cRIO on our test chassis. We do not yet have access to the production 4 slot cRIO. I can believe the old cRIO cant do the 10ms period but that does not explain the 50ms for the drivers station. I have not hooked up a scope to a DSC pin to confirm that the time reported by the OS is accurate.
The timing is clearly faster and more consistent with the timed loop, but I hate unexplained behaviors.
Does anyone know if the periods on the older cRIO were different and if the driver station software adapts? Is the delta time reported by the OS accurate? What period are people using for PID loops?
|