04-17-2013 12:18 AM
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?
Solved! Go to Solution.
04-17-2013 01:09 AM
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.
04-17-2013 11:20 AM
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.