Reputation: 11
I need to code a DC motor w/ encoder to turn a certain amount CW and then to return to its original position CCW. I know stepper motors can do this easily but for my application I need to use the DC motor. Is this possible? I have the encoder reading values whenever I manually turn the gear (ex: 250 corresponds to a value when turned CCW, -50 corresponds to a value when turned CW, everything is relative to the starting position). I want the motor to be able to reach position 50 (so it will always turn to that position on command, and then be able to return to the initial position).
Upvotes: 0
Views: 788
Reputation: 28974
You'll either need an absolute encoder an incremental encoder with some way to reference your zero position.
Then you'll have to count the encoder steps. I'd recommend a dedicated IC or MCU to do this job as you'll otherwise lose encoder signals even when using interrupts.
The encoder allows you to know the actual position.
Then you need a way to control the motor in both directions and ideally a brake.
The last thing you need is to implement a control. PID for example which allows you to tell the motor in which direction and how fast to turn in order to reach and then maintain the target position.
Upvotes: 1