LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle rollover in FPGA Tick Count output?

Solved!
Go to solution

I wrote a little VI that counts ticks on a set of DI lines for a finite amount of time. It uses the Tick Count VI to determine how much time has elapsed since it started running. The output of this VI is a U32, and the subtract function looks like it will saturate at '0' if the tick count rolls over. How can I handle this situation to prevent the VI from exiting early?

 

timer.png

0 Kudos
Message 1 of 3
(3,964 Views)
Solution
Accepted by David_Staab

Integer arithmetic should handle rollover calculation correctly (e.g. if your value is a U8 and you do 3-250, you should get 9). I'm assuming (although I never checked) that it works the same in the FPGA. You can do a simple check yourself with explicit code. That would make anything less than a full cycle safe, so it all depends on how long that takes. If it's ms, it would take ~50 days. In your case, it looks like you configured the function to be in us, so that would be somewhere over an hour. If that's not enough, then you could hold the actual value in a U64 and then take the number of us that passed in each iteration and add that to the U64.


___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(3,956 Views)

Thanks, tst. When I got access to hardware today, I tested the subtract function and then the entire VI. It works fine through rollover, as you expected.

0 Kudos
Message 3 of 3
(3,935 Views)