Go to Post rumors only beget more rumors - JakeGallagher [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 01-02-2007, 11:56
benjamin1748 benjamin1748 is offline
Benjamin
FRC #1748 (Lab Rats)
Team Role: Programmer
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Baltimore
Posts: 1
benjamin1748 is an unknown quantity at this point
encoders

I was working on a program using the encoders to get my robot to drive straight. I ran into a problem. When I tried to get my wheels to drive at the same speed they would slow down, speed up, and would repeat this until they stopped. If looked as if the wheels were playing catch up. Does anyone know a solution or have any helpful advice on how I should go about this problem?
  #2   Spotlight this post!  
Unread 01-02-2007, 12:05
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: encoders

It sounds as if you have implemented a simple PID control, or at least the proportional part of PID. If you are unfamiliar with this just search for it here on ChiefDelphi. Believe it or not, you aren't too far away from making your drive behave properly. I am guessing you are finding the error between the speed you want and the speed the encoders are showing and applying that error to your motors to make the correction. The problem is you keep overshooting the mark, this is a common problem in all mechanical control systems. You just need to scale down your error so that the response is slower and doesn't overshoot:

correction = error*.4 (for example)

In a true PID control you would scale it down to just enough to prevent oscillation, however this often results in the error never going to 0. That's when you can try adding in the "I" and the "D" part of the control. I will let you find out more about that after you search for "PID"
  #3   Spotlight this post!  
Unread 05-02-2007, 10:26
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 590
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: encoders

Quote:
Originally Posted by benjamin1748 View Post
I was working on a program using the encoders to get my robot to drive straight. I ran into a problem. When I tried to get my wheels to drive at the same speed they would slow down, speed up, and would repeat this until they stopped. If looked as if the wheels were playing catch up. Does anyone know a solution or have any helpful advice on how I should go about this problem?
If the problem isn't related to PID stuff - another easy way to use encoders to drive straight is using this algorithm:

Code:
error = GetEncoder(LEFT_ENCODER) - GetEncoder(RIGHT_ENCODER);
Drive(speed, error);
The Drive function (either from the easyC samples or built in to WPILib) takes a speed and direction. When you are driving straight, the wheel counts will be the same on the two wheels. If the count is different, you need to speed up either the right or left wheel. The amount of the correction is proportional to the amount of error.

A few implementation details:
1. You should make sure that the sign of error matches your robot.
2. You should probably limit error so the robot doesn't make wild turns.
3. You might want to stick this into a function, like DriveStraight where the encoder counts are reset at the beginning of the straight driving segment.
4. The drive function simply sends speed+direction to one wheel and speed-direction to the other wheel, so make sure that they don't exceed +/-127 since that's all the range that speed controls have.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
  #4   Spotlight this post!  
Unread 07-02-2007, 11:14
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Re: encoders

To Brad & Adam,

Kevin Watson's code apparently handles 8 interrupts......how many does EasyCPro handle? We are using 3 ultrasonic sensors and 4 encoders!

Jon Mittelman
  #5   Spotlight this post!  
Unread 07-02-2007, 22:28
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: encoders

John,

The controller only has 6 interrupt ports and easyC handles all 6 of them. You are going to need to loose a sensor or use a VEX co-processor. Why are you using 4 encoders do you have a mechanum(sp?) drive system?
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #6   Spotlight this post!  
Unread 07-02-2007, 22:31
Unsung FIRST Hero
Greg Marra Greg Marra is offline
[automate(a) for a in tasks_to_do]
FRC #5507 (Robotic Eagles)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2005
Location: San Francisco, CA
Posts: 2,030
Greg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond repute
Re: encoders

Quote:
Originally Posted by Kingofl337 View Post
The controller only has 6 interrupt ports and easyC handles all 6 of them. You are going to need to loose a sensor or use a VEX co-processor. Why are you using 4 encoders do you have a mechanum(sp?) drive system?
Would it even be possible to use a VEX coprocessor (or any coprocessor for that matter) with EasyC? That sounds far beyond the scope of what EasyC can handle.
  #7   Spotlight this post!  
Unread 07-02-2007, 22:37
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: encoders

No, it would not be beyond the scope of easyC. You could connect the two serial ports together and and pass data all day long. We even have a feature to select the baudrate for devices that use a slower serial speed.

If you start calling some of the Microchip libraries you can touch and piece of the hardware you can touch in MPLAB.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Encoders Ctx32 Programming 8 13-05-2006 23:54
3 Encoders stephenthe1 Programming 5 17-11-2005 19:21
encoders stephenthe1 Programming 61 09-02-2005 15:05
Optical Encoders misterikkit Robotics Education and Curriculum 7 22-12-2003 23:13


All times are GMT -5. The time now is 04:14.

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