Motors freezing up

5 replies [Last post]
amehta
Title: NooBot
Joined: 07/18/2011
Posts:
BotPoints: 136
User offline. Last seen 5 years 32 weeks ago.

Hello all,

We were running our robot and in the middle of it, the motors froze. We picked the robot up, and the motors were locked. Here is the snippet of the code I'm using:

  1. gomotors(LEFT_MOTOR_PORT, RIGHT_MOTOR_PORT, 1000, 2000);
  2. gomotors_diffspeed(RIGHT_MOTOR_PORT, LEFT_MOTOR_PORT, 300, 300, -1500, -1500);
  3. gomotors_diffspeed(RIGHT_MOTOR_PORT, LEFT_MOTOR_PORT, 0, 500, 0, NINETY_DEGREE_TURN_CONSTANT_CBCBOT_PIVOT);
  4. gomotors(LEFT_MOTOR_PORT, RIGHT_MOTOR_PORT, 400, -1000); //<--This is where the code stops working
  5. gomotors(LEFT_MOTOR_PORT, RIGHT_MOTOR_PORT, 750, 300);
  6. gomotors_diffspeed(RIGHT_MOTOR_PORT, LEFT_MOTOR_PORT, 500, 0, NINETY_DEGREE_TURN_CONSTANT_CBCBOT_PIVOT, 0);

And here's the function definition (and no, I didn't forget to define the variables or the #defines):

  1. void gomotors(int leftmotor_port, int rightmotor_port, int speed, int distance)
  2. {
  3. m = get_motor_position_counter(leftmotor_port);
  4. j = get_motor_position_counter(rightmotor_port);
  5. mtp(leftmotor_port, speed, m + distance);
  6. mtp(rightmotor_port, speed, j + distance);
  7. bmd(leftmotor_port);
  8. bmd(rightmotor_port);
  9. }

The weird thing is that this function works (I've used it in years past) and it still works in this program, it's just this one line that doesn't work.

-amehta (Andrew Mehta)

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 18 weeks ago.

I'm not really sure why your motors would freeze, but a few things come to mind. Have you tried mrp instead of mtp? (I don't trust mtp....) Also, what happens if while the motors are locked, you jiggle the motors from side to side a bit? (The CBC motor controller sucks, and sometimes erroneously locks motors until you physically jiggle the motor... if I were KIPR, I would have just used libxrc's motor controller, which has way more features and doesn't have that problem -- the CBC issue is caused by the lack of a trajectory generator.)

Sorry I'm not much help....

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

amehta
Title: NooBot
Joined: 07/18/2011
Posts:
BotPoints: 136
User offline. Last seen 5 years 32 weeks ago.

It's ok...

For future teams that have this same problem:
-Yes, we tried jiggling the motors, didn't work.
-I don't trust mrp, I had a bad experience with it and I just don't like it... So I use mtp and add the current value (hence the variables). Yes, it's complicated, but it works (up until now)

We think it might have to do something with the low battery. This doesn't happen every time, just sometimes. And when it happens, it's usually when the battery is low.

Thanks though.

-amehta (Andrew Mehta)

amehta
Title: NooBot
Joined: 07/18/2011
Posts:
BotPoints: 136
User offline. Last seen 5 years 32 weeks ago.

But if anyone knows what the problem is, it would be helpful just in case our battery is low, or the battery isn't the problem. Thanks in advance.

-amehta (Andrew Mehta)

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 18 weeks ago.

Is this happening with only 1 CBC or have you tried different CBC's? I have on occasion had really weird bugs with programs on a CBC, and it turned out that the CBC was bad.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

amehta
Title: NooBot
Joined: 07/18/2011
Posts:
BotPoints: 136
User offline. Last seen 5 years 32 weeks ago.

We haven't tried it on another CBC, no... Thanks for the advice.

-amehta (Andrew Mehta)