So we are building a similar intake design to the 118 everybot and we’re using NEOs and Spark Maxes to lift the intake into position. Is it possible to check the current of the Spark Max and when it gets too high, stop the motor because it has hit the bounds where the intake can lift to? Something like this:
if (Lifter.getOutputCurrent() == too high) {
indexer.set(0);
} else {
indexer.set(1);
}
It IS possible but it is not usually desired. The current data is noisy and dependent on mechanical forces like friction as well, and by the time you see the current spike it is usually well past the point you should have stopped. Usually a better option is to either set the current limiting on the motor so that it cannot harm the mechanical components, or use the built in position monitoring in the motor.
Can you point me at some docs for this? I don’t quite understand how this would work. Wouldn’t you end up stalling the motor at the hard stop unless you also detected that the motor wasn’t rotating and turn off the power?
Current Limiting is a function we have built into our motor controllers, so whatever current limit you set, it will adjust the power output to never go above that setpoint. (yes this does effectively de-rates the motor performance at stall)
Yes you would be stalling it, however you can adjust the stall current so that it is low enough that it does not harm the motor. Unfortunately, I program in labview so I do not know the pertinent commands.
Thanks, but would this be an effective way to handle a hard limit as the OP asked? If I understand correctly, @Tom_Line is suggesting to set a current limit that will be exceeded when the mechanism hits the hard limit. I believe this would turn the motor off for the kCurrentChopCycles period, and then it would turn it back on.
I don’t think this is an effective way to avoid installing a limit switch or absolute encoder. The idea of watching for velocity to stop/slow below a threshold seems like a better workaround.
The current limit allows your mechanism to hit the hard stop without destroying itself - or the hard stop. You could measure velocity - but again, by the time you’ve decelerated you’ve already slammed into your hard stop and destroyed it if you’re applying too much power.
Limiting both max velocity and motor output to prevent mechanical damage would be an acceptable solution. Motion control would be ideal. Limiting the current so it simply can’t hurt itself is easiest.
You may find that based on the momentum or gearing involved it’s impossible to effectively limit current enough to prevent damage, in which case motion control is really your only solution.