View unanswered posts | View active topics It is currently Tue Aug 04, 2020 10:50 pm

Reply to topic  [ 2 posts ] 
Timing Issue 
Author Message

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.

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

Wed Mar 12, 2014 2:36 pm
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
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:
// 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

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

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

Who is online

Users browsing this forum: No registered users and 1 guest

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.