|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||||
|
|||||||
|
Re: Configure Timers
Quote:
If instead you use the WPILib GetPeriod() method, this happens: 1) the FPGA returns the elapsed time (measured with the FPGA's 1MHz clock) between the most recent N+1 counts detected, then 2) WPILib divides that elapsed time by N. You can then use this in your code to calculate speed. Using this method, you don't need to average the speed over seven and a half revolutions to get a clean signal. One-quarter of a revolution will given you a clean speed signal, with less phase lag. Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
|
#2
|
||||||
|
||||||
|
Re: Configure Timers
I haven't been able to find that implemented in java.
|
|
#3
|
||||
|
||||
|
Re: Configure Timers
Quote:
Quote:
Code:
this.m_counter.writeTimerConfig_AverageSize(1); Quote:
If you want to run your motor faster than 20ms, you must place the drive code in a different loop, thread, etc that does not wait for new DS packets. Here is a snipit from the WPI Library showing the wait: Code:
if (nextPeriodReady()) {
getWatchdog().feed();
FRCControl.observeUserProgramTeleop();
teleopPeriodic();
didTeleopPeriodic = true;
}
}
this.m_ds.waitForData();
}
}
private boolean nextPeriodReady()
{
return this.m_ds.isNewControlData();
}
Quote:
Not available on Java. The timer class in Java has getFPGATimeStamp() (returns ms) and getUsClock(), although the UsClock is deprecated I am not sure why. Last edited by NotInControl : 08-02-2013 at 11:55. |
|
#4
|
||||
|
||||
|
Re: Configure Timers
Quote:
...use only one channel of the encoder, and configure the FPGA to count only the rising edges of that channel and to report the period based on the elapsed time between the 126 most recent counts (i.e. set the FPGA averaging to 125 samples). You would use the GetPeriod() method of the Counter class to get the period. At 2300 rpm you should get single-digit rpm jitter (+/-3rpm) with this setup, and with only 1/4 of a rev lag instead of seven and a half revs. You could ask for speeds at a 10ms rate and get a fresh reading each time. Quote:
Quote:
Quote:
|
|
#5
|
|||
|
|||
|
Re: Configure Timers
I generally don't go and make my own spoon before I go to eat some soup.
That being said, I have tried to strongarm the Squawk VM running on the cRIO. An instance of Timer will handle execution of all of its TimerTasks. If you want, you can make instances of Thread and run them asynchronously from the main robot code. I would point out that you can't really guarantee the length of a timeslice unless you have ring 0 privileges. In this case, you could argue ring 0 privileges are JVM-level, but the JVM has a lot of overhead (compared to modern ones). I would say a timeslice of less than 15ms will be impossible to guarantee. And everyone seems to bring up JNI. Has anyone who says that actually tried to use it? It'd be even harder on something like a FIRST-compliant cRIO, where you have huge restrictions on what you can do with the thing (not saying it'd be impossible, but more of a pain than usual). |
|
#6
|
||||
|
||||
|
Re: Configure Timers
Quote:
|
|
#7
|
|||
|
|||
|
Re: Configure Timers
I'm trying to say that this whole argument is basically futile because of the lack of control you have over the JVM and its scheduling. What control you do have you can not apply to the precision that is wanted.
Most tasks should be run by a Timer as TimerTasks. If you want to try to run something faster, use a Thread, but you will not be able to guarantee execution timing. |
|
#8
|
||||
|
||||
|
Re: Configure Timers
Which "argument" are you referring to? There are many different things being discussed here; many of them are not rendered pointless by your scheduling comment.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|