![]() |
Re: Velocity PID Programming: Terms dependent on time
Quote:
In all tests I've done, they just do. It's likely the fact that the code is actually running faster than a waited loop. |
Re: Velocity PID Programming: Terms dependent on time
Quote:
|
Re: Velocity PID Programming: Terms dependent on time
I'm not certain about labview's implementation but in C++ you can request the system clock for its time since it powered up. This has a resolution of 1ms. Before you do your dt calculation you can figure out how much time has passed by asking for the current system time and subtracting the last time you asked for the time. I think this is much better than any loop that you state how long it takes. This will account for anything that changes the cpu load, perhaps vision code or the garbage collector.
new_time = current_sys_time do pid calculations with dt = new_time - old_time old_time = new_time |
Re: Velocity PID Programming: Terms dependent on time
Quote:
The same thing exists in LabVIEW. It's the 'Tick Count' block with the same 1ms accuracy. I *believe* there's a more accurate Tick Count in the RT section that can measure from other clock sources. BUT, I haven't ever needed more than ms accuracy. In an ideal realtime world there is no garbage collector, all of the RAM is statically allocated in blocks and never dynamically allocated. In an ideal realtime world, people also don't try to run vision on the same processor that runs hard RT control loops without actual RT control loops, when the RT task is already using the majority of the CPU, and expect the non-RT control loop to be reasonably consistent. |
Re: Velocity PID Programming: Terms dependent on time
Quote:
There's a much more accurate system timer that is available: Timer::GetPPCTimestamp() has low overhead and returns time in seconds in double precision with 1/3 microsecond resolution. According to the WPILibC++Source20120204rev3111 source code date February 4 2012, it uses a 64-bit counter incrementing at 33MHz, which if true wouldn't overflow in your lifetime. Warning: I'm told that earlier versions of GetPPCTimestamp() used a 32-bit counter instead of 64, and would rollover every 130 seconds. Check the source code on your machine to make sure. |
Re: Velocity PID Programming: Terms dependent on time
Quote:
Timer::GetFPGATimestamp() and ::GetClock() -- double precision seconds since FPGA was reset. Uses FPGA clock so is synchronized with other FPGA timers. FPGA clock counts time in microseconds with an unsigned 32-bit integer. Rolls over every 71.6 minutes. (Timer::Reset does NOT reset the rollover.) Timer::GetPPCTimestamp() -- double precision seconds since cRIO was powered on. Uses PPC system clock so is not synchronized with FPGA timers. Hardcoded assumption of 33MHz in WPILib. The counter is fetched with niTimestamp64() so it's probably 64-bit and rolls over every 9 billion minutes. ::GetTime() -- double precision seconds since January 1, 1970. This uses the vxWorks real-time clock which I can't find documentation on. The API allows nanosecond precision which seems optimistic. |
Re: Velocity PID Programming: Terms dependent on time
Anyone know if there is a common high-resolution timer that can be called from LabVIEW? I'm only familiar with the millisecond resolution timer that's available from the timing palette.
|
Re: Velocity PID Programming: Terms dependent on time
Quote:
|
Re: Velocity PID Programming: Terms dependent on time
Quote:
1) how many layers of code are wrapped around each of these timers, and 2) can each one be used in a critical section, and 3) how long does each take to execute, and 4) is there anybody who has authoritative answers to these questions |
Re: Velocity PID Programming: Terms dependent on time
3 Attachment(s)
Quote:
Look under Real Time -> RT Timing They use a 32-bit internal counter. |
Re: Velocity PID Programming: Terms dependent on time
Quote:
|
Re: Velocity PID Programming: Terms dependent on time
Quote:
|
Re: Velocity PID Programming: Terms dependent on time
Quote:
|
Re: Velocity PID Programming: Terms dependent on time
Quote:
Quote:
Quote:
|
Re: Velocity PID Programming: Terms dependent on time
Quote:
Code:
INCORRECT!!Code:
CORRECT:Quote:
Quote:
|
| All times are GMT -5. The time now is 21:35. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi