Timing Issue
Page 1 of 1

Author:  FTCBrowncoats [ Wed Mar 12, 2014 2:36 pm ]
Post subject:  Timing Issue

We're trying to return to the start point after scoring the IR cube, but we don't have any sensors that can be used for timing or distance measure so we elected to use a simple raw int incriment decrement timer. The problem is, that whenver we run it, it doesn't return back, it just sits there.

while (findDirection() != 8) {

   motor[frontRight] = -40;
   motor[frontLeft] = -40;


   motor[frontRight] = 0;
   motor[frontLeft] = 0;

   motor[frontLeft] = -50;
   motor[frontRight] = -50;
   while (0 <= timeRun) {
   motor[frontLeft] = 0;
   motor[frontRight] = 0;

findDirection() returns the highest IR sensor zone reading as an int

Author:  BurningLights [ Wed Mar 12, 2014 6:34 pm ]
Post subject:  Re: Timing Issue

My guess it that either your first loop runs significantly slower than your second loop because of the IR sensor stuff, or you're running into variable overflow. Either way, I would recommend that you use a timer to track how long your first loop takes, instead of incrementing a variable. The code for using a timer looks like this:
// Clear out the first timer

// Do your IR beacon finding loop

// Get the number of milliseconds the first timer has been running
long milliseconds = time1[T1];

Then to retrace your steps:
// Drive backwards

// Clear out first timer again

while (time1[T1] < milliseconds){}

// Stop driving

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group