more fun with motors...

Hello again everybody.

My robot weighs just over 20 pounds, and is run by 4 393 motors on the drive base attached by chain to the wheels. The ratio is 1:1. These 4 motors are also plugged into a power expander so they can be run from a second battery.

The question is this:

Should I program a function that allows me to accelerate to full speed (in driver control) instead of starting at that speed? If so, how would I do that in easy C?

If you really wanted to, you could just gradually increase the speed on the joysticks manually or, something like this may work.

int joy;
int motor;

joy = GetJoystickAnalog(1,3); // store the analog value from the joystick
for (motor = 0; motor < joy; motor += 10)
/* continually adds 10 to the motor speed untill it reaches the input from your joystick */

// please pardon any syntax errors but, you should be able to get the general idea

Another option is to average the past several values of the joystick.


int joy1 = 0;
int joy2 = 0;
int joy3 = 0;
while(true){//Driver Control loop
  joy1 = joy2;
  joy2 = joy3;
  joy3 = Joystick;

  int average = (joy1 + joy2 + joy3) / 3;

  motor = average;

Please see this wonderful bit of code posted by jpearman. It really works. We have two of our teams on this now and we’ve had fewer motor burn outs since. Adjust that slew rate per time slice per motor as necesssary. You hardly notice it at all but it’s not slamming the motor so much with a sudden 127!

You might just want to tackle user control code first sicne it’s typically easier. So start the task in user control, then use the variable motorReq] versus just motor]. Should take you under an hour to do this. Getting it in all your autonomous functions might take longer. Setting any of the motor] values without using motorReq] will cause the two routines to fight each other as you will find out as you debug it.

Slightly different than the post above, this adjusts the range for your joystick. See this other bit of code from Quazar. You still get to 127 but in between you have much finer motor control. Having a button send it to half or 1/3 power is another trick but you don’t get back to 127 then. Up to you on your strategy really.

Thanks for posting this link to an earlier thread, I hadn’t seen it and I’m going to have our students use this code to hopefully help with their tendency to jam the joysticks from full forward to full reverse instantly.