Quote:
|
Originally Posted by ForgottenSalad
EDIT: Ah, abw and sanddrag... beat me to it
The limit switch looks something like this.
You'd have to mount one at the far right and one at the far left to constrain the turret's movement. You'd then have to add those two lines of code and it should stop the motor when it hits either the far left (min) or far right (max) switch.
And as far as using a potentiometer, maybe there's a better way to do it, but I find it much easier for purposes of limiting motor movement to use the switches. Problem I had with the pot was getting instant stopping of the motor and sometimes the pot's base would turn with the motor, instead of just the bar turning, and it'd return feedback that was off and become useless for it's purpose. I find pots better for when you need to work with things along the motor's rotation, not for just stopping the motor at the ends.
|
If you use a pot, you can either set the limit to be some tolerance away from the real max you want (motor overshoot accounting for that tolerance), or use a feedback loop that deadens the motor response the closer it gets to the tolerance. Either way, or with a limit switch for that matter, a mechanical stop is recommended.