Go to Post Holy 5-year-old-thread-revival Batman!! - Mr. Freeman [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 11-02-2008, 23:16
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: Attempting to Drive Straight with Gear Tooth Sensors and Gyroscope

Lynx34,

A fairly simple method to make your robot drive straight can be done with minimal changes in your code. Since you are already counting gear tooth pulses when running your "drive straight" code, just take the difference between your left & right and add/subtract that number from your base PWM value (which would be your joystick value)

When you are in your drive straight code, use this:

if (left_joystick > 127)
{
left_motor = left_joystick;
right_motor = left_joystick + (gt_left - gt_right);
}
else
{
left_motor = left_joystick;
right_motor = left_joystick - (gt_left - gt_right);
}

You can try using a multiplier (or divider) on the (gt_left - gt_right) depending on how quickly you are counting pulses, and you would also have to make sure the right_motor doesn't go below 0 or above 255. We used this fairly successfully in 2004 when we wanted to drive straight in autonomous and used gear tooth sensors. What this code will do is cause your robot to curve very slightly to the right/left at the beginning of the "drive straight" code until the power to the motors evens out the speed. You only want to reset the gt_left and gt_right when you are no longer using the "drive straight" code (instead of every 1/2 second), which in your case would be when the left and right joystick values are more than 5 apart. (Also notice that I am ignoring the right_joystick in the above code. This is on purpose as I am using the left_joystick as the base speed since by this time we know they are less than 5 apart).

There are, of course, many other ways to drive straight, but this may be good enough for you without going into PID loops, gyros and the like.

Mike

Last edited by Mike Bortfeldt : 11-02-2008 at 23:21. Reason: Added code for reverse
 


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
Help with the Kit Gear Tooth sensors Keo-san Programming 9 20-02-2007 08:07
Gryo, Camera, Accelorometer, Ultrasonic, and Gear Tooth Sensors in one program EHaskins Programming 8 22-05-2006 12:08
where can we buy hall effect sensors or gear tooth sensors amirjpl Electrical 3 13-02-2006 11:02
Gear Tooth Sensors et1337 Electrical 7 28-01-2006 22:48
Accelerometer vs Gear Tooth Sensors zdeswarte Electrical 4 22-01-2005 15:35


All times are GMT -5. The time now is 19:11.

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