|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
||||
|
||||
|
Re: Thread scheduler for PID period control ?
The TeleOp period is 20ms (50Hz). The default period for Java PID thread is 50ms (or at least it was in 2013). Excerpt from 2013 PIDcontroller.java: Code:
/**
* Class implements a PID Control Loop.
*
* Creates a separate thread which reads the given PIDSource and takes
* care of the integral calculations, as well as writing the given
* PIDOutput
*/
public class PIDController implements IUtility, LiveWindowSendable, Controller {
public static final double kDefaultPeriod = .05;
/**
* Allocate a PID object with the given constants for P, I, D, and F
* @param Kp the proportional coefficient
* @param Ki the integral coefficient
* @param Kd the derivative coefficient
* @param Kf the feed forward term
* @param source The PIDSource object that is used to get values
* @param output The PIDOutput object that is set to the output percentage
* @param period the loop time for doing calculations. This particularly effects calculations of the
* integral and differential terms. The default is 50ms.
*/
public PIDController(double Kp, double Ki, double Kd, double Kf,
PIDSource source, PIDOutput output,
double period) {
|
|
#3
|
||||
|
||||
|
Re: Thread scheduler for PID period control ?
Quote:
For example, did you do it like this: Code:
// begin thread new_time = get_time(); delta_time = new_time - previous_time; previous_time = new_time; . .// do stuff here . // end thread Code:
// begin thread start_time = get_time(); . .// do stuff here . delta_time = get_time() - begin_time; // end thread |
|
#4
|
||||||
|
||||||
|
Re: Thread scheduler for PID period control ?
Quote:
What computer did you run the DS on? Last edited by Joe Ross : 30-01-2014 at 12:50. |
|
#5
|
|||
|
|||
|
Re: Thread scheduler for PID period control ?
Quote:
Code:
// begin thread new_time = get_time(); delta_time = new_time - previous_time; previous_time = new_time; . .// do stuff here . // end thread |
|
#6
|
|||
|
|||
|
Re: Thread scheduler for PID period control ?
It was a windows 7 lenovo - not sure the exact model but not more than two years old and definitely not a netbook. We did this tethered, not on WiFi.
Last edited by gpetilli : 31-01-2014 at 14:38. |
|
#7
|
||||||
|
||||||
|
Re: Thread scheduler for PID period control ?
I just ran the following code:
Code:
double prevTime = 0;
public void teleopPeriodic() {
double time = Timer.getFPGATimestamp();
System.out.println(time-prevTime);
prevTime=time;
}
Code:
[cRIO] 0.014032000000000266 [cRIO] 0.020156000000000063 [cRIO] 0.02008299999999963 [cRIO] 0.019773999999998182 [cRIO] 0.019995999999999015 [cRIO] 0.020203999999999667 [cRIO] 0.01987100000000197 [cRIO] 0.020114999999996996 [cRIO] 0.02004800000000273 [cRIO] 0.02036799999999772 [cRIO] 0.019611000000004708 [cRIO] 0.019765999999997064 [cRIO] 0.019995999999999015 [cRIO] 0.019989000000002477 [cRIO] 0.02004999999999768 [cRIO] 0.019984999999998365 [cRIO] 0.0200450000000032 [cRIO] 0.019925000000000637 [cRIO] 0.019964999999999122 [cRIO] 0.020108999999997934 [cRIO] 0.020091000000000747 [cRIO] 0.019836000000005072 [cRIO] 0.019992999999999483 [cRIO] 0.02026199999999534 [cRIO] 0.019725000000001103 [cRIO] 0.019995999999999015 [cRIO] 0.020110000000002515 [cRIO] 0.019950999999998942 [cRIO] 0.019914999999997463 [cRIO] 0.020150000000001 [cRIO] 0.019964999999999122 [cRIO] 0.019953000000000998 [cRIO] 0.02007000000000403 [cRIO] 0.023333000000000936 [cRIO] 0.016567999999999472 [cRIO] 0.019990999999997427 [cRIO] 0.019987999999997896 [cRIO] 0.02036199999999866 [cRIO] 0.019624000000000308 [cRIO] 0.020121000000003164 [cRIO] 0.02003100000000302 [cRIO] 0.01989399999999364 [cRIO] 0.020100000000006446 [cRIO] 0.019787999999998362 [cRIO] 0.02019099999999696 [cRIO] 0.019915000000004568 [cRIO] 0.019970999999998185 [cRIO] 0.020511999999996533 [cRIO] 0.019507000000004382 [cRIO] 0.020938999999998487 [cRIO] 0.01930399999999821 [cRIO] 0.020080999999997573 [cRIO] 0.019986000000002946 [cRIO] 0.0199089999999984 [cRIO] 0.020019000000004894 [cRIO] 0.019859999999994216 [cRIO] 0.020032000000000494 [cRIO] 0.020005000000004713 [cRIO] 0.01986199999999627 [cRIO] 0.020163000000003706 [cRIO] 0.020060000000000855 [cRIO] 0.019814999999994143 [cRIO] 0.02012300000000522 [cRIO] 0.019915999999994938 [cRIO] 0.019857999999999265 [cRIO] 0.020221000000006484 [cRIO] 0.01981199999999461 [cRIO] 0.02013300000000129 [cRIO] 0.020065000000002442 [cRIO] 0.01982299999999526 [cRIO] 0.020184000000000424 [cRIO] 0.019892000000005794 [cRIO] 0.02009899999999476 [cRIO] 0.01988500000000215 [cRIO] 0.02012200000000064 [cRIO] 0.019989999999999952 [cRIO] 0.019863999999998327 [cRIO] 0.02014700000000147 [cRIO] 0.019995999999999015 [cRIO] 0.020175999999999306 [cRIO] 0.019838000000000022 [cRIO] 0.019888999999999157 [cRIO] 0.020115000000004102 [cRIO] 0.020016999999995733 [cRIO] 0.01998400000000089 [cRIO] 0.020042000000003668 [cRIO] 0.01999999999999602 [cRIO] 0.01975800000000305 [cRIO] 0.0200139999999962 [cRIO] 0.020180000000003417 [cRIO] 0.019850999999995622 [cRIO] 0.02010900000000504 [cRIO] 0.020080000000000098 [cRIO] 0.020117999999996528 [cRIO] 0.019851000000002728 [cRIO] 0.020186999999999955 [cRIO] 0.020111999999997465 [cRIO] 0.020330999999998767 [cRIO] 0.019290000000005136 [cRIO] 0.02057199999999426 [cRIO] 0.019626000000002364 [cRIO] 0.01993500000000381 [cRIO] 0.020097999999997285 [cRIO] 0.021600999999996873 [cRIO] 0.01841500000000451 [cRIO] 0.019878999999995983 [cRIO] 0.020146000000003994 [cRIO] 0.020054000000001793 [cRIO] 0.020954999999993618 [cRIO] 0.018789000000005274 [cRIO] 0.022835000000000605 [cRIO] 0.017481999999994002 [cRIO] 0.019851000000002728 [cRIO] 0.019829999999998904 [cRIO] 0.02016400000000118 [cRIO] 0.020018000000000313 [cRIO] 0.019930000000002224 [cRIO] 0.020049000000000206 [cRIO] 0.020051999999999737 [cRIO] 0.02079599999999715 [cRIO] 0.019050999999997487 [cRIO] 0.022271000000003482 [cRIO] 0.01766800000000046 [cRIO] 0.02002000000000237 [cRIO] 0.020178999999998837 [cRIO] 0.02001899999999779 [cRIO] 0.019908000000000925 [cRIO] 0.020046000000000674 [cRIO] 0.020044999999996094 [cRIO] 0.019980000000003884 [cRIO] 0.01983699999999544 [cRIO] 0.02458000000000027 [cRIO] 0.0157040000000066 [cRIO] 0.01980599999999555 [cRIO] 0.020093000000002803 [cRIO] 0.0201279999999997 [cRIO] 0.019898999999995226 [cRIO] 0.020168000000005293 [cRIO] 0.019810999999997136 [cRIO] 0.020003000000002658 [cRIO] 0.019991999999994903 [cRIO] 0.022979000000006522 [cRIO] 0.01685799999999915 [cRIO] 0.020008999999994614 [cRIO] 0.019876000000003557 [cRIO] 0.02014599999999689 [cRIO] 0.020217000000002372 [cRIO] 0.020510000000001583 [cRIO] 0.019436999999996374 [cRIO] 0.020022000000004425 [cRIO] 0.01999699999999649 [cRIO] 0.019826999999999373 [cRIO] 0.019909000000005506 [cRIO] 0.02016599999999613 [cRIO] 0.01995600000000053 [cRIO] 0.02026299999999992 [cRIO] 0.019973999999997716 [cRIO] 0.019733999999999696 [cRIO] 0.020008000000004245 [cRIO] 0.020130000000001758 [cRIO] 0.0199439999999953 [cRIO] 0.01991699999999952 [cRIO] 0.020014000000003307 [cRIO] 0.02026499999999487 [cRIO] 0.020091000000000747 [cRIO] 0.019711000000000922 [cRIO] 0.02048200000000122 [cRIO] 0.019823999999999842 [cRIO] 0.020276000000002625 [cRIO] 0.019548000000000343 [cRIO] 0.020054999999999268 [cRIO] 0.021468999999996186 [cRIO] 0.01859900000000181 [cRIO] 0.019700000000000273 [cRIO] 0.019939000000000817 [cRIO] 0.021791000000000338 [cRIO] 0.018093999999997834 [cRIO] 0.020206999999999198 [cRIO] 0.019817000000003304 [cRIO] 0.02050700000000205 [cRIO] 0.020139999999997826 [cRIO] 0.022245999999995547 [cRIO] 0.017315000000003522 [cRIO] 0.01983200000000096 [cRIO] 0.02001200000000125 [cRIO] 0.02009699999999981 [cRIO] 0.019945999999997355 [cRIO] 0.020163000000003706 [cRIO] 0.019883000000000095 [cRIO] 0.01994699999999483 [cRIO] 0.020003000000002658 [cRIO] 0.020181000000000893 [cRIO] 0.01998400000000089 [cRIO] 0.019994999999994434 [cRIO] 0.01981800000000078 [cRIO] 0.020724999999998772 [cRIO] 0.01940400000000153 [cRIO] 0.020572000000001367 [cRIO] 0.019492999999997096 [cRIO] 0.020011000000003776 [cRIO] 0.02001200000000125 [cRIO] 0.019867999999995334 [cRIO] 0.01991699999999952 [cRIO] 0.020219000000004428 [cRIO] 0.019978999999999303 [cRIO] 0.02002199999999732 [cRIO] 0.019750999999999408 [cRIO] 0.02012500000000017 [cRIO] 0.020092000000005328 [cRIO] 0.020537999999994838 [cRIO] 0.019495000000006257 [cRIO] 0.020107999999993353 [cRIO] 0.019899999999999807 [cRIO] 0.020124000000002695 [cRIO] 0.020169000000002768 [cRIO] 0.019700000000000273 [cRIO] 0.020637000000000683 [cRIO] 0.01944199999999796 [cRIO] 0.01986800000000244 [cRIO] 0.020131999999996708 [cRIO] 0.020014000000003307 [cRIO] 0.01990499999999429 [cRIO] 0.02029100000000028 [cRIO] 0.019598999999999478 [cRIO] 0.020002000000005182 [cRIO] 0.02232999999999663 [cRIO] 0.017898000000002412 [cRIO] 0.020381000000000427 [cRIO] 0.01945299999999861 [cRIO] 0.019967000000001178 [cRIO] 0.02024799999999516 [cRIO] 0.019709000000005972 [cRIO] 0.01999399999999696 [cRIO] 0.020249999999997215 [cRIO] 0.019863000000000852 [cRIO] 0.020217000000002372 [cRIO] 0.019892999999996164 [cRIO] 0.020042000000003668 [cRIO] 0.019748999999997352 [cRIO] 0.020043000000001143 [cRIO] 0.0200010000000006 [cRIO] 0.020333000000000823 [cRIO] 0.019875999999996452 [cRIO] 0.019884000000004676 [cRIO] 0.020113000000002046 [cRIO] 0.019994999999994434 [cRIO] 0.02008400000000421 [cRIO] 0.02040299999999462 [cRIO] 0.019336000000002684 [cRIO] 0.020540000000004 [cRIO] 0.01947499999999991 [cRIO] 0.020902999999997007 [cRIO] 0.01910999999999774 [cRIO] 0.019978000000001828 [cRIO] 0.020012999999998726 [cRIO] 0.020107000000002984 [cRIO] 0.01981500000000125 [cRIO] 0.020117999999996528 [cRIO] 0.01991199999999793 [cRIO] 0.020054999999999268 [cRIO] 0.020019000000004894 [cRIO] 0.02013799999999577 [cRIO] 0.019870000000004495 [cRIO] 0.02012099999999606 [cRIO] 0.020061000000005436 [cRIO] 0.019942999999997824 [cRIO] 0.019940999999995768 [cRIO] 0.02003100000000302 [cRIO] 0.019827999999996848 [cRIO] 0.019962000000006697 [cRIO] 0.02714199999999778 [cRIO] 0.01292699999999769 [cRIO] 0.019863999999998327 [cRIO] 0.020138000000002876 [cRIO] 0.02063100000000162 [cRIO] 0.019636999999995908 [cRIO] 0.01994300000000493 [cRIO] 0.02027299999999599 [cRIO] 0.019710000000003447 [cRIO] 0.020027999999996382 [cRIO] 0.020064000000004967 [cRIO] 0.019843999999999085 [cRIO] 0.01997199999999566 [cRIO] 0.02011099999999999 [cRIO] 0.019913999999999987 [cRIO] 0.020194000000003598 [cRIO] 0.019945999999997355 [cRIO] 0.01988099999999804 [cRIO] 0.02000600000000219 [cRIO] 0.020093000000002803 [cRIO] 0.020111999999997465 [cRIO] 0.026910000000000878 [cRIO] 0.012717999999999563 [cRIO] 0.020026999999998907 [cRIO] 0.020040000000001612 [cRIO] 0.020037999999999556 [cRIO] 0.02022699999999844 [cRIO] 0.02054300000000353 [cRIO] 0.01946699999999879 [cRIO] 0.01999699999999649 [cRIO] 0.019892000000005794 [cRIO] 0.01996899999999613 [cRIO] 0.02007199999999898 [cRIO] 0.021723999999998966 [cRIO] 0.01812500000000483 [cRIO] 0.020227999999995916 [cRIO] 0.019947000000001935 [cRIO] 0.0199089999999984 [cRIO] 0.02003400000000255 [cRIO] 0.020015000000000782 [cRIO] 0.02004399999999862 [cRIO] 0.020769999999998845 [cRIO] 0.01921300000000059 [cRIO] 0.019786000000003412 [cRIO] 0.019997999999993965 [cRIO] 0.020124000000002695 [cRIO] 0.019961000000002116 [cRIO] 0.020072999999996455 [cRIO] 0.020029000000000963 [cRIO] 0.020017000000002838 [cRIO] 0.01980999999999966 [cRIO] 0.022269999999998902 [cRIO] 0.017738000000001364 [cRIO] 0.019945999999997355 [cRIO] 0.02023799999999909 [cRIO] 0.019825000000004422 [cRIO] 0.01999999999999602 [cRIO] 0.02022500000000349 [cRIO] 0.019962999999997066 [cRIO] 0.019761000000002582 [cRIO] 0.020324999999999704 [cRIO] 0.01984199999999703 [cRIO] 0.020082000000002154 [cRIO] 0.019743999999995765 [cRIO] 0.020238000000006195 [cRIO] 0.020014999999993677 [cRIO] 0.0198040000000006 [cRIO] 0.02026599999999945 [cRIO] 0.01972000000000662 [cRIO] 0.019998999999998546 [cRIO] 0.01994699999999483 [cRIO] 0.02109500000000253 [cRIO] 0.019206000000004053 [cRIO] 0.019966999999994073 [cRIO] 0.020003000000002658 [cRIO] 0.020752000000001658 [cRIO] 0.01915199999999828 [cRIO] 0.020476999999999634 [cRIO] 0.019496000000003733 [cRIO] 0.019954999999995948 [cRIO] 0.02003700000000208 [cRIO] 0.020058999999996274 [cRIO] 0.02009500000000486 [cRIO] 0.020039999999994507 [cRIO] 0.020006999999999664 [cRIO] 0.019711000000000922 [cRIO] 0.019989000000002477 [cRIO] 0.0201849999999979 [cRIO] 0.019786000000003412 [cRIO] 0.02016100000000165 [cRIO] 0.019966999999994073 [cRIO] 0.019948000000006516 [cRIO] 0.020086999999996635 [cRIO] 0.020040999999999087 [cRIO] 0.020315000000003636 [cRIO] 0.020910999999998126 [cRIO] 0.018869000000002245 [cRIO] 0.01991099999999335 [cRIO] 0.0198960000000028 [cRIO] 0.020060000000000855 [cRIO] 0.020119999999998583 [cRIO] 0.01984600000000114 [cRIO] 0.01997599999999977 [cRIO] 0.020156000000000063 [cRIO] 0.019992000000002008 [cRIO] 0.019875999999996452 [cRIO] 0.019952000000003522 [cRIO] 0.02003899999999703 [cRIO] 0.019950999999998942 [cRIO] 0.02415600000000495 [cRIO] 0.017558999999998548 [cRIO] 0.01820099999999769 [cRIO] 0.020138000000002876 [cRIO] 0.02014899999999642 [cRIO] 0.01997400000000482 [cRIO] 0.02056699999999978 [cRIO] 0.019649999999998613 [cRIO] 0.01983699999999544 [cRIO] 0.019916000000002043 [cRIO] 0.019925999999998112 [cRIO] 0.020104000000003452 [cRIO] 0.01996899999999613 [cRIO] 0.020089000000005797 [cRIO] 0.01988399999999757 [cRIO] 0.02015999999999707 [cRIO] 0.020121000000003164 [cRIO] 0.01988399999999757 [cRIO] 0.02070300000000458 [cRIO] 0.019280999999999437 [cRIO] 0.020150000000001 [cRIO] 0.0196550000000002 [cRIO] 0.020775000000000432 [cRIO] 0.019251999999994496 [cRIO] 0.02002600000000143 [cRIO] 0.019967000000001178 [cRIO] 0.020124000000002695 [cRIO] 0.019885999999999626 [cRIO] 0.02072099999999466 [cRIO] 0.01945100000000366 [cRIO] 0.01994499999999988 [cRIO] 0.02018600000000248 [cRIO] 0.019722999999999047 [cRIO] 0.02007499999999851 [cRIO] 0.02379799999999932 [cRIO] 0.016322999999999865 [cRIO] 0.019782999999996775 [cRIO] 0.02015100000000558 [cRIO] 0.020270999999993933 [cRIO] 0.019754000000006045 [cRIO] 0.019815999999998724 [cRIO] 0.020310999999999524 [cRIO] 0.01969700000000074 [cRIO] 0.020060000000000855 [cRIO] 0.01984799999999609 [cRIO] 0.02037299999999931 [cRIO] 0.019815999999998724 [cRIO] 0.01990700000000345 [cRIO] 0.020332000000003347 [cRIO] 0.01992499999999353 [cRIO] 0.02002400000000648 [cRIO] 0.020189999999999486 [cRIO] 0.019765999999997064 [cRIO] 0.0204039999999992 [cRIO] 0.019517999999997926 [cRIO] 0.019838000000000022 [cRIO] 0.020096000000002334 [cRIO] 0.01993500000000381 [cRIO] 0.01998299999999631 [cRIO] 0.020029000000000963 [cRIO] 0.019978000000001828 [cRIO] 0.020064999999995337 [cRIO] 0.019913999999999987 [cRIO] 0.020009999999999195 [cRIO] 0.0201720000000023 [cRIO] 0.019997000000003595 [cRIO] 0.022979999999996892 [cRIO] 0.016818000000000666 [cRIO] 0.020387999999996964 [cRIO] 0.01974100000000334 [cRIO] 0.02002199999999732 [cRIO] 0.020033000000005075 [cRIO] 0.01996399999999454 [cRIO] 0.020049000000000206 [cRIO] 0.019928000000000168 [cRIO] 0.02005900000000338 [cRIO] 0.0199439999999953 [cRIO] 0.019925000000000637 [cRIO] 0.02031700000000569 [cRIO] 0.0196899999999971 [cRIO] 0.020135000000003345 [cRIO] 0.020114999999996996 [cRIO] 0.019871999999999446 [cRIO] 0.020012999999998726 [cRIO] 0.019944000000002404 [cRIO] 0.02004699999999815 [cRIO] 0.020015999999998257 [cRIO] 0.019809000000002186 [cRIO] 0.020138000000002876 [cRIO] 0.021020999999997514 [cRIO] 0.019089000000001022 [cRIO] 0.020018000000000313 [cRIO] 0.020696000000000936 [cRIO] 0.019242999999995902 [cRIO] 0.01981500000000125 [cRIO] 0.020102000000001397 [cRIO] 0.01995600000000053 [cRIO] 0.020029000000000963 [cRIO] 0.020207999999996673 [cRIO] 0.019660000000001787 [cRIO] 0.020089999999996166 [cRIO] 0.020042000000003668 [cRIO] 0.019973999999997716 [cRIO] 0.020473000000002628 [cRIO] 0.019314000000001386 [cRIO] 0.020022999999994795 [cRIO] 0.022302000000003375 [cRIO] 0.017952000000001078 [cRIO] 0.0197819999999993 [cRIO] 0.020102000000001397 [cRIO] 0.019888999999999157 [cRIO] 0.020230999999995447 [cRIO] 0.019927000000002693 [cRIO] 0.019983000000003415 [cRIO] 0.020053999999994687 [cRIO] 0.019967000000001178 [cRIO] 0.020789000000000613 [cRIO] 0.019309999999997274 [cRIO] 0.020400000000002194 [cRIO] 0.01931199999999933 [cRIO] 0.020124000000002695 [cRIO] 0.020106999999995878 [cRIO] 0.01998100000000136 [cRIO] 0.019860999999998796 [cRIO] 0.020028000000003487 [cRIO] 0.020136999999998295 [cRIO] 0.020029999999998438 [cRIO] 0.01998200000000594 [cRIO] 0.01994999999999436 [cRIO] 0.02002600000000143 [cRIO] 0.020383000000002482 [cRIO] 0.022705000000001974 [cRIO] 0.017861999999993827 [cRIO] 0.0212670000000017 [cRIO] 0.017876000000001113 [cRIO] 0.0199089999999984 [cRIO] 0.018914999999999793 [cRIO] 0.020319000000000642 [cRIO] 0.02000900000000172 [cRIO] 0.019713000000002978 [cRIO] 0.020324999999999704 [cRIO] 0.019955999999993423 [cRIO] 0.021434000000006392 [cRIO] 0.018278999999999712 [cRIO] 0.019920999999996525 [cRIO] 0.020091000000000747 [cRIO] 0.020014000000003307 [cRIO] 0.02043099999999498 [cRIO] 0.020060000000000855 [cRIO] 0.020884000000002345 [cRIO] 0.01870699999999914 [cRIO] 0.020175999999999306 [cRIO] 0.021906000000001313 [cRIO] 0.018057999999996355 [cRIO] 0.01976499999999959 [cRIO] 0.02005900000000338 [cRIO] 0.02006399999999786 [cRIO] 0.019984999999998365 [cRIO] 0.020016000000005363 [cRIO] 0.019852000000000203 [cRIO] 0.01999699999999649 [cRIO] 0.020014000000003307 [cRIO] 0.02085999999999899 [cRIO] 0.019115999999996802 [cRIO] 0.01998100000000136 [cRIO] 0.02034799999999848 [cRIO] 0.019743000000005395 [cRIO] 0.019969999999993604 [cRIO] 0.020834000000000685 [cRIO] 0.019154000000000337 [cRIO] 0.020351000000005115 [cRIO] 0.019782999999996775 [cRIO] 0.019863999999998327 [cRIO] 0.01995900000000006 [cRIO] 0.020419000000003962 [cRIO] 0.01973499999999717 [cRIO] 0.020254999999998802 [cRIO] 0.020149000000003525 [cRIO] 0.01984799999999609 [cRIO] 0.019854999999999734 [cRIO] 0.019978000000001828 [cRIO] 0.020330999999998767 [cRIO] 0.019764000000002113 [cRIO] 0.019944000000002404 [cRIO] 0.020730999999997834 [cRIO] 0.019033999999997775 [cRIO] 0.020793000000004724 [cRIO] 0.019093999999995503 [cRIO] 0.020068000000001973 [cRIO] 0.01989300000000327 [cRIO] 0.020155999999992957 [cRIO] 0.01997400000000482 [cRIO] 0.020041999999996563 [cRIO] 0.020545000000005587 [cRIO] 0.02011299999999494 [cRIO] 0.019421000000001243 [cRIO] 0.019908000000000925 [cRIO] 0.02002199999999732 [cRIO] 0.01991999999999905 [cRIO] 0.020029000000000963 [cRIO] 0.019992999999999483 [cRIO] 0.020448000000001798 [cRIO] 0.01956700000000211 [cRIO] 0.020226000000000965 [cRIO] 0.020052999999997212 [cRIO] 0.019679000000003555 [cRIO] 0.020129999999994652 [cRIO] 0.020181000000000893 [cRIO] 0.01988099999999804 [cRIO] 0.019881000000005145 [cRIO] 0.020089999999996166 [cRIO] 0.020166000000003237 [cRIO] 0.019773999999998182 [cRIO] 0.020504999999999995 [cRIO] 0.019983000000003415 [cRIO] 0.02005699999999422 [cRIO] 0.019624000000000308 [cRIO] 0.020502000000000464 [cRIO] 0.020051999999999737 [cRIO] 0.019203000000004522 [cRIO] 0.02033000000000129 [cRIO] 0.01980599999999555 [cRIO] 0.022809999999999775 [cRIO] 0.017161000000001536 [cRIO] 0.019911000000000456 [cRIO] 0.020144999999999413 [cRIO] 0.02002199999999732 [cRIO] 0.01988200000000262 [cRIO] 0.020184000000000424 [cRIO] 0.019803000000003124 [cRIO] 0.020103999999996347 [cRIO] 0.019919000000001574 [cRIO] 0.020341999999999416 [cRIO] 0.019807999999997605 [cRIO] 0.01982100000000031 [cRIO] 0.02013900000000035 [cRIO] 0.02006200000000291 [cRIO] 0.020164999999998656 [cRIO] 0.019975000000002296 [cRIO] 0.019897000000000276 [cRIO] 0.020015999999998257 [cRIO] 0.020395000000000607 [cRIO] 0.019925999999998112 [cRIO] 0.019846999999998616 [cRIO] 0.019803000000003124 [cRIO] 0.019911000000000456 [cRIO] 0.020461999999994873 [cRIO] 0.019856000000004315 [cRIO] 0.01998899999999537 [cRIO] 0.019852000000000203 [cRIO] 0.019776000000000238 [cRIO] 0.020119000000001108 [cRIO] 0.02020300000000219 [cRIO] 0.019680999999998505 |
|
#8
|
||||
|
||||
|
Re: Thread scheduler for PID period control ?
Quote:
Last edited by Ether : 31-01-2014 at 22:36. Reason: added 2nd graph |
|
#9
|
|||
|
|||
|
Re: Thread scheduler for PID period control ?
That is what I expected, which is why I was confused. I should get the 4 slot cRIO today and will retry. I know the older 8 slot was slower, but it seems strange that they would change the driver station behavior to update less often.
|
|
#10
|
||||||
|
||||||
|
Re: Thread scheduler for PID period control ?
My test was run on an 8-slot. The 8-slot has less ram, but the same processor. In this test, it is not slower.
|
|
#11
|
|||
|
|||
|
Re: Thread scheduler for PID period control ?
Thanks for the feedback, i will have them re-run the test. BTW: what period do you use for your PID loops?
|
|
#12
|
|||
|
|||
|
Re: Thread scheduler for PID period control ?
Quote:
I guess we just need to try the measurements again. |
|
#13
|
|||
|
|||
|
Re: Thread scheduler for PID period control ?
Just to reiterate. The 8-slot has less RAM and is a model variation of the same FreeScale processor, meaning it has a less cache. For most situations, it is the same speed.
Greg McKaskle |
|
#14
|
||||
|
||||
|
Re: Thread scheduler for PID period control ?
When you create a task and put it in a loop with a delay, the delay is subject to the resolution of the system clock (which is 10ms). So a request to delay for 20ms would have considerable variation. The system is waiting for two clock ticks which could happen in a little over 10ms or a little under 30ms.
The PID class does not use delays, instead it uses the timer OS libraries (last I looked). These fire in the context of the tick timer interrupt routine and are more periodic. The first PID timer callback may run at a variable time after enabling but it will run very periodically afterwards. Does that make sense? The operating system does have a higher resolution timer (the auxiliary timer) for custom purposes. It is not used by the base OS. And perhaps NI built a service on top of the the auxiliary timer. Plus there is normally a third timer only used for timestamps. But the base timers work as described above. The periodicity of the messages from the DS is dependent on many things. Ethernet is not strictly deterministic. The teleop loops start after a semaphore is given once the code on the cRIO processes an incoming message and the data is available. HTH Last edited by wireties : 02-02-2014 at 16:53. |
|
#15
|
||||||
|
||||||
|
Re: Thread scheduler for PID period control ?
I am not sure why but the autogenerated code from RobotBuilder does not include the feed forward gain, Kf, and the loop period, so they default to 0 and 50ms.
Here is a code snippet: public Launch() { super("Launch", Kp, Ki, Kd, Kf, 0.01); Note that we had 0.005 as the period at first and it was acting squirrely. I think we were having the PID loop take too much of the CPU time. When we backed off to 10ms, life was good. YMMV. Joe J. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|