|
Page 1 of 1
|
[ 7 posts ] |
|
Need help with encoder programming. Badly
| 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
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2905 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| 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
Expert
Joined: Thu Jan 03, 2013 5:10 pm Posts: 140 Location: Southern Indiana
|
 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 asparagusI am not a robot! I am a unicorn! ~ quote from a robotPlay chess for free!
|
| 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
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2905 Location: Rotterdam, The Netherlands
|
 Re: Need help with encoder programming. Badly
Why do you reset the motor encoders in your while loop?
= Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Tue Feb 26, 2013 1:12 pm |
|
 |
|
Coder A
Expert
Joined: Thu Jan 03, 2013 5:10 pm Posts: 140 Location: Southern Indiana
|
 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 asparagusI am not a robot! I am a unicorn! ~ quote from a robotPlay chess for free!
|
| Tue Feb 26, 2013 3:12 pm |
|
|
|
Page 1 of 1
|
[ 7 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 6 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
|
|