![]() |
Save the Gearbox, Save the Game
Chantilly Academy Robotics Team 612 has developed code that slows the wear on the kit-of-parts planetary gearbox.
The code gradually changes the speed based on the joystick value. NOTE: in this code, pwm01 is the left side, pwm02 is the right. This also assumes that you are using 2 joystick drive, with the left joystick Port 1 on the Operator Interface, and with the right joystick on Port 2 on the Operator Interface. Here it is: /***** Put these lines of code into user_routines.c at the top *****/ #define aRate 3 //This is the rate at which the motor speeds up #define dRate 8 //This is the rate at which the motor slows down void accelR(int); //method explained below void accelL(int); //method explained below /***** This goes with the above *FUNCTION NAME: accelL *PURPOSE: to gradually increase or decrease motor output on pwm01 *CALLED FROM: user_routines.c *ARGUMENTS: num, the input target value for the motor output *RETURNS: void *****/ void accelL(int num) { static int leftMotorTemp = 127; if(pwm01 >= 127) { if(num > leftMotorTemp) leftMotorTemp += aRate; else if(num < leftMotorTemp) leftMotorTemp -= dRate; } else if(pwm01 < 127) { if(num > leftMotorTemp) leftMotorTemp += dRate; else if(num < leftMotorTemp) leftMotorTemp -= aRate; } if(leftMotorTemp > 255) leftMotorTemp = 255; else if(leftMotorTemp < 0) leftMotorTemp = 0; pwm01 = leftMotorTemp; } /***** This goes with the above *FUNCTION NAME: accelR *PURPOSE: to gradually increase or decrease motor output on pwm02 *CALLED FROM: user_routines.c *ARGUMENTS: num, the input target value for the motor output *RETURNS: void *****/ void accelR(int num) { static int rightMotorTemp = 127; if(pwm02 >= 127) { if(num > rightMotorTemp) rightMotorTemp += aRate; else if(num < rightMotorTemp) rightMotorTemp -= dRate; } else if(pwm02 < 127) { if(num > rightMotorTemp) rightMotorTemp += dRate; else if(num < rightMotorTemp) rightMotorTemp -= aRate; } if(rightMotorTemp > 255) rightMotorTemp = 255; else if(rightMotorTemp < 0) rightMotorTemp = 0; pwm02 = rightMotorTemp; } /***** Put this into Process_Data_From_Master_uP accelL(p1_y); Changes left side based on left joystick y-value accelR(p2_y); Changes right side bases on right joystick y-value //End of code What this code does is gradually change the speed. This will do several things:
Our driver really likes the code, so we will keep it after FIRST sends out the fix. Sorry about the edit. We have several versions of the same code floating around. |
Re: Save the Gearbox, Save the Game
Interesting idea. Thanks for the code!
One question. Is their any lag having to do with speeding up and slowing down so much? |
Re: Save the Gearbox, Save the Game
I believe that the problem with the carrier plate will come about from shock loads. Software will not help with that. Properly engineered materials will.
|
Re: Save the Gearbox, Save the Game
The shock load comes about because of the sudden reversal of direction of the motor...the motor is under software control.....please think about it....
|
Re: Save the Gearbox, Save the Game
Interesting.
You could also write this as 1 function by passing the joystick & pwm by reference to your acceleration function. Also, there is nothing wrong with modifying the pwm output variable directly, since the actual pwm output value isn't changed until the Putdata() in Process_Data_From_Master_uP(). What happens if the joystick input is 5, your current pwm output is 8, and it decrements the pwm output by 12? At first glance it looks like your temporary value would go negative. I could be wrong though :ahh: |
Re: Save the Gearbox, Save the Game
Thanks for posting this code. I think this is a very simple fix that will be very helpful for teams using the BaneBots gearboxes. With everyone working on materials fixes, it's easy to forget the simpler ways to alleviate the problem.
Another suggestion: Keep your chains in tension. Any backlash will increase impulsive loading a lot. |
Re: Save the Gearbox, Save the Game
Depending on your gearing, you can change the aRate and dRate. 8 and 12 worked well for us. Feel free to change it to suit your needs.
To get more responive braking, put the Victor jumper on "B", the inner 2 pins. This will cause the robot to actually stop after you tell it to. About the negative or >255 pwm outputs, you can put a limiter on the temporary pwm. something along the lines of (* is wildcard): if (pwm**temp > 255) pwm**temp = 255; else if (pwm** < 0) pwm** = 0; If the bad pwm's give you a problem, put these lines of code before the pwm assignment, but after the if/else block, replacing th *'s with the approprate number. |
Re: Save the Gearbox, Save the Game
Quote:
This goes in a .c file: Code:
/*******************************************************************************Code:
//example to call function |
Re: Save the Gearbox, Save the Game
Very nice, you might also want to look in to using PID to attain certain speeds, with low P gains it would ramp up and adjust to speeds gently.
Also, you can use [code] tags to neaten up your posting and make it easier to read. Also, do you like Heroes? ;) |
Re: Save the Gearbox, Save the Game
We at MARS have our own acceleration code, written by your's truly. It's very simple, and it didn't take too long to type up. We use different acceleration rates for autonomous mode and human control. Here it is:
Code:
//these two variables are declared at the top of user_routines_fast.cCode:
pwm03 = Motor_Accel(p1_y, pwm03);EDIT (#2): Turning seems to be a problem, since the acceleration rates make it hard to shift from one side of 127 to the other... |
Re: Save the Gearbox, Save the Game
2 robots collide head on with each going 6 FPS. The shock and stress to the drive train will happen and software will not protect against this. Too many shocks and some thing fails. The baines bot carrier plate is 1 point of failure. The gears are a concern of mine. Yes, they are hard, but can they endure the stress that some teams inflict on their drive trains. Planetary gear boxes have some pluses. They also need higher strength and precision than the plate and gear sandwich gear boxes like the Andy Mark's. Our team is playing it safe with the AM solution and will watch the BB story unfold. Good luck to the teams that are going with the BB's. Train your drivers not to smash into objects at full speed. As a side note, The power tools and equipment that I have at work and has survived my constant abuse for years and years do not have planetary transmissions.
|
Re: Save the Gearbox, Save the Game
First off, great work 612. Our neighbors down the street keep continuously trying to make life easier for other teams, and helping out FIRST.
This is a great way to try and prevent your own robot from damaging your Banebots transmissions, but, as mentioned, it does not protect from outside forces, so be wary. It may or may not impede impulses enough to prevent damage when using 2 CIMs, but it will certainly mitigate the damage. Basically, a word of caution, this is a great start on saving your transmissions, but it isn't perfect (no solution will be), and there will still be certain risks imposed upon your transmissions. |
Re: Save the Gearbox, Save the Game
We put a low-pass filter on the motor speed command almost every year. A more compact way to accomplish this follows. Note that you can (and I always do) use integers for the fractional part, but it's quicker to show you what's going on with floats:
Code:
// Put this at the top of "user_routines.c" |
Re: Save the Gearbox, Save the Game
Quote:
The concept is right but might I suggest a better execution? Code:
// Put this at the top of "user_routines.c" |
Re: Save the Gearbox, Save the Game
Quote:
Code:
pwm01 = (unsigned char) (K_LP * pwm01 + (1.0 - K_LP) * pwm01_old);The epression: Code:
(unsigned int)((K_LP*pwm01)/10)Code:
(unsigned int) K_LP * pwm01 / 10Your expression: Code:
temp_pwm01 = (unsigned int)((K_LP*pwm01)/10) +Code:
pwm01 = (unsigned char) ((unsigned int) K_LP * pwm01 +Code:
#define ((unsigned int) 2) K_LP |
Re: Save the Gearbox, Save the Game
Quote:
Let's say your robot is driving forward, and another robot hits yours head on. There is no direction reversal at the DD joint. Now let's say your robot is driving forward slowly, and it is hit from behind by another robot. There is a direction reversal at the DD joint, but also the impact at the DD joint is softened considerably by some things. These include the fact that the other robot will share it's momentum with yours, so that it must accelerate the mass of your robot, and this takes time and absorbs energy. Also the load will be distributed among more than one wheel/transmission, so it is not all concentrated at one point. And there is some give in the chain drive system, assuming you are using a chain drive. In a sudden motor reversal situation, the inertia of what's connected to the transmission output shaft is higher than the inertia of the transmission gears/motor armature, and there is also a large torque multiplication and speed reduction supplied by the transmission. From the instant the motor changes direction, it can turn quite a ways at full torque as it takes up the slack in the transmission gears (and DD joint), and it can gain a considerable amount of rotational inertia before it finally slams the DD joint against the other side. From the pictures of damaged plates, it looks to me like this is what is causing the problem. I really would like to see the results of some driving tests on DD joint wear with software motor acceleration control. I think it might be more helpful than some folks realize. |
Re: Save the Gearbox, Save the Game
Quote:
|
Re: Save the Gearbox, Save the Game
Quote:
|
Re: Save the Gearbox, Save the Game
We dismantled out gearboxes yesterday, after about 2 hours of use, and found very little distortion on the end plate.
Our acceleration-limiting software is doing its job. |
| All times are GMT -5. The time now is 22:19. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi