I'm programming a robot that has limited travel on one of its articulations. I don't require precision on its position, just that it stops the motor as soon as it hits the limit.
NXC has the MotorOverLoad function, which appears to do exactly what I want... however, it always returns "false" even if the motor is completely stalled! Digging a bit, I found that MotorOverload is actually a shortcut for one of the fields of GetOutput (like "GetOutput(OUT_A, OverloadField)"). Checking the field's documentation, I see that, for it to work, I need to set the motor according to numerous parametres... but, after setting them, I can't get the motor to actually run!
This is what I wrote to get the motor running, while hopefully enabling MotorOverload:
Code: Select all
SetOutput(
OUT_C,
RunStateField, OUT_RUNSTATE_RUNNING,
OutputModeField, OUT_MODE_MOTORON + OUT_MODE_REGULATED,
RegModeField, OUT_REGMODE_SPEED,
PowerField, power_C * d);
Code: Select all
if(MotorOverload(OUT_C))
Stop(OUT_C);