Gear Motor with position and direction control


I am building a a circuit using a Micro Gear motor with a 12 CPR encoder. I am trying to control this motor using two buttons ( one for counter clockwise and one for clockwise). What I am trying to accomplish is a circuit that will allow me to control how far the motor rotates under one button press ( for example with one button press I get a 3 degree clockwise turn and pressing the other button would get me a 3 degree counter clockwise turn)

Any help is appreciated!!!!!

You need a position control feedback loop. The button presses should be changing the position setpoint, and the control loop bringing the encoder count to match the setpoint probably using PID method. Control loops are everything in position control.

The first steps are getting the encoder read correctly, and turning button presses into setpoints - those can both be done and tested before trying to tie everything together.

Thanks for responding Mark! I have a separate circuit that has a working mechanism of the two buttons controlling the motor. This circuit is not connected to an arduino. I'm having some confusion as to how to connect my encoder. Should it go through my circuit or separately to the arduino or should I change my circuit to function using Arduino?

If you bought your motor/encoder from Pololu, take a look at the software examples they provide for their encoders.

Actually its probably worth looking at them anyway!

What do you guys mean by software examples. I'm on the pololu site, I see schematics for the encoder but I don't see software examples.