My Son is building a robotic arm for a science competition. We need to get a hard brake on the motor. I found the example below to brake and hold the motor arm in place.
However, when I execute the code, the motor does not stop completely. It actually does a small back-and-forth rotation and then stops. We need it basically to stop immediately, and
not rotate at all, with a load on it. Any suggestions, please?
Active braking
This will actively hold the motor at its current position (and act against forces which try to move it). This consumes a lot of power. The NXC-code to do this is:
If it's overshooting, then try tuning the PID parameters. Sound like the D needs to be turned up a bit.
Re: NXC and Braking
Posted: 18 Feb 2012, 21:34
by lamikam
Thanks, I am a total newb. How does one set the PID value(s)?
Re: NXC and Braking
Posted: 18 Feb 2012, 21:48
by lamikam
OK, I think I added the PID values, and used various combinations of PID_0 to PID_7 values, but do not see any difference. See this youtube video of the problem
It would be helpful to see what you are doing before you apply the brakes. Have you looked at the routine I posted in a thread here that implements ramp up and ramp down before braking?
The bottom line is that if you are running the motor at full power or 75% power and it is still running at a high power level when it arrives at the desired stopping point then braking at that tachometer position will result in the sort of oscillation you are seeing. That's because the brake is applied at a position and the regulation is trying to maintain the speed at that position. It will initially overshoot the position and the PID control routine built into the firmware will power the motors to restore the position at the 0 speed/power specified.
If you are creating a robotic arm you could try to design your mechanism to work with lower power levels, which will help, or you can write your motor control routines to ramp down as it approaches the desired tachometer position before you finally apply the brakes at the position.
John Hansen
Re: NXC and Braking
Posted: 19 Feb 2012, 02:18
by lamikam
Thanks, do you have a link to that thread? Unfortunatly, the way my son built the arm, this motor needs > 75% power.
Re: NXC and Braking
Posted: 19 Feb 2012, 02:22
by lamikam
John, I did a search for your posts, but did not find one with the ramping code.
Thanks,
Leor
Re: NXC and Braking
Posted: 19 Feb 2012, 05:15
by h-g-t
I have been searching for a while and all I can find is a reference under 'Output Port Constants'
#define OUT_OPTION_RAMPDOWNTOLIMIT 0x20
but have no idea how to set that up for a particular motor.