Author |
Message |
itsBenton
Rookie
Joined: Wed Feb 06, 2013 6:39 pm Posts: 6
|
 Need help with encoder programming. Badly
 |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, none, none, none) #pragma config(Sensor, S1, , sensorI2CMuxController) #pragma config(Motor, mtr_S1_C1_1, Left, tmotorTetrix, PIDControl, reversed, encoder) #pragma config(Motor, mtr_S1_C1_2, Right, tmotorTetrix, PIDControl, encoder) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main() { nMotorEncoder[Left] = 0; nMotorEncoder[Right] = 0; { nMotorEncoderTarget[Left] = 360; nMotorEncoderTarget[Right] = 360; motor[Left] = 70; motor[Right] = 70; }
while(nMotorRunState[Left] != runStateIdle && nMotorRunState[Right] != runStateIdle) { nMotorEncoder[Left] = 0; nMotorEncoder[Right] = 0; } }
|  |  |  |  |
this is the code and its just not working for me. PLEASE HELP
|
Tue Feb 26, 2013 12:00 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Need help with encoder programming. Badly
Hi Benton,
How about you add a little explanation about what you're looking to achieve. None of us are psychic and even if we were, we'd never let on.
So how about you write a little post about what you've tried, what you're seeing and what you think might be the issues.
= Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Feb 26, 2013 12:07 pm |
|
 |
itsBenton
Rookie
Joined: Wed Feb 06, 2013 6:39 pm Posts: 6
|
 Re: Need help with encoder programming. Badly
well, im looking for the robot to drive forward till the IR seeker reads 5. (i have not put in the IR yet). If it does not read 5, continue. if it does read 5, Make a 90 degree turn to the left and then lift our arm for this years competition. Then the robot will drive forward and place the ring on the post. (again, i have not programmed that far yet)
|
Tue Feb 26, 2013 12:17 pm |
|
 |
Coder A
Moderator
Joined: Thu Jan 03, 2013 5:10 pm Posts: 207 Location: The plateau north of the Ohio River Valley, also known as Cave Country.
|
 Re: Need help with encoder programming. Badly
Your code never finishes as the encoders are constantly being reset, and never reach 360 so they can stop. First you will want to change both !='s to =='s in the while statement.
_________________ I'm not a robot! I'm british! ~ quote from an asparagus I am not a robot! I am a unicorn! ~ quote from a robot
|
Tue Feb 26, 2013 12:45 pm |
|
 |
itsBenton
Rookie
Joined: Wed Feb 06, 2013 6:39 pm Posts: 6
|
 Re: Need help with encoder programming. Badly
for every video or thing ive seen, it says !=
|
Tue Feb 26, 2013 12:50 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Need help with encoder programming. Badly
Why do you reset the motor encoders in your while loop?
= Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Tue Feb 26, 2013 1:12 pm |
|
 |
Coder A
Moderator
Joined: Thu Jan 03, 2013 5:10 pm Posts: 207 Location: The plateau north of the Ohio River Valley, also known as Cave Country.
|
 Re: Need help with encoder programming. Badly
If you want to keep your loop the way it is, take the current commands out of it and place them right after it. That will also work.
_________________ I'm not a robot! I'm british! ~ quote from an asparagus I am not a robot! I am a unicorn! ~ quote from a robot
|
Tue Feb 26, 2013 3:12 pm |
|
|