Encoder Commander

by TeamJaeger in Circuits > Robots

41675 Views, 302 Favorites, 0 Comments

Encoder Commander

IMG_0165.jpg
IMG_0162.jpg
IMG_0274.jpg
Control Issues - Ep 6: The Encoder Commander

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.

What You'll Need

Qty Item
9 90° Dual Side Mount (585470)
1 Attachment Blocks B (585600)
2 pattern plate (585002) (3x4 pattern)
2 pattern plate (585580) (1x3 pattern)
4 grommets for feet (636088)
1 Arduino Component Mount (585010)
1 2.5mm ID x 5.5mm OD Panel Mount Jack (163-4303)
1 DPST HD Toggle Switch (605049)
2 Momentary Square Push Button Switch (605051)
  some male header rows
2 1x4 female header rows
1 1x6 female header row
2 1x6 female header row (for the mini power rails)
  a variety of jumper wires (I like the ones from adafruit.com)
1 Arduino
2 3mm LEDs
1 Potentiometer Board A
2 10k resistors
2 220ohm resistors
  heat shrink
1 JST PHR-6 Equivalent male connector
1 18v7 Simple Motor Controller (605060)
1 laser cut motor controller mount
3 2-56 x 0.25 standoffs for mounting the motor controller (534-1801B)
6 2-56 x 3/16 screws for mounting the motor controller (91251A076)
3 dual screw plates (585472)
8 #5 washers (90126A306)
8 #6 nylon spacer (561-KSP92)
4 1" 6-32 screw (632124) for mounting the pot/motor controller assembly)
6 6-32 nuts (585474)
2 1/2" 6-32 screws (632114) for mounting the mini power rails
8 5/16 inch 6-32 screw (632108) for mounting the motor wire ports, and motor mounts
5 1/4" pan head 6-32 screw (90272A144)
16 1/4" socket head 6-32 screw (632106) for the enclosure assembly
19 3/8" socket head 6-32 screw (632110) for the enclosure assembly
1 laser cut top plate (mostly aesthetics, but it does hold the LEDs nicely)
1 laser cut side plates (optional)
1 pot 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

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:

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 :)

Build the Box

IMG_0272.jpg
IMG_0262.jpg

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

Electrical Prep

IMG_0212.jpg
IMG_0216.jpg
IMG_0221.jpg
IMG_0282.jpg
IMG_0256.jpg
IMG_3676.jpg
IMG_0231.jpg

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

Add the Arduino and Power

IMG_0258.jpg
IMG_0255.jpg
IMG_0253.jpg
IMG_0251.jpg

Add the Pot, Motor Controller, and Power Rails

IMG_0243.jpg
IMG_0240.jpg
IMG_0247.jpg
IMG_0244.jpg
IMG_0238.jpg
IMG_0218.jpg
IMG_0236.jpg
IMG_0235.jpg
IMG_0233.jpg
IMG_0192.jpg

Motor Mounts & Ports

IMG_0229.jpg
IMG_0226.jpg
IMG_0207.jpg
IMG_0203.jpg
IMG_0204.jpg

Buttons & LEDs

IMG_0214.jpg
IMG_0210.jpg
IMG_0209.jpg

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!

Finishing Touches

IMG_0185-2.jpg
IMG_0177.jpg
IMG_0178.jpg
IMG_0167.jpg
IMG_0175.jpg

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.

Test It Out

encoder-commander-animation-large.gif

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!