|
Re: Counter loop
Posted by Joe Ross at 2/12/2001 7:14 PM EST
Engineer on team #330, Beach Bot, from Hope Chapel Academy and NASA/JPL , J&F Machine, and Raytheon.
In Reply to: Counter loop
Posted by Eric on 2/12/2001 5:24 PM EST:
: If you want to time a motor out (say run it for 1 second and stop) and you wanted to do it more accuratly than simply counting loops (presumably bad data could thow this method off) what would the progam code look like? (I'm trying to get a handle on the delta_t kind of thing.)
delta_t is the number of data packets that you missed.
to be able to time things you should use the following idea:
counter = couter + 1 + delta_t
If delta_t is 0 then no data was lost and your program loop is less than 1/40th of a second. If delta_t is not zero, then you missed that many packets.
using this code, when the counter reaches 40 then 1 second has passed.
__________________
This message was archived from an earlier forum system. Some information may have been left out. Start new discussion in the current forums, and refer back to these threads when necessary.
|