I have a fairly complicated math routine to calculate the time delay before turning on an output. The variables in the routine can change depending on input states, programmend variables, etc.
Since these variables can be different every time the calculations are made the time it takes to execute the calculation is different.
Does anyone know a way to see how long it takes to execute a certain part of code on the fly? I can see the different times using the Stopwatch fucntion in MPLAB but I need to be able to get this value into the code so I can subtract if from the final calculation to get a correct delay time.
Thanks
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
Posted: Mon Apr 16, 2007 8:12 am
How about starting a timer when you collect the data. Then when you are done with the math you read the timer and subtract from your calculated time. Or more likely just let the timer run till it matches your calculated time, then do your I/O. Then you have the precise time between the data collection and the output. _________________ The search for better is endless. Instead simply find very good and get the job done.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum