Encoder Commander

41,296

301

9

Introduction: Encoder Commander

About: I work at RobotZone ( the folks behind Actobotics and ServoCity.com ) in Winfield, KS. I love working on projects with my kids and seeing what they create.

The Encoder Commander is a project I made to make it easy to work with motors with quadrature encoders.

The idea will be to plug a motor with encoder in and turn it on. Initially it will be in speed control mode so the big knob will control the speed and direction of the motor. So far not terribly exciting... just a speed controller with an analog input. But you can use the speed control to get the motor into the position you want for the first endpoint, press the endpoint A button, then get the motor into the position you want for the second endpoint and press the endpoint B button and Bob is your mother's brother, you are now in position control mode and the knob will move the motor back and forth proportionally between the endpoints you've set up.

It is worth noting that while you can plug two different styles of motor into the Encoder Commander, it is designed to only have one motor plugged in at a time.

Step 1: What You'll Need

QtyItem
990° Dual Side Mount (585470)
1Attachment Blocks B (585600)
2pattern plate (585002) (3x4 pattern)
2pattern plate (585580) (1x3 pattern)
4grommets for feet (636088)
1Arduino Component Mount (585010)
12.5mm ID x 5.5mm OD Panel Mount Jack (163-4303)
1DPST HD Toggle Switch (605049)
2Momentary Square Push Button Switch (605051)
some male header rows
21x4 female header rows
11x6 female header row
21x6 female header row (for the mini power rails)
a variety of jumper wires (I like the ones from adafruit.com)
1Arduino
23mm LEDs
1Potentiometer Board A
210k resistors
2220ohm resistors
heat shrink
1JST PHR-6 Equivalent male connector
118v7 Simple Motor Controller (605060)
1laser cut motor controller mount
32-56 x 0.25 standoffs for mounting the motor controller (534-1801B)
62-56 x 3/16 screws for mounting the motor controller (91251A076)
3dual screw plates (585472)
8#5 washers (90126A306)
8#6 nylon spacer (561-KSP92)
41" 6-32 screw (632124) for mounting the pot/motor controller assembly)
66-32 nuts (585474)
21/2" 6-32 screws (632114) for mounting the mini power rails
85/16 inch 6-32 screw (632108) for mounting the motor wire ports, and motor mounts
51/4" pan head 6-32 screw (90272A144)
161/4" socket head 6-32 screw (632106) for the enclosure assembly
193/8" socket head 6-32 screw (632110) for the enclosure assembly
1laser cut top plate (mostly aesthetics, but it does hold the LEDs nicely)
1laser cut side plates (optional)
1pot knob (optional)
Last but not least pick the motor with encoder that is right for you:
Heavy Duty Planetary Gear Motor with Encoders
Planetary Gear Motors with Encoders

Step 2: About PPR, CPR & Quadrature (Incramental) Encoders

I've put together this PDF to help understand the difference between PPR and CPR and understand what the usable resolution at the output shaft will be.

Also if you want to learn more about incremental encoders I'd steer you towards this great video:

Step 3: Deploy the Code

I like to deploy the code to the arduino first (even if it is just a blank sketch to start with). If I connect things to the arduino and there happens to be a sketch from a previous project on it, it could yield undesired results when powered on.

BTW have I mentioned how much I love codebender.cc? Seriously if you have not used it, go check it out and come back. Edit: I just learned that if you create a codebender account using this link I might someday earn a t-shirt :)

Step 4: Build the Box

I'll go ahead and let the photos do the talking. Most photos in this instructable have annotations - click the photos to see them.

Step 5: Electrical Prep

I like to get all the bits in order. Again click the photos for the notes.

Step 6: Add the Arduino and Power

Step 7: Add the Pot, Motor Controller, and Power Rails

Step 8: Motor Mounts & Ports

Step 9: Buttons & LEDs

Step 10: Wire It Up

I want to give a shout out to the folks at 123D Circuits for their help! Thanks to them the motors (with encoders) as well as the motor controller I used are now in the 123D Circuits component library!

Step 11: Finishing Touches

Now that you are all wired up you can go ahead and attach the top and sides.

While I was in the process of building & testing it I actually attached the top via a hinge rather than hard mounting it.

Step 12: Test It Out

Go ahead and test it out. Quadrature encoders are incremental encoders. You can think of them as counting up or down depending on which way the motor is turning. If you get into a runaway state (the motor spins forever never reaching the target) it is probably because the motor or the encoder channels are connected backwards. This would be like saying "OK you are at 10, now count backwards until you get to 20". Either reverse the motor + & - or reverse the encoder channels A & B and you should be good to go.

Also reversing the two reference (non-wiper) wires on the pot will change which direction the motor spins relative to the direction of the pot.

Happy Commanding!

Be the First to Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • For the Home Contest

      For the Home Contest
    • Make It Bridge

      Make It Bridge

    9 Comments

    0
    DerrickS22
    DerrickS22

    5 years ago

    Love the build, but would this also be possible with a dual "H" Bridge instead of the simple controller? I'm looking at converting an old wide format printer to cut rolls of vinyl into sheets, i already have a dual H board and the cost of the simple motor controller is not justified just to test the motor/encoders.

    Any advice would be greatly accepted as just learning to code with Arduino.

    Regards

    Smiler

    0
    jed2k
    jed2k

    6 years ago

    I am building a camera slider. This would be a perfect control for it. However, is it possible to add a "run" feature? For ex.: set end points, set desired travel speed, then hit a button (or a DPDT rocker) and the camera will move from point A to point B on its own. And obviously stop at point B. You could then set the rocker to opposite throw to return to point A. Is this possible?

    I have no trouble with mechanics and fabrication (35 years exp), but am completely new to small electronics, Arduino, etc.

    Really enjoying your site(s), videos, and past orders from Servocity (built tilt/pan rig previously).

    Thanks for your consideration.

    Regards,

    JED

    0
    TeamJaeger
    TeamJaeger

    Reply 6 years ago

    Hi Jed, The short answer is "yes" it certainly would be possible.

    Just about everything you want is already there is some form. Adding that functionality would mostly be a matter of copy/pasting and making a few minor adjustments.

    An SPST (as opposed to a DPDT) toggle switch or rocker would be sufficient to toggle between two endpoints. Codewise it would be exactly the same as the latching pushbuttons. So you could simply copy/paste the code for the latching pushbuttons to add a third "button". Then you could simply modify the POSITION_CONTROL mode. The main difference is how the target is set (line 104). If the toggle switch is high, then you would set the target to position1, else you would set the target to position2.

    0
    Saiyam
    Saiyam

    7 years ago

    Wow, amazing idea! Your documentation is more that perfect!

    Just a question. I see that you mounted your arduino on metal base. So wasn't there a problem (I mean short circuiting and all)?

    0
    TeamJaeger
    TeamJaeger

    Reply 7 years ago

    Good question. It is hard to see in the photos, but the Arduino is actually mounted to a plastic Arduino Component Mount which is then mounted to the base. https://www.servocity.com/html/arduino_component_mount__58501.html#.VnceeeODGko

    0
    Saiyam
    Saiyam

    Reply 7 years ago

    Whoops! I didn't notice that. Thanks for your answer :)

    0
    stringstretcher
    stringstretcher

    7 years ago

    Great instructable! I have some plus motors like these but did not understand where to start with them. This will help me a lot! Thanks.

    0
    electrowiz89
    electrowiz89

    7 years ago

    This is really cool!

    Thanks for sharing