| Author |
Message |
Marius
Joined: Jun 10, 2013 Posts: 51
|
Posted: Jun 12, 2013 4:54 PM Post subject: Scalar Timer's tick rate deviates from Target rate |
|
Hi Jarek,
the subject says it pretty much. My measurement tool is the Counter element, either over 1 or 10 seconds.
Exaample value 20 ticks per 1 second target parameters entered in timer 141 ticks measured by counter in 10 seconds.
This gets worse for larger tick rates.
Any hints?
Marius
|
|
 |
Marius
Joined: Jun 10, 2013 Posts: 51
|
Posted: Jun 12, 2013 5:18 PM Post subject: |
|
| The cause of error may be also the counter element, that its correctness is limited to very low rates? |
|
 |
jarek
Joined: Oct 22, 2007 Posts: 1073
|
Posted: Jun 12, 2013 6:30 PM Post subject: |
|
Both Timer and Counter use system clock. When you use system clock calculations can get rounded to a few milliseconds at a time, they depend on operating system.
If you want precision use your input sample rate (assuming it is precise) and count samples since the design started, not since the last tick to avoid rounding.
Another possible solution would be to use SimulationSource (you can configure it for a specific output sample rate), it also uses system clock, but it measures time from the design start, so the output rate should be quite precise. |
|
 |
Marius
Joined: Jun 10, 2013 Posts: 51
|
Posted: Jun 18, 2013 1:46 PM Post subject: |
|
I cannot really use a global sample rate because I wish to set the tick rate freely which can't alyways be a nice fraction of the sample rate. Because decimating the global rate would be how I could get a certain tick rate, right? (I never learned how data actually moves through the system, in loopwise batches of undeterminable length, or really one after another...)
Anyhows, I tried with SimulationSource. With its job to generate a comparison signal for actual measurement data, it should be able to generate a precise rate. Simulation Source is faithful until around 50Hz, then also deviates considerably. I'm sending you my snippet for this, you can easily try. I'm using Counter to check the rate, so I cannot be perfectly sure if it's a good measurement device. On the other hand, counter reports real data rates up to 2000 accurate as a charm!
Independently of this is the following question: TimeSource yields a time signal e.g. FROM START. What I need is the same thing, but FROM TRIGGER EVENT. Is there any element or trick that can provide this?
Marius
|
|
 |
jarek
Joined: Oct 22, 2007 Posts: 1073
|
Posted: Jun 18, 2013 6:43 PM Post subject: |
|
If you use timer, it should be more precise in longer time to set one pulse in a specified time period, e.g. 0.1s.
Your snippet doesn't seem to prove that SimulationSource is imprecise, only that it is different than Timer. It should be definitely more accurate (then Timer) when it comes to rate in longer time.
The last question: if you remember the time at triger, you can subtract it from the value provided in TimeSource. It is so simple to do. Or you could use FROM_RESUME option and restart this element at the trigger time. |
|
 |
jarek
Joined: Oct 22, 2007 Posts: 1073
|
Posted: Jun 19, 2013 1:31 AM Post subject: |
|
| I analyzed and improved SimulationSource, now it should maintain the output sample count very precisely. |
|
 |
Marius
Joined: Jun 10, 2013 Posts: 51
|
Posted: Jun 19, 2013 4:49 PM Post subject: |
|
| perfect, it works now like it should. thanks |
|