Go to Post Just so you don't spend too much time on non-clues ... now you can all go back to the real one! :D - Libby K [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
  #3   Spotlight this post!  
Unread 28-03-2004, 23:23
Josh Siegel's Avatar
Josh Siegel Josh Siegel is offline
lurker
#0448 (Crandroids)
 
Join Date: Nov 2003
Rookie Year: 2003
Location: Bloomfield Hills, Michigan
Posts: 67
Josh Siegel will become famous soon enough
Send a message via AIM to Josh Siegel Send a message via MSN to Josh Siegel
Re: Speed limiting code from last year in C?

Well, I just spent 18 minutes re-writing the code on here (my laptop isn't with me) and it didn't post!

I'm sorry, I'm exhausted, and I'm going to bed now, but here's what I'm trying to do, with topspeed instead of p1_wheel:


p1_wheel = (((p1_wheel*154)/254)+100) MAX 254 'adjust wheel to 154-254
IF drive_R < 127 THEN drive_R_reverse: 'is the right drive forward
drive_R = (drive_R - 127) MIN 0 'subract 127 to get the forward value
drive_R = (drive_R * p1_wheel)/254 'multiply by the wheel percentage
drive_R = (drive_R + 127) MAX 254 'add 127 back for proper output
GOTO drive_R_done: 'exit the drive right section
drive_R_reverse: 'the right drive is reverse
drive_R = (127 - drive_R) MIN 0 'invert drive-R to get a forward value
drive_R = (drive_R * p1_wheel)/254 'multiply by the wheel percentage
drive_R = (127 - drive_R) MIN 0 'invert drive_R back to normal
drive_R_done: 'drive_R section complete

IF drive_L < 127 THEN drive_L_reverse: 'is the left drive forward
drive_L = (drive_L - 127) MIN 0 'subract 127 to get the forward value
drive_L = (drive_L * p1_wheel)/254 'multiply by the wheel percentage
drive_L = (drive_L + 127) MAX 254 'add 127 back for proper output
GOTO drive_L_done: 'exit the left right section
drive_L_reverse: 'the left drive is reverse
drive_L = (127 - drive_L) MIN 0 'invert drive-L to get a forward value
drive_L = (drive_L * p1_wheel)/254 'multiply by the wheel percentage
drive_L = (127 - drive_L) MIN 0 'invert drive_R back to normal
drive_L_done: 'drive_L section complete



Edit: Okay, so I lied, I'm not going to bed just yet . I have to get this programming bug out of my system!;

Does this look like it would work? Its should be the same as above, except without the error protection (min 0/max 254)

Code:
unsigned int topspeed = 127;

if (pwm01 > 127) {
pwm01 = ((((pwm01 - 127)*topspeed)/254)+127);
}
if (pwm02 > 127) {
pwm02 = ((((pwm02 - 127)*topspeed)/254)+127);
}
if (pwm01 < 127) {
pwm01 = (127-(((127 - pwm01)*topspeed)/254));
}
if (pwm02 < 127) {
pwm02 = (127-(((127 - pwm02)*topspeed)/254));
}

Last edited by Josh Siegel : 28-03-2004 at 23:29.
 


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
Great year. archiver 1999 0 23-06-2002 22:46
Wow! what a year archiver 2000 8 23-06-2002 22:43
2000 not a new Millenium archiver 2000 7 23-06-2002 22:17
"Motors and Drive train edition" of Fresh From the Forum Ken Leung CD Forum Support 6 29-01-2002 12:32
speed control punarhero Technical Discussion 11 24-01-2002 18:03


All times are GMT -5. The time now is 06:07.

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