|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Autonomous problem
I have written this for atonomous code but the the robot does not stop when the counter reaches 2000. Anyone know why?
/* Add your own autonomous code here. */ switch (Step) { case 1: { stop = 2000; crawl = (stop - 200); slow = (stop - 100); Left_Count = Get_Left_Encoder_Count(); Right_Count = Get_Right_Encoder_Count(); if (Left_Count < slow) pwm03 = 220; if (Left_Count > slow && Left_Count < crawl) pwm03 =200; if (Left_Count > crawl && Left_Count < stop) pwm03 =150; if (Left_Count >= stop) pwm03 =127; printf("Left Counter %ld\r", Left_Count); if (Right_Count < slow) pwm04 =220; if (Right_Count > slow && Right_Count < crawl) pwm04 =200; if (Left_Count > crawl && Right_Count < stop) pwm04 =150; if (Right_Count >= stop) pwm04 =127; printf("Right Counter %ld\r", Right_Count); |
|
#2
|
|||||
|
|||||
|
Re: Autonomous problem
Make sure that your encoders are counting the direction that you expect them to.
Are you changing the values of pwm03 or pwm04 anywhere else? |
|
#3
|
||||
|
||||
|
Re: Autonomous problem
I am not changing the pwm's anywhere else and the encoders are counting in the correct direction. Actually i am using hall effect sensors with encoder code.
|
|
#4
|
||||
|
||||
|
Re: Autonomous problem
Where did the "step" variable come from? I don't see it being used anywhere in that code block.
EDIT: It would help if you posted the rest of that part of the code so we could tell more about the problem (don't worry, we aren't going to steal your code for our own use) Last edited by Chriszuma : 06-02-2006 at 22:40. |
|
#5
|
|||||
|
|||||
|
Re: Autonomous problem
Step needs to be set to 1 somewhere, but I don't see it being done in the code fragment you posted.
|
|
#6
|
|||
|
|||
|
Re: Autonomous problem
Quote:
I dont know, I'm just asking...if the count isnt updating due to code not interfacing properly with your sensors, that could be the issue. |
|
#7
|
|||
|
|||
|
Re: Autonomous problem
Let's look at your algorithm first. I have changed your mode variables to hard coded numbers which makes the code more obvious.
Code:
/* Add your own autonomous code here. */
switch (Step)
{
case 1:
{
stop = 2000;
crawl = 1800; // are you sure these
slow = 1900; // are in the correct order?
Left_Count = Get_Left_Encoder_Count();
Right_Count = Get_Right_Encoder_Count();
if (Left_Count < 1900)
pwm03 = 220;
if (Left_Count > 1900 && Left_Count < 1800)
pwm03 =200;
if (Left_Count > 1800 && Left_Count < 2000)
pwm03 =150;
if (Left_Count >= 2000)
pwm03 =127;
printf("Left Counter %ld\r", Left_Count);
if (Right_Count < 1900)
pwm04 =220;
if (Right_Count > 1900 && Right_Count < 1800)
pwm04 =200;
if (Left_Count > 1800 && Right_Count < 2000)
pwm04 =150;
if (Right_Count >= 2000)
pwm04 =127;
printf("Right Counter %ld\r", Right_Count);
Code:
if (count < slow) {
// fast
}
else if (count < crawl) {
// slow
}
else if (count < stop) {
// crawl
}
else {
// stop
}
|
|
#8
|
||||
|
||||
|
Re: Autonomous problem
thanks for your help and step is defined at the top of user routines fast.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Autonomous Problem... | JoeFryman | Programming | 2 | 19-02-2005 14:56 |
| Future of Autonomous Mode | FadyS. | Programming | 41 | 24-05-2004 19:45 |
| problem with autonomous that has stumped all programmers so far | bd02 | Programming | 32 | 10-03-2004 22:22 |
| autonomous mode problem on field | Chris_C | Programming | 17 | 26-03-2003 19:11 |
| The problem with scouting... | archiver | 2001 | 10 | 23-06-2002 23:49 |