Hi,
I'm trying to work on the Tribot claw open/close mechanism, and I'd like to find out how to detect when the claw has reached its limits (max open or close positions, as well as when an object is gripped).
From examining the available NXC APIs, the RotateMotor*() family of calls basically allows me to specify the angle to rotate through, but I'm not sure what happens
if/when something stops the rotation. Would the motor attempt to keep turning regardless? Could this harm the motor or gears (i.e., is the torque high enough to strip the plastic gear teeth)? How can I detect the case of no further rotation progress, and decide to halt the rotation?
Note: I'm not programming in NXC per-se, but understanding how it is done in NXC is the first step for implementing a solution.
How do I detect motor rotation hitting limiter
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: How do I detect motor rotation hitting limiter
So you have a motor that you want APR control of. You want to be able to home it's position without additional sensors.
Here is what I do:
Run the motor at low power (10-50%) unlimited, and keep reading the encoder.
Once there is no change in the encoder position over a period of like 100-250ms, I assume it's at it's physical limit.
I reset the encoder, and start the APR engine.
Here is what I do:
Run the motor at low power (10-50%) unlimited, and keep reading the encoder.
Once there is no change in the encoder position over a period of like 100-250ms, I assume it's at it's physical limit.
I reset the encoder, and start the APR engine.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: How do I detect motor rotation hitting limiter
With RotateMotor*, yes.tcwan wrote: From examining the available NXC APIs, the RotateMotor*() family of calls basically allows me to specify the angle to rotate through, but I'm not sure what happens
if/when something stops the rotation. Would the motor attempt to keep turning regardless?
It can't hurt the motor's internal gears. But depending on your gear reduction, it can indeed break LEGO gears, yes (even though it happens very very rarely). Usually the parts pop out / the model falls apart first.tcwan wrote: Could this harm the motor or gears (i.e., is the torque high enough to strip the plastic gear teeth)?
What happens depends on whether you use speed regulation, REG_MODE_SPEED, or power control (different names for one same thing). If you use it, and the motor gets stuck, the firmware will increase power, and hence torque.
In situations like this, I'd usually not use speed regulation, and a lower power level, to get constant torque (as opposed to constant speed with speed regulation, which might increase torque dangerously).
Manually, there are many ways, I suggest the one mattallen said.tcwan wrote: How can I detect the case of no further rotation progress, and decide to halt the rotation?
You can also use IO map module commands (maybe there is an NXC alias for it) to get the value for "ActualSpeed". This value is used from the firmware when you enabled speed regulation (REG_MODE_SPEED). Once the motor blocks / speed decreases, the power level will be increased by regulation (what I called dangerous above). But you can monitor this using ActualSpeed. So you could use this as indicator when to stop and release the motor.
There's also a field / flag inside the output module called Overload. The firmware sets it once the ActualSpeed reaches 100, i.e. once the motor can't compensate the increased load on the axle just by increasing the power level anymore... IIRC then this Overload stays "on" once reached once, and you have to reset / clear it manually (maybe this works by resetting all counters, don't remember).
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
Re: How do I detect motor rotation hitting limiter
Hi mattallen37 and linusa,
Thanks for the suggestions. Seems like there is a need for some (new) library functions for solving this kind of problems even in NXC.
There is no Power Regulation in NxOS so mattallen37's suggestion seems the easiest to implement for now.
Thanks for the suggestions. Seems like there is a need for some (new) library functions for solving this kind of problems even in NXC.
There is no Power Regulation in NxOS so mattallen37's suggestion seems the easiest to implement for now.
Re: How do I detect motor rotation hitting limiter
Here is a great example of how it's done in NXC - copied from the Version 2 of Tilted Twister:
Basically it sets TachoPrevious to equal the real tacho count each loop and only continues if they are different. When they are the same it stops. They can only be the same if the motor stops turning and the tachoNow doesn't increase any more, and the tacho previous "catches up".
In the robot design, the elements that are designed to stop the motor rotating at it's limit point are build robustly so there is no play in the mechanism. It works very will and I'm considering including it in my current project.
void InitTurntable()
{
int tachoNow,tachoPrevious;
OnFwd(OUT_A,15);
do
{
tachoPrevious=tachoNow;
Wait(100);
tachoNow=MotorTachoCount(OUT_A);
}while(tachoNow!=tachoPrevious);
Coast(OUT_A);
Wait(500);
ResetAllTachoCounts(OUT_A);
Wait(500);
currentAngle=0;
}
Basically it sets TachoPrevious to equal the real tacho count each loop and only continues if they are different. When they are the same it stops. They can only be the same if the motor stops turning and the tachoNow doesn't increase any more, and the tacho previous "catches up".
In the robot design, the elements that are designed to stop the motor rotating at it's limit point are build robustly so there is no play in the mechanism. It works very will and I'm considering including it in my current project.
void InitTurntable()
{
int tachoNow,tachoPrevious;
OnFwd(OUT_A,15);
do
{
tachoPrevious=tachoNow;
Wait(100);
tachoNow=MotorTachoCount(OUT_A);
}while(tachoNow!=tachoPrevious);
Coast(OUT_A);
Wait(500);
ResetAllTachoCounts(OUT_A);
Wait(500);
currentAngle=0;
}
Who is online
Users browsing this forum: Semrush [Bot] and 3 guests