View unanswered posts | View active topics It is currently Thu Aug 21, 2014 2:21 am






Reply to topic  [ 2 posts ] 
autonmous help 
Author Message
Rookie

Joined: Sun Mar 06, 2011 6:53 pm
Posts: 7
Post autonmous help
we are haveing a slight problem with our autonmouse program. we are trying to move with dead reckoning by time.
here is what we tried

motor[motorD]=100;
motor[motorE]=100;
wait1Msec(2000);

we downloaded this and ran it, the robot didn't move.

next we tried this..
task main ()
{
while (true);
{
ClearTimer(T1);

while(time1[T1]<2000)
{
motor[motorD]=100;
motor[motorE]=100;
}
while (time1[T1]>2000)
{
motor[motorD]=0;
motor[motorE]=0;
}
}
}

this worked so we added a turn and that worked it looked like this...

task main ()
{
while (true);
{
ClearTimer(T1);

while(time1[T1]<2000)
{
motor[motorD]=100;
motor[motorE]=100;
}
while (time1[T1]>2000)
{
motor[motorD]=0;
motor[motorE]=0;
}
ClearTimer(T2);

while(time1[T2]<50)
{
motor[motorD]=100;
motor[motorE]=-100;
}
while(time1[T2}>50)
{
motor[motorD]=0;
motor[motorE]=0;
}
}
}

we then added a third movement, go straight, this didnt work what happend is that the program whent strait skiped over the turn and went straight again here is the code...
task main ()
{
while (true);
{
ClearTimer(T1);

while(time1[T1]<2000)
{
motor[motorD]=100;
motor[motorE]=100;
}
while (time1[T1]>2000)
{
motor[motorD]=0;
motor[motorE]=0;
}
ClearTimer(T2);

while(time1[T2]<50)
{
motor[motorD]=100;
motor[motorE]=-100;
}
while(time1[T2}>50)
{
motor[motorD]=0;
motor[motorE]=0;
}

Cleattimer(T3);

while(time1[T3]<2000)
{
motor[motorD]=100;
motor[motorE]=100;
}

while(time1[T3]>2000)
{
motor[motorD]=0;
motor[motorE]=0;
}
}
}

Any help would be appreciated. THANKS


Mon Mar 07, 2011 3:51 pm
Profile
Rookie

Joined: Mon Mar 07, 2011 5:45 pm
Posts: 6
Post Re: autonmous help
Code:
while (time1[T1]>2000)
{
motor[motorD]=0;
motor[motorE]=0;
}


Your robot is stuck in a while loop while the time is more than 2000. Since the timer counts up, it will never go back under 2000. You won't ever get out of the while loop, so the next code should never start.

It would be more efficient to use Motor Encoders, simply because powers vary with how much the battery is charged. You won't move a constant distance each time.

If you do insist on using timers, then choose a different condition.
Try using time1[T1] < someTime. This will give you the set amount of time of movement (or lack of movement) you want.


Mon Mar 07, 2011 5:55 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.