Motor programming

Hey guys. Is there a command you can type on RobotC to make a motor lock. At a speed of zero, I can still move the motor.

Technically you could make a function like this…


task main()
{
     void motorLock()
     {
     motor[motorname] = 10;
     }
}

Set the power level to the highest you can without having the motor move. Then you would just call out that void anytime you needed it and it will supply power to the motors to where they are getting held up but they aren’t moving. This, however, won’t work if you call it out at the end of autonomous and you want the motor to “lock” at the end of the autonomous period because the competition template turns off all motors when the competition control gets disabled.

Btw. As far as I know there isn’t a built-in function to “lock” motors in place.

Well the built in PID works like that. You just need a sensor to know when the motor is moving to properly lock a motor.

Be aware that you can power a motor in a stall condition (powered but not moving against a load) at a motor value of maybe only 10 to 20 indefinitely, but above that, you are risking the motor overheating and tripping its PTC, which will effectively shut down the motor. If the PTC is tripped, then the motor will not be able to hold any load at all, except for whatever tiny load it can hold due to the friction of its internal gears.

There is no mechanical lock in the motors. What Tabor was saying about a PID sensor loop is that the motor could be powered to “fight” against any force that tries to move it from a particular set position. But this could potentially overheat the motor if the required motor values commanded by the PID loop are running above about 10 to 20 (depends on the motor).