Go to Post The minibot horse is dead. Stop trying to beat it. Glue is too cheap. - Taylor [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 10-02-2003, 13:44
Skabana159's Avatar
Skabana159 Skabana159 is offline
Robotics and Field Hockey
AKA: Jesse C. Owens
#0159 (Alpine Robotics)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2000
Location: Ft. Collins, CO
Posts: 92
Skabana159 is on a distinguished road
Send a message via AIM to Skabana159
Okay. I'm going to assume that your wheel is simply a potentiometer with a wheel attached. This means that it will simply read a value between 0 and 254, 0 all the way left, 254 all the way right. One solution to your problem of over correction would be what my team has come to call a "slew rate." We have incurred the same problem letting our joystick snap back into place, and it kind of bounces around. What you must do is ramp the speed of your rotation. I will do it with the default tank drive code, since I am not sure what your drive code is, but it should be easy to apply to your code.

pwm1_old var byte
pwm2_old var byte
slew_rate CON 5 'Or however much you decide it should be

pwm1_old = pwm1
pwm2_old = pwm2
PWM1 = (((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) -2000)
PWM2 = (((2000 + p1_y + p1_x - 127) Min 2000 Max 2254) -2000)
'The above two lines could be replaced by your current code

If (abs(pwm1-pwm1_old) < slew_rate) then noslew1
If pwm1>pwm1_old then pwm1=((pwm1_old+slew_rate)MAX 254)
If pwm1<pwm1_old then pwm1=((pwm1_old-slew_rate)MIN 0)

noslew1:
If (abs(pwm2-pwm2_old) < slew_rate) then noslew2
If pwm2>pwm2_old then pwm2=((pwm2_old+slew_rate)MAX 254)
If pwm2<pwm2_old then pwm2=((pwm2_old-slew_rate)MIN 0)
noslew2:

This code stores the old value of the motor outputs, then assigns the new motor output based on the joystick (in your case a steering wheel. It then goes on to check if the new value is "close enough" to your old value, in other words within your constant, 5 in my case. If it is not within the constant, it adds or subtracts the constant to the old value, and assigns it to your new motor output.
This will, in effect, add or subtract a constant to your motor speed every loop until it reaches the correct point on your steering wheel.
I hope this helps you out!
__________________
"What most people do not understand is that the Buddha, the Godhead, resides just as comfortably in gears and circuits as in hills and trees. To believe otherwise is to dilute the Godhead."
-Robert Pirsig, Zen and the Art of Motorcycle Maintenance
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
4 wheel steering/ Crab Huey_Da_X-cat Technical Discussion 3 11-02-2002 22:49
"Motors and Drive train edition" of Fresh From the Forum Ken Leung CD Forum Support 6 29-01-2002 12:32


All times are GMT -5. The time now is 22:33.

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