View unanswered posts | View active topics It is currently Wed Dec 17, 2014 9:23 pm






Reply to topic  [ 2 posts ] 
Timing Issue 
Author Message
Rookie

Joined: Tue Jan 14, 2014 10:00 pm
Posts: 5
Post 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.

Code:
while (findDirection() != 8) {
      timeRun++;
   }

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

   wait1Msec(600);

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

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


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


Wed Mar 12, 2014 2:36 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 212
Post 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:
Code:
// Clear out the first timer
ClearTimer(T1);

// 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:
Code:
// Drive backwards

// Clear out first timer again
ClearTimer(T1);

while (time1[T1] < milliseconds){}

// Stop driving

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Wed Mar 12, 2014 6:34 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.