Go to Post We're not here to build robots. We're here to build students. - GreyingJay [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-01-2013, 15:33
Spacemonkey619 Spacemonkey619 is offline
Registered User
None #4899
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: California
Posts: 7
Spacemonkey619 is an unknown quantity at this point
Robotc NXT Encoder help

I'm using Robotc for NXT and I'm trying to learn the encoders. So i made a simple forward then left with encoders program. The robot runs the go forwards part but completely ignores the part were it is supposed to turn left. Can anyone help me out and tell me what i did wrong here?


task main()
{

nMotorEncoder[rightMotor] = 0; //clear the LEGO encoders in motors B and C+
nMotorEncoder[leftMotor] = 0;

while (nMotorEncoder[rightMotor] < 1500) //while the encoder wheel turns one revolution (360)
{
motor[rightMotor] = 50; //turn both motors on at 50 percent power
motor[leftMotor] = 50;
}

motor[rightMotor] = 0; //turn both motors off
motor[leftMotor] = 0;

wait1Msec(1000);

//new line

while (nMotorEncoder[leftMotor] < 500) //while the encoder wheel turns one revolution (360)
{
motor[rightMotor] = 50; //robot will turn left
motor[leftMotor] = 0;
}

motor[rightMotor] = 0; //turn both motors off
motor[leftMotor] = 0;


wait1Msec(3000); // wait 3 seconds to see feedback from the debugger screens
// open the "NXT Devices" window to see the distance the encoder
//spins. The robot will coast a little bit.
}
  #2   Spotlight this post!  
Unread 23-01-2013, 20:38
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Robotc NXT Encoder help

The encoders don't go back to zero after you've read them. You don't want to go to a certain distance; you want to go a certain distance beyond where you are now. If you're at 1500 and you want to go 500 more, you want to drive until 2000.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:22.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi