Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Slow down teh motors! (http://www.chiefdelphi.com/forums/showthread.php?t=52161)

jgannon 18-01-2007 13:25

Re: Slow down teh motors!
 
Quote:

Originally Posted by Alan Anderson (Post 559707)
Joey probably has it right. The pwm values are unsigned char, and it's likely that the compiler isn't accounting for the possibility of underflow when subtracting 127. If your joystick puts out 125, the result wraps around to 254, which gets divided down to 127 and shifted back up to 254 by the final addition. Forward control on the joystick will work okay, but the slightest backward movement will cause the robot to go full speed forward. Using 1-stick control, barely moving the joystick to either side will make it circle madly in the opposite direction.

Adding the cast to (int) will force the compiler to deal properly with the signed values, and everything should be okay.

Thanks for the support. I seem to remember smashing a mentor into the tool cabinet a couple years back because any input value less than 127 would send the output to 0, and thus sent the robot into full reverse as soon as I touched the joystick. I'm pretty sure that was the quick-and-dirty way of fixing it. Good luck, brennerator.

bcieslak 18-01-2007 13:27

Re: Slow down teh motors!
 
We tried the same thing with the same results last year...

Thats when we learned why the FIRST code always added 2000 calucations then subtracted it from the final result in their mix limit. It prevented sign and overflow issues.

Another project for you to consider is to ramp the motor commands to the new speed when your driver slams the stick from one direction to the other.(or pushed the button). With 26 Ms between pwm updates your motor could be commanded to go full forward at one update and then full backwards at the next up date. Your poor drive train won't last to long doing that.

Good Luck
BC

Bob22341 18-01-2007 13:41

Re: Slow down teh motors!
 
I did this a couple of days ago. here's the jist of it:

if (buttonpressed)
motorspeed = transmission
else
motorspeed = joystickinput


transmission(){
speed -= 127;
speed /= divider;
speed +=127;
}

p.s. you'll have to modify this to make it work with your robot, but this should help you. Also, in binary, division is better than multiplication for using the transmission.

{edit}
you can have the motors running through the transmission normally, and have when the buttonpressed equals transmission bypass. Have fun playing around with it.
{/edit}

Ted Weisse 18-01-2007 14:35

Re: Slow down teh motors!
 
A dead zone is a very good idea for your input controls. If you establish this zone in the input from 125-129 on each input it helps, keeps from jerking the drive back and forth. Test if the input is in the zone and if true set the value to 127, if not then the input value would be used as Full_Speed. Now set scaled values for speeds such as ½ by using the value of Full_Speed. Therefore: Half_Speed = 127 - ( 127 - Full_Speed ) / 2. You would need to do this for each side/motor. If you wanted ¼ speed just divide by 4 instead of 2 and so on. Now test for the inputs of the triggers and set the output to the desired value either the Full_Speed or Half_Speed results. This has been tested and works, hope it helps. Remember you can test for either trigger or even both to form an “AND” so you can have multiple speeds. :cool:

dcbrown 18-01-2007 21:36

Re: Slow down teh motors!
 
If using the Vector 884 speed controllers, these already have a built-in deadband from 117-137.

http://www.ifirobotics.com/victor-88...r-robots.shtml

Jimmy Cao 18-01-2007 21:41

Re: Slow down teh motors!
 
Here's a quick and simple way of reducing speed, by any factor you like (ex, 2, 3, 4, etc. Non whole numbers make the RC unhappy, it dosen't like fractions)

_NEW_VALUE_=127+((_INPUT_SPEED_-127)/_FACTOR_);

Simply replace the bold words with your variables.

brennerator 18-01-2007 23:30

Re: Slow down teh motors!
 
Thanks all!

Joey's fix worked perfectly


All times are GMT -5. The time now is 10:12.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi