Indexing a gearmotor with Arduino

ben5017, Tue Oct 14 2014, 01:15PM

I am trying to write a code to index a gear-motor (continuous rotation servo) a set number of degrees with an encoder.
This will be used to control the "drum magazine" on my coilgun project

board is an Arduino Mega 2560

encoder has following pins A, A', B, B', Z, Z'
gear-motor has standard servo connection v+, v-, and white

below is the sequence and goals of the program.

1) have a set "home" position that will initially align the mechanism when turned on
2) read state of button, when pressed....
2a) rotate the servo a set number of degrees (360/13) (13 position indexer)
2b) stop and hold servo at set position.
2c) repeat every time button is pressed
3) have a time limit to reach position so that if there is a jam it will (hopefully) not burn out the servo

I have some experience with writing code for the Arduino, however basically none with encoder and motor control, I need a working example to play around with but have been unable to find one online.

I am at work right now but later i can post data sheet on the encoder as well as a little more information about my project to get some of you guys motivated to help me
1413292504 3315 FT0 Coilgun
Re: Indexing a gearmotor with Arduino
Conundrum, Mon Nov 03 2014, 07:45AM

Aren't these Gray coded?
IIRC the code always changes one digit on each rotation step, the idea is that you have an absolute reference if you have a copy of the code in memory.