Introduction: 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.
Step 1: What You'll Need
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:
Attachments
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!
9 Comments
4 years ago on Step 10
Wiring diagram is not visible for me; I just see an ad for library.io
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
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
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.
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)?
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
Reply 7 years ago
Whoops! I didn't notice that. Thanks for your answer :)
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.
7 years ago
This is really cool!
Thanks for sharing