Introduction: Arduino Lens Controller - Synchronized Zoom/Focus With Wii Classic Controller

Picture of Arduino Lens Controller - Synchronized Zoom/Focus With Wii Classic Controller
My Lumix GH2 Micro Four Thirds camera not only shoots fantastic high definition videos, but with inexpensive adapters I can use it with older manual lenses that are cheap and often very high quality. I shoot a lot of performance videos for my daughter's dance studio, and I use an f3.5 Nikon 28-85mm zoom lens because it provides a good zoom range and a fast aperture for a zoom lens. The problem with this setup is that I have to zoom and focus the lens manually, and though I try to minimize zooming while shooting, there are times when it is essential for maintaining proper framing and for showing off the dancers' skills. I've managed to learn to zoom manually without introducing excessive camera jitter (usually), but since I am also focusing manually, it's a bit of a chore to quickly and smoothly adjust the focus after zooming in or out. To overcome this shortcoming I decided to build a power zoom and focus controller for my camera (which many others have done), with the critical goal of being able to automatically maintain the proper focus as the lens smoothly zooms in and out.  After many months of prototyping I arrived at a great solution that uses an Arduino clone that accepts input from a Wii Classic controller, and which uses 2 hobby servos to move the lens. The total cost of the final product is less than $100.


The design that I eventually implemented has a number of advanced features:
- 2 joysticks provide continuously-variable speed lens control. Moving the right stick forward and back controls synchronized zoom and focus, and moving the left stick side to side controls just focus. The implementation of speed control also helps keep the servo noise down to acceptable levels.
- There are 6 programmable "goto" zoom/focus settings that can be programmed on the fly from the Wii Classic, and that will move the zoom and focus to the desired position just by pushing a button (left shoulder for widest zoom, right shoulder for most zoom, and a, b, x and y for any zoom/focus position).
- The maximum lens movement settings can also be programmed on the fly to ensure that the servos don't try to rotate beyond the limits of the lens's zoom and focus positions.
- D-pad provides single degree movements of zoom (up and down pad) and focus (left and right pad) to make precise adjustments for critical focus/zoom.

Here's a demonstration of how the synchronized zoom - focus works on my GH2 with a Nikon 28 - 85mm zoom lens:


In this instructable I'll cover the basics of how to build your own version of this controller, including the Arduino code and instructions for mounting the servos to a rail-based camera rig. I'll mention how I built my rig, but since I'm not really happy with it, I won't go into detailed steps on that and will leave it to you to figure out your own solution based on the pictures of my rig and some notes about how I made it.

This was my first attempt at building something with Arduino, though I've had some programming experience so it wasn't too difficult for me to learn the basics of Arduino code. However, if you want to tackle this project and you haven't already gained familiarity with setting up and programming an Arduino, I recommend that you go through the tutorials on the Arduino site, especially those for Servos. http://arduino.cc/en/Tutorial/HomePage

Step 1: Getting Started: Tools and Materials

Picture of Getting Started: Tools and Materials

You can complete the electronics for this project with just some wire strippers and a soldering iron. But to make the servo mounting arms it helps to have access to a bandsaw and a drill press (though careful work with a hand drill can negate the need for the latter). I also used a tablesaw to cut the sheet plastic and a table-mounted router with a 1/2 diameter core-box bit to cut the grooves in the plastic to match the rails on my home-made camera rail system.

Here is a list of the major supplies you'll need to complete this project, but please go through the whole instructable before buying anything so that you'll understand what to purchase in order to fit your own needs.

- Arduino or Arduino clone (I used a Seeeduino because it was a little cheaper than the Arduiino and provides the same functionality).
- Wii Classic Controller. I bought mine from eBay for around $10 shipped.
- Wiichuck Adapter (a little circuit board that plugs into your Wii Classic so you don't have to cut the cable). I got this from FunGizmos for $4: http://store.fungizmos.com/items/212
- 2 standard sized hobby servos with nylon gears and ball bearings. The nylon gears are quieter and the ball bearings provide better support for the shaft when handling the load of stiffer zoom lenses. I bought some surplus servos from a local RC store for $5 each, but am replacing them with 360 degree digital servos that should be even quieter and more accurate, and those cost me $20 each from eBay.
- 2 lens gears to mount on your lens's zoom and focus rings. I used the flexible ones that I found on eBay for $10 each, and made my own spacer rings to provide better resolution and a bit more mechanical advantage for the servos. You can also spend about twice as much and get lens gear rings that have built-in spacers, and these are also available on eBay. just search for "lens gear follow focus".
- 2  Drive gears to mount on the servos to drive the lens gears. These need to be 32p or mod .8 gear pitch (which is the standard pitch for lens gears). I fashioned my own drive gears by fitting some $4 RC spur gears to the original servo control arms, but that required some work on a mini lathe that not everyone has. A better option would be to buy the servo-mountable gears from Servo City for just a few dollars more: http://www.servocity.com/html/32_pitch_hitec_servo_gears.html. While you're ordering those, you'll save yourself some trouble is you also buy a pair of male servo leads to make it easier to connect your servos to your Arduino and to swap servos if the need arises.
- 1/2 inch thick sheet plastic or 3/4" thick aluminum to make the servo mounts. I used an old plastic cutting board, but if you do, make sure that it's the harder ridgid kind (you should not be able to dent the surface at all with your thumbnail). The softer kind is UHMW and will not machine well enough for this purpose.
- knobs and matching carriage bolts for clamping the servo mounts to the rails.

Step 2: Choosing Gears and Servos for Your Lenses

Picture of Choosing Gears and Servos for Your Lenses

Before you purchase your servos or gears, you need to understand some things about servos. Servos have a limited range of motion (typically 180), so if you want to be able to control your lens throughout its entire zoom and focus range, you need to do a little calculation based on your lens's ring movement and the diameter of the lens gear that the servo will be driving. I think it's best to just go through the process that I went through, so you can follow the same approach for your own system's needs.

My lens's focus and zoom rings move about 90 degrees from end to end, and with the spacers and lens gear the total diameter of the gear being driven by the servo is 4.25 inches. I used a circumference calculator from this web site (http://math.about.com/library/blcirclecalculator.htm) to get a circumference of  13.35 inches.  Since 90 degrees is 1/4 of 360, I can calculate that my servo needs to provide about 3.4 inches of travel (13.35 / 4). I used standard 180 degree servos, so I know that the circumference of my servo drive gears had to be at least 6.8 inches (180 degrees is half of 360, so my servos will only be able to provide movement that is half the total circumference of the servo drive gears). Using the circumference calculator again, I know that I need gears that are at least 2.2 inches diameter. I actually ended up using a slightly smaller lens gear because I don't need the full range of focus motion and I wanted to have a little finer control of focus since that is more critical than zoom for me. This is another consideration to keep in mind - the closer you are to 1:1 between drive gear and lens gear, the less resolution you have. For example, in my setup a 1 degree servo step = 1/2 degree lens step, but if my drive gear diameter was equal to the lens gear the lens would move 1 degree for each servo degree. You also need more servo torque for a 1:1 drive:lens ratio that you do for a 1:2 drive:lens ratio.

You should also know that there is another variable that you can introduce - servo rotation. My servo control code is written for standard servos that rotate 180 degrees, but I've ordered a pair of digital servos that rotate 360 degrees and that will allow my controller to handle lenses that require more travel. You can get servos that rotate up to 3 turns, which should be enough to handle most lenses while maintaining low drive to lens gear ratios. Of course you'll have to make some minor changes to the code to handle the increased degree range, but it should be pretty straightforward. If you want full turn or multi-turn servos, search for "winch servo" on eBay.

Step 3: Prepare Your Arduino (or Clone)

Picture of Prepare Your Arduino (or Clone)

Once you have your Arduino (or equivalent), your Wiichuck connector, your servos and leads, and your Wii Classic controller, you're ready to start putting things together and to load the code onto your Arduino. Here's the outline: wire the Wiichuck connector and servo leads so you can start testing everything together (that step requires some soldering). Once you have things connected, set up the Arduino IDE on your computer, plug in your Arduino, and start loading the libraries and examples you need. Then the fun starts.

Wiring the WiiChuck Adapter:
This part is pretty easy, if you don't do what I did and lose the little 4 pin header that comes with it. You just solder the header in place, then plug it into the Arduino as illustrated in the image on the FunGizmos web site. To connect your Classic controller, just make sure that the indentation on the controller plug lines up with the "nc" on the Wiichuck adapter.

Wiring the Servos:
I originally purchased a motor controller board because I first tried to build this project with stepper motors rather than servos (because I thought they wold be quieter, which turned out to be quite wrongheaded). The board has 2 hobby servo connectors, so I didn't have to do any soldering to connect my servos. But the process is for wiring them straightforward: you simply connect the power leads of both servos (black is negative, red is positive) to ground and VCC of your board. You have several locations from which you can choose. Then connect one of the signal (yellow) wires of one servo to pin 9, and the other to pin 10. These are the default PWM pins that provide default pulse width modulation outputs that are required to tell the servo how far to turn.

Once you're done with the wiring, you can connect everything together, connect your Arduino to your computer via the USB cable, and start loading code. 

Step 4: Program Your Board: Get the Libraries and My Code and Start Playing

Before you load the code that I wrote for my lens controller, you need to get the Arduino IDE set up on your computer and load the libraries that you need. The Servo control library is included with the Arduino IDE, so you don't need to do anything for that. However, my code also uses a user-contributed Wii Classic Controller library that is available on the Arduino playground. http://arduino.cc/playground/Main/WiiClassicController10
You can follow the steps on the page to add this to your library, or just download the zip file that I've attached and unzip it into your Arduino libraries folder. Mine is in this path:
..\Documents\Arduino\arduino-1.0\libraries\

I created a folder called MiconoWiiClassic in the \libararies folder, and saved the "WiiClassic.h" file in that folder. You can just unzip the MiconoWiiClassic.zip file that I've included here to your Arduino-1.9\libraries folder.

UPDATES:
1) Since first posting this Instructable, I've figured out how to double the resolution of the servos, which makes them smoother and more accurate. I did this by tweaking the Servos library that is installed by Arduino. You can either tweak the library yourself, or you can download the Servo.zip file and extract the Servo.cpp file into your ..\Arduino\arduino-1.0\libraries\Servo folder and overwrite the Servo.cpp file that's there. If you want to tweak the file yourself, you can just open the file from your library in Notepad, and replace all instances of "180" with "360".  If you downloaded my sketch before I made this update, you should re-download FocusController_gp.zip and extract it to your sketch folder. It will add focus_zoom_controller_servo_final_2xresolution.ino to that folder.

2) After you unzip the files you need to change one thing in the WiiClassic.h file in order to make the library work as expected with my code.The WiiClassic.h library contains a DEFINE_ON_HOLD feature that must be uncommented in order to ensure that the button presses are reported just once. To uncomment this, you have to open the ..\arduino-1.0\libraries\MiconoWiiClassic\WiiClassic.h file in Notepad and change the following line:
//#define REPORT_ON_HOLD
to
#define REPORT_ON_HOLD
If you don't do this, you will notice that the D-pad button presses will keep moving the servos as you hold the button, whereas it should only move the servo one step per press. This error may also cause strange behavior from other button presses.

3) If you're plugging the WiiChuck adapter in to Analog pins 2,3,4 and 5, you need to configure 2 and 3 as ground and power, by adding the following to the setup section of your code (thanks to Phillip James for catching this ommision)

"pinMode(16, OUTPUT);" Sets digital 16 pin (aka Analog 2) as ground pin
"digitalWrite(16, LOW);"
"pinMode(17, OUTPUT);" Sets digital 17 pin (aka Analog 3) as +5V pin
"digitalWrite(17, HIGH);"

Once you have that library in place, you can also download my project code and unzip it to your main Arduino folder, and the next time you launch the Arduino IDE, my projects will show up in your Sketchbook folder. My Arduino folder is in my documents folder, like this:
..\Documents\Arduino\

Step 5: Test Things Out: Wii Classic Controller

With the electronic parts connected and your code in place, it's time to start testing things out and tweaking the code, if necessary. Start by loading the WiiClassicTestValues sketch from your Sketchbook (File > Sketchbook > WiiClassicTestValues). Before loading it onto your board, compile it to make sure that you've installed the WiiClassic.h library properly (you should also be able to see it in your libraries list (Sketch > Import Library). If it compiles properly, load it onto your board.

The program outputs the value of each of your sticks on the Wii Classic to the Serial Monitor, so you'll need to open the Serial Monitor (Tools > Serial Monitor). Let the controller run with the sticks at rest to see what the values are at the center positions, then methodically push both sticks all the way forward for a few seconds, then all the way down, then all the way left, then all the way right. Once you've done that, you can turn Autoscrolling off in the monitor window and copy the results to Notepad and save the file for further review. You're now ready to ensure that the controller code is calibrated to your Wii Classic Controller.

Step 6: Load the Lens Controller Code and Adjust for Your Wii Controller

Now you can load the controller code and ensure that the expected controller values match your Wii Classic Controller. Start by loading my controller sketch from File > Sketchbook > focus_zoom_controller_final.

Once it's loaded, scroll to line 101 of the code to see the settings for the controller stick values, shown below:

// the right stick has 1/2 the resolution of the left - these values may vary from one
  // controller to another, so you'll need to run a test program to discern the values of
  // each stick position
  int yCenterRight = 15;
  int yMinRight = 2;
  int yMaxRight = 28;
  int xCenterRight = 15;
  int xMinRight = 3;
  int xMaxRight = 28;
  int centerOffsetRight = 3;
  int endOffsetRight = 0;
 
  int yCenterLeft = 32;
  int yMinLeft = 6;   
  int yMaxLeft = 55;
  int xCenterLeft = 31;
  int xMinLeft = 6;
  int xMaxLeft = 55;
  int centerOffsetLeft = 6;
  int endOffsetLeft = 0;

Check these values against the read out from your controller, and change any values as necessary. Make sure you save your changes.

Step 7:

It's time to test out the code with your servos.  In my code I have the Zoom servo attached to pin 9 of the Arduino, and the Focus servo attached to pin 10. You can easily change that in the code by changing the numbers here:

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  //attach servos and set them to initial positions for mounting the servos to the lens
  zoomServo.attach(9);
  focusServo.attach(10);

Once that is done and your servos are connected, plug your board into the USB port on your computer and download the code to your board. When it's done downloading and booting, the Zoom servo will move to 180 degrees and the Focus servo will move to 0. You can now start playing with the sticks and buttons to see what happens, and can try programming the various servo positions and the focus ratio. Some of the buttons have default values, but you can program any button by pressing, HOME, then the button and the program will remember the setting until the board is reset or powered off.

Once you're satisfied that the controller is working correctly to move the servos, you can grab your camera and lens and assess whether the servo directions for the stick movements are correct. Pushing the right stick forward should turn the servo in the correct direction to zoom the lens, and pulling it back should do the opposite. At the same time it should move the focus in the direction that is needed to keep the camera in focus when the zoom is moved. I have mine set up so that when I zoom in (push the right stick forward), I have to move the focus stick to the right to correct the focus, and when I zoom out (pull the right stick back), I have to move the focus stick to the left to correct the focus. This seemed like the most intuitive arrangement.  

By setting the servos next to your camera and lens in the way you plan to mount them on the camera rig, you can tell whether they are moving in the right direction given how your lens moves. If they don't, there are instructions in the code on how to change the direction of servo movement relative to each stick movement. I have future plans to hack the Servo library to make this easier, but for now it's not as easy as flipping a switch, but it's also not overly complicated.

Step 8: Put It Together for a Real Test

Picture of Put It Together for a Real Test

Here's where it really gets fun. Once your satisfied that you have the servos moving in the right direction for your camera, there's really no reason not to mount everything an see how it works with your camera and lens. You can make enclosures and add switches, power connectors, and pretty lights once everything is working to your satisfaction, but there's really no point in doing that until you see whether your setup is able to drive your lens the way you want. I did this with several iterations of my project, including a stepper-based version that was a complete disaster and caused me to change course and switch to servos. The idea is to fail fast, before you've committed too much work on a final product that still needs tweaking.

Start by mounting the servo drive gears and the lens gears. This is all pretty straightforward, but if you find that your lens gear is slipping at all (as mine did), it may help to know that you can increase the grip of anything with the rubber backing that's easily peeled off the back of a cheap, thin mousepad. The same stuff can also be used to deaden noise from the servos. Along those lines, adding some plastic-safe grease to the servo gearbox can also help reduce the servo noise. I used fishing reel grease that is designated as plastic safe, and it really quieted my zoom servo.

If you don't have a rail system, you'll need to fashion one by either following what I did (I'll let the picture guide you) or find an even better design on the web. My rig was put together quickly for testing purposes, and I plan to replace the cobbled-together design with something more attractive, rigid, and easy to adjust. My rails are 1/2 diameter carbon ski poles that I snagged from Goodwill for $4 (Goode brand are not tapered, so they worked well for this).  The rail holder is made from a 1/2" thick hard plastic cutting board that I sawed into a 2-1/2 inch wide by 6" long strip. To create the rail "holes" I routed two 1/4" deep by 1/2" diameter grooves with a core box bit mounted in a router table and guided by a small fence. I now wish I had made thiis whole thing wider, but I wanted to keep it narrow so I could still get to my battery door without dismounting the camera from the rails.  I then cut the piece in 2 lengthwise, mounted a spacer block of baltic birch plywood to one end with some wood screws, and then drilled a couple of 1.4" holes in it for attaching it to  the camera and the Manfrotto quick release plate.

Once you have a a rail rig, you can fashion some servo mounting blocks to fit your rails. I also made mine from some hard plastic cutting board scrap that I routed on my router table. I screwed one end together with some small drywall screws, and drilled a 1.4" whole on the other side of the rail hole to hold a carriage bolt. A small knob allows me to tighten the mouting block for a pretty snug fit on the rails. Once I was sure everything fit OK, I drilled tiny pilot holes to fit the servo mounting screws that came with my servos, and fastened the servos in place. Note that with this arrangement the servo is only fastened at the front edge, so be careful where you exert pressure when mounting the servo and block assembly on the rails.

Step 9: Give It a Test Run

Picture of Give It a Test Run
With the camera in place (and mounted on a sturdy tripod) and the servos mounted to the rails, it's time to hook everything up for a test run.  Don't power the Arduino with the gears enagaged though. Instead, first swing them away from the lens gear so the servos can rotate without moving the lens. You can then power up your board. If you don't do this, you may find that your servo tries to turn the lens beyond its limits, and that's not good.

Program your controller for your lens (these instructions are also in the Arduino code)
After your board boots up and the servos have stopped moving, move the lens zoom ring to that it is at the max setting that corresponds to the servo position. When my controller starts up my zoom servo moves to the widest zoom position, so that's where I move the lens before I engage the zoom servo. After I've moved the lens, I swing the servo into position so the drive gear just engages the lens gear (if put too much pressure on the lens, you may cause it to stick and you won't get as smooth of movement). I then program this as the widest zoom setting by pressing "Home", then "Left Shoulder " on the Wii Classic Controller. I then use the right stick to zoom in until the camera hits its zoom limit, and use the pad to back off a degree or two. I then program this max zoom position by pressing "Home", then "Right Shoulder" to program the maximum zoom setting of the lens.

I repeat a similar procedure for the focus servo, but program the right most and left most focus servo settings using the "Right Z" and "Left Z" buttons.

Once these limits are set, it's time to power up your camera, pick  a subject and set the focus for the widest and closest zoom settings. It doesn't matter where you start, but I usually go max zoom (just press the right Shoulder button to automatically go there). I then use the left stick and left-right D-Pad to get the focus right, then press "Home" then "+" to set the focus for Max Zoom. Next zoom your lens all the way out to the widest zoom and again, use the left stick and D-Pad to dial in the focu on your subject. Once it's good, press "Home" then "-" to set the focus at the Min Zoom (widest zoom) position. Each time you program either the "-" or "+" buttons, the code calculates the correct ratio to move the focus while zooming in order to keep your subject in focus as you zoom.  You can tweak the focus at any time by using the left stick or the D-Pad, and until you re-program the "+" or "-" key the focus will always move in synchronization with the zoom movement when you use the right stick to zoom your lens. This is where the magic of my "contraption" (as my wife calls it) is.

You can also program the 4 (x, y, a, b) buttons with dedicated Zoom/Focus positions. Just move the zoom and focus to the desired position, then press "Home", and then the one of the buttons to program it for that position.  If you move only the focus servo while programming each of these buttons, you can make your controller work like a follow focus with 4 preset focus positions that don't move the zoom lens at all. 

Here's a video demonstrating this process with the controller mounted on my GH2 camera:

Step 10: Wrap It Up

When you're done playing and teaking and satisified that your own version of my controller will work for you, it's time to make it all permanent, pretty, and easy to mount and dismount. I'll let you figure that part out on your own (but hopefully you'll share your results with me).  I have a number of tweaks to make on my controller before I finalize it, so I thought I'd share my plans here to get you thinking along the same lines.

Enclosure and Better Servo Mounts
I just haven't foudn the right enclosure yet, so I'd welcome sugestions here. I'll probably buy a smaller Arduino like a mini so I can keep things small and that will open up my options. I'm also going to rpelace the plastic servo mounts with machined aluminum mounts now that I know how well this thing works. I'm also going to upgrade the servos themselves.

Power Supply
Right now my controller runs off USB power by plugging my USB cord into an iPod charger. However, I have a spare external 9 volt DVD battery that can be charged while it's supplying power to by controller, and I like the idea of having battery only option so once I've found a suitable enclosure I'm going to wire the proper connector to the external poer pins on my board.

LED Indicators
It
would be nice (and very easy to add an indicator for "program mode", so I have some LED's that will illuminate when the controller is in Program or Run mode.

Easy Servo Reversing
As I indicated earlier, it's a bit tedious to change the direction of the servo relative to the stick movements, so I've started working on hacking the Arduino servo library to accept a servo direction flag.

Memory for Lens Settings
It would also be nice to not have to reprogram the lens limit settings each time the controlle ris powere off, so I plan to add SD card based storage for each lens setting.

Step 11: Feedback and Follow Up

Picture of Feedback and Follow Up

Another member. Steve Dray, has done a great job building a couple of his own versions of this rig, and has generously shared his wiring diagrams and pictures. I hope this inspires and helps others trying to build this project, especially since I've had limited time to answer questions. Steve was having some problems that he diagnosed as a poor power supply, so he built his own regulated supply, and included the schematic for that as well. I've managed to get by with my little cube ipod charger.

Thanks Steve!

Comments

swatdojo (author)2012-05-16

thanks for the instructable! i saw in the comments you had already seen my wireless follow focus at phillipjamesproductions and I wanted to stop by and say that this turned out great. I was looking to try it out myself to implement it into a new project I'm working on, but I'm having trouble getting the controller test program to compile. It says the nunchuck_setpowerpins() was not declared. from what i understood from some research is that is the bit of code that defines the analog pins as power/gnd/data etc. I dug through the code and didnt find it declared anywhere in the libraries or your final code. Did i miss something obvious?

thanks again!
phillip

grp19 (author)swatdojo2012-05-16

Hi Phillip! Thanks for the complement, I've seen your project and I plan to use your xbee wireless implementation when I'm ready to add that capability to my controller. As for the problem with getting the WiiClassicDemo to compile, I had the same problem, and I just commented out the nunchuck_setpowerpins(); line - I don't need it because I wired my WiiChuck adapter directly to VCC (power) and ground on my Arduino, so I didn't need to configure the output pins. If you're wiring your adapter like I did, you can do the same. However if you're plugging the adapter into the Arduino pin headers, then you will need to configure 2 of the pins as power pins. apparently the person who created the demo had added that method to some the WiiChuck library, but it wasn't added to the WiiClassic library. But you can still configure the pins in your sketch. If you're plugging the WiiChuck adapter in to Analog pins 2,3,4 and 5, you can configure 2 and 3 as ground and power, by adding the following to the setup section of your code:

"pinMode(16, OUTPUT);" Sets digital 16 pin (aka Analog 2) as ground pin
"digitalWrite(16, LOW);"

"pinMode(17, OUTPUT);" Sets digital 17 pin (aka Analog 3) as +5V pin
"digitalWrite(17, HIGH);"

Thanks for catching this - I'm updating the instructable with this information for those that are plugging the WiiChuck adapter in. Keep me posted on your progress, and check back here as you work because I've made some improvements to my code that I will post here when I'm done testing it.

abhishekbiomed27 (author)2017-08-23

Awesome instructable. Really, the top rated one. May I know the specs of the lenses you used

grp19 (author)abhishekbiomed272017-08-23

Thanks for the nice feedback. The lens I primarily used with this rig is an f3.5 Nikkor 28-85mm zoom, which is mounted to my camera with a Nikon FD to 4/3 adapter. I've made some improvements to this since posting the instructable, including some code to make the servos smoother and to be able to easily change the movement of the servos relative to the joystick movements. I've also been working on a version that uses 300-degree Dynamixel servos, but that is not quite done yet. The advantage of servos with a larger turning range is that it will handle lenses with a longer focus or zoom movement.

abhishekbiomed27 (author)grp192017-08-23

Thanks a lot. Keep innovating

FranzG5 (author)2016-05-06

Hi there,

the link to fungizmos doesen't work anymore...

are there any alternatives?

grp19 (author)FranzG52016-05-06

You can get them from DFrobot for US$1.90: http://www.dfrobot.com/index.php?route=product/pro...

FranzG5 (author)grp192016-05-06

by the way, great project!!!!! Thank you for publishing and for being online 4 years since publishing.

oh okay, i got this item already,

I thought on fungizmos there is instruction about how to connect the four Pins to the arduino, i didn't figuered out yet.

Did I overread the passage?? Where do I have to connect the four wires from the WiiClassiccontroller to the arduino board?

Brian202020 (author)2016-05-06

grp19, I've posted on this topic several times several years back, but never got around to making it. I have a an interesting idea to use this tech on. Is there a way we can talk either via email or phone? I might want to commission you to make something.

Poppy Ann (author)2014-08-31

Would it not be easier to just fit the zoom rings and then count the number of teeth it moves from one extreme to the other then just get a gear with double the number of teeth in place of working out the diameter then the degrees of movement etc.

i made one for a cctv camera i was playing around with but i gave up with the zoom rings and just fitted two servo's to a mount i built then just added servo arms and set the maximum movement with the transmitter (to be changed to arduino when i have time) it works great thanks for the idea.

regards Poppy Ann

grp19 (author)Poppy Ann2014-08-31

Counting the teeth is a great idea if you have the gears on hand., but I was trying to figure out what I needed so I could order the gears online. The math is also easier to do than it is to explain - it's a quick calculation, and if, like me, you're buying gears for the project, you don't have them on hand to count the teeth, so being able to work it out based on diameter allows you to get the right sized grears when you're buying gears based only on diameter of the lens gear.

Poppy Ann (author)grp192014-09-01

Hi there,
you did a great job with the instructable i did not know you did not have any of the items on hand, i was lucky as i had all the items except for the focus rings as i had never heard of them and it was your instructable that gave me the idea so i bought a pair but in the end on my lens the focus movement is covered up so it could not take a focus ring that was when i decided to try just a servo which worked so good i went on to just use the same on the zoom control.
now i have two focus rings amongst the spare parts boxes i have.

for me trying to use this idea was just a play item i do not do any real photography it was just to play with and pass the time in the end i built a pan and tilt mounting at the same time but by the time i had it finished it is so large i think i better go back to the start and try again on a smaller scale.
i think i will borrow your code if/when i try setting it up with a arduino to operate it.
thanks again for the great instructable.
regards Poppy Ann.

joerierave (author)2013-09-16

Isn't this an option to supply the 5V needed instead;
http://www.ebay.com/itm/121108770419?ssPageName=STRK:MEWAX:IT&_trksid=p3984.m1438.l2649
(search term on ebay: 2 IN 1 12V DC USB 5V Rechargeable Li-ion Battery 4 CCTV)

It's a 12V rechargeable battery that has 12V output and also a 5V USB output. To keep things simple. Instead of building a regulator, use the 5V USB from this battery. Or are am i wrong?

Great idea by the way! Thanks for your instructable!

Another question i have; Will it be possible to also add a Nunchuck controller? And maybe only connect the classic controller for programming the lens values such as the focus and zoom rotation limits and backfocus (zoom+focus ratio)?
The nunchuck has two buttons on top, that can be used to zoom in and out and the analog stick can be used for focus. I think this will be a more ergonomic controller for one handed use. Maybe even modified to also serve as a grip for your camera rig.

Thanks again for the instructable!

Greets,
Joerie Rave

andrea biffi (author)2013-03-20

awesome project! remember: diameter x 3.14 = circumference, you'll not need a circumference calculator nex time ;-)

grp19 (author)andrea biffi2013-03-20

Ha! Thanks. Yeah, I'm aware that it's easy to calculate a circumference - just an indication of how lazy I am: I had a bunch of different gears to just from so it was easier to use someone else's Javascript calculator than to enter a bunch of values in excel or even using google's built-in calculation.

andrea biffi (author)grp192013-03-20

Yes I understand, all these automations make me become lazy too ;-)
Anyway I love those servos and gears, I wish to have a similar shop in Italy too..

maxtak78 (author)2013-03-05

Dear grp19, your project is awesome and I was thinking to use it with my crane.
I understood that you changed the servo using one at 360°, could you suggest a good servo to use? Thank you

grp19 (author)maxtak782013-03-05

Thanks. The 360 degree servo I tried turned out to be very noisy, and I ended up going back to the servos shown in the project. They provide enough rotation to cover the whole zoom range of the lens and most of the focus range, and since I use this rig only for longer range shots (dance performances and sporting events), I never need the whole focus range of the lens.

If you really do need 360 degree rotation, I recommend searching youtube first, so you can see examples of the servos moving and also understand how noisy they are.

Let me know how your project goes.

Guy

ibm66 (author)2013-02-03

Great project, thanks. I got encouraged to follow up your instructions and build one for my camera. But i'm experiencing some problems, my zoom pin 9 does not seem to respond at all and pin 10 works only when pin 9 is attached. And i see a code:
"const int ratioPin = A1;" what does this line do?

rstruk (author)2013-01-07

Nice instructions! What model $20 digital servos did you get and do they work well? Is 10kg torque enough for most lenses if I use a 60 tooth gear? Lastly what work did you have to do on the lathe to fit the gear? Cheers

vmenezes (author)2012-11-26

Hello dear friend! First thanks for the fantastic project, their generosity has encouraged me to enter this universe with DIY Arduino. I'm in Brazil, here it does not have the same disclosure therein, I am most excited to try. I already bought my arduino, motors, control and everything else you listed in the materials. But as I am a beginner, I missed a wiring diagram because I could not identify where I connect the cables pins for the control of arduir I bought on ebay.

If you can simplify a fool for beginner like me, I would be immensely grateful.

Again congratulations for the initiative and generosity!
Valter Menezes

grp19 (author)vmenezes2012-11-27

Hi Valter,

Thanks for you comment, and I'm glad you have decided to try this project. At least one other person has successfully built this, so I'm glad to see another person trying it. The text describes where to connect everything, but I think it is not as clear as a wiring diagram would be, and the other builder thought I had one point wrong. I will try to put together a diagram and update the instructable with it.

eyepatchentertainmen (author)2012-05-14

Brilliant work. This actually solves another problem perfectly. The issue of dual focus anamorphics.

grenho (author)2012-05-01

That's a great project! I would just upgrade the servos to be more silent and find a way to hook up an external monitor. It would be awesome to have a "control console" arcade style -> http://hal9k.dk/lib/exe/fetch.php?hash=816af8&w=150&h=122&media=http%3A%2F%2Fvancefry.com%2Fwp-content%2Fuploads%2Fpixelbox-mockup.jpg

grp19 (author)grenho2012-05-01

Thanks! The zoom servo that I have isactually quieter than the focus servo (which is what you hear som prominently in the video), so I'm hoping that the higher quality digital servos that I've ordered will be even quieter. If they aren't then I have a hack in mind for the servos to make them quieter based on what I found by taking apart some zoom drives from old camcorders. And since my GH2 has live HDMI video out, I already use my camera with an external monitor when I'm shooting dance performance videos. However I haven't gone as far as putting it all in a control console, though I've certainly thought about it. One thing's for sure, I'm not done improving this, and look forward to having more feedback.

toxictorch (author)grp192012-05-03

You can just buy small dc motors and rig up o-ring drive to eliminate the noisy gears, and perhaps some rubber mounting bushings. I was actually thinking about doing this myself, but this takes the work out of figuring out all that mess and gives me a great start point. Thanks a ton!

grp19 (author)toxictorch2012-05-03

Hi toxictorch. I'm glad you're interested in this project, and hope you share whatever improvements you make. I've been through many iterations, and initially avoided servos because of the noise. I also contemplated dc motors and drive belts (since as you correctly note, the noise is from the gears in the servos), but the thing that brought me back to servos is that they provide an easy closed-loop solution, which means that I don't have to count steps (like I would with a stepper) in order to program a position and have the motor go to that position with a simple command. With the solution that you outline, you'd have to add a position sensor to the lens or the motor drive in order to know exactly where the lens is at (I strongly considered this approach, but found it overly complicated to implement and to install on a camera rig). That approach also requires you to handle interrupts, for which the Arduino can only handle two. I do believe I have a solution to the servo gear noise though, and will update my project when I have had a chance to implement it and prove that it works.

toxictorch (author)grp192012-05-04

Simple solution as well, you just yank the guts out of the servo. Board with a soldered on motor and a pot. You can change up the pot or even modify it for continuous rotation if you want with just some resistors (but then you get the whole counting steps crap). Basically just get the reduction similar and attach the pot to either the final output cog/gear that goes to the lens, or even have a separate pot/gear attached to the lens.

Gears are nice for ensuring proper steps, but you could always go friction drive if you mount the pots really well. Taking out the form factor of the servo would also allow you to make a much more compact unit, but I have way too many vapor projects on the backburner to be going all crazy with this, I will probably stick with simple and quick.

Also, it is 3am after I just got back from watching the Avenger's, late night rants are bound to be horrible.

mintybot (author)toxictorch2012-05-06

There's not much point in taking the brains out of a servo, it wouldn't reduce the noise and it would get rid of any advantage the author chose the servos for. Also, using bare DC motors are tricky, especially for such a delicate task like focusing a lens.

toxictorch (author)mintybot2012-05-06

Not sure you are thinking all the way through on the idea. You can use the same little dc motor in the servo if you want, but you dont need to use gears for reduction (which is the noise). The whole idea of "delicate" is on one crappy pot in the servo anyways.

But let us make this simple to understand, just take out all the gears for the servo and replace it with two grooved pulleys and an o-ring to drive them. Keep the pot at the end pulley and you have the exact same thing as a servo, with a much quieter output. There are far better solutions to this, but using the cheap servo electronics makes it easy for anyone to do this. An encoded motor is great, but a servo uses a pot for a solution.

The author knew what I meant though.

grp19 (author)toxictorch2012-05-07

Yeah, I knew :), but thanks for clarifying so that others can also follow what you were talking about. I actually might try a hybrid solution to what you outlined, which is inspired by a teardown I did of some old VHS camcorder zoom mechanisms: they have a gear box, but the motor drives the gearbox via a step-down pulley and belt. this not only isolates the gear train from the motor vibration, but it also reduces the overall speed of the gear drive, and the slower they turn, the quieter the gears are. In fact this is one of the reasons that my controller is quieter than some of the commercial ones: my Arduino code gives me speed control over the servos, and I limit it to keep the gear noise down. I've done a couple of other things since posting this to imrprove the performance of my controller: I doubled the resolution of the servos by tweaking the Arduino Servo library, and I've replace the focus servo with another one I had on hand, and which turned out to be a lot quieter. I'm going to upload the new code and will post some new videos demonstrating the noise improvement when I get a chance. Again, thanks again for your suggestions and feedback - keep it coming!

toxictorch (author)grp192012-05-08

Sounds great, I will most certainly build something within a year when I make a trip to Japan for a month or so. Keep updating this! Thanks a ton for your work.

grp19 (author)toxictorch2012-05-04

Believe me, I've looked at all kinds of different possibilities for the drive system, including using the servo guts with my own motor and drive, as you suggested (and that's very likely to happen with the new servos I just received). There are also 2 open source projects, OpenServo and OpenEncoder that look to be an even more promising path if I decide that I need to build a custom lens servo. In my wildest dreams I'd like to build a truly quiet drive system with all of the required intelligience built into the drive itself, so the arduino doesn't have to do anything other than send the speed and (where necessary) target position, and can easily read the position from the drive system. I'm looking at the OpenServo/OpenEncoder project for that longer term goal, because OpenServo provides much more control over the servo resolution and speed than you get with even digital servos, and the OpenEncoder project replaces the limited turn, limited accuracy potentiometer with an unlimited turn and very precise magnetic encoder.

reptedjess (author)2012-05-06

Whoa this is really cool! I'm a photographer and never really had any interest in video, but this is seriously making me consider getting into that side of things. Imagine how awesome it would be to have a shoulder rig with these controls!

Chakazuluu (author)2012-05-06

This is really cool and timely because I am designing a camera crane for my shoulder mount Panasonic DVC20P. I was worrying over having to design from scratch a zoom & focus mechanism. Your project takes a lot of the work out of it. Thank you very much.

grp19 (author)Chakazuluu2012-05-06

Thanks Chakazuluu. I found one thing that I missed in the code that I uploaded, and I'm currently working on improving the resolution of the servo control. When I make those changes I will upload updated files, so check back as you work on this. Also, if you're going to use this on a boom you may want to consider adding wireless control, which can be done with a second Arduino and some xbee units. When I get around to doing that I will share it, but if you beat me to it you can share as well. Also, using higher quality servos will give you very quiet operation. I just swapped out the focus servo (which was the noisest of the 2 in the videos) and focusing is now much quieter and even smoother. I used a Hitec with karbonite gears, and added some additional grease to the gearcase. Good luck and have fun!

P.S. Here's the thing I missed:
The WiiClassic.h library contains a DEFINE_ON_HOLD feature that must be uncommented in order to ensure that the button presses are reported just once. To uncomment this, you have to open the ..\arduino-1.0\libraries\MiconoWiiClassic\WiiClassic.h file in Notepad and change the following line:
//#define REPORT_ON_HOLD
to
#define REPORT_ON_HOLD
If you don't do this, you will notice that the D-pad button presses will keep moving the servos as you hold the button, whereas it should only move the servo one step per press. This error may also cause strange behavior from other button presses.

Brian202020 (author)2012-05-04

I found nicely machined rail mounts that hold servo's. I contacted the dealer to see if they would be willing to sell just the rail mounts without everything else.

http://www.dvcity.com/dvshop/product.php?productid=18089&cat=253&page=1

grp19 (author)Brian2020202012-05-04

Their servo mounts look nice, and it would be cool if they would sell them as a kit part. But looking at their prices I think that they're going to be steep for a DIY solution. As for the rail system, sensoryhouse made a much nicer rail mount system than mine, but you definitely need a drill press and a metal cutting bandsaw to pull it off: https://www.instructables.com/id/DIY-HDSLR-Shoulder-Rig-Follow-Focus/

sensoryhouse (author)2012-05-04

I have some useful info to add to this topic.  


Here is a link to a PDF with live links.



Brian202020 (author)sensoryhouse2012-05-04

Is the Wii Classic controller being used on this set up as well? It doesn't say on the PDF or Phillip James Productions website.

grp19 (author)Brian2020202012-05-04

I looked at Phillip's project, and his just provides focus control and uses an optical encoder to control the focus servo, so there's no Wii controller involved. It would be possible to add a similar feature to my project that could work in conjunction with the Wii controller.

Brian202020 (author)grp192012-05-04

I think adding an accurate repeatable way to mark the focus would be very nice.

sensoryhouse (author)grp192012-05-04

lol, i considered the "topic" to be Arduino lens control, not Wii controller hacks.

Brian202020 (author)sensoryhouse2012-05-04

I think what sets grp19's project above the rest is the zoom/focus syncing. The Wii controller isn't perfect for marking focus and what not, but it has a lot of buttons for programing and it's inexpensive. The ideal situation would be combining the 2 methods like grp19 suggested.

not sure why the image shows up so damn small but the PDF is hi res.

grp19 (author)sensoryhouse2012-05-04

It works fine if you click the link. And thanks for posting it. I especially appreciated the link to the silent (or very quiet) servo in the PDF. At $90 they're pretty expensive, but it's good to know that there's an alternative if the servo hack that I'm working on doesn't work out.

Brian202020 (author)grp192012-05-04

Those servo's do look nice. Silent, strong, and quick. Once I dive into this project I'll probably get those.

Brian202020 (author)2012-05-03

I like your project grp19. I just stumbled onto the Arduino scene so forgive my ignorance, but how easy would it be to add a LANC input and output? I'm imagining a box you can mount to multiple cameras (so multiple types of outputs) with multiple inputs.

I was thinking:
Input: LANC and Wii Classic Controller
Output: LANC, 2 servo's (focus and zoom), and USB (to control either Canon or Nikon DSLR's)

If you add LANC you could power on and off the camera as well as use the camera itself for focusing if you can (or want), and use only one servo for the zoom. Then if you add the ability to control Nikon and Canon DSLR's via USB you have all your bases and possibilities covered.

Brian202020 (author)Brian2020202012-05-03

I was just thinking again about this and you'd have to add buttons on the box itself to simulate some of the classic controller buttons to set the focus and zoom syncing for the LANC input.

grp19 (author)Brian2020202012-05-03

Hey Brian202020, Thanks for your comments and your suggestions. The advantage of using the Wii Classic is that you get 2 joysticks and basically 12 buttons while using only 2 inputs on the Arduino (the other 2 connections are just power and ground). However, if you want to have the controller also handle some LANC functions or to handle USB commands to a DSLR (the GH2 unfortunately supports neither), it is possible to add this to the code I've written. To get you started here's an LANC implementation for Arduino: http://blog.makezine.com/2008/12/28/controlling-sony-camcorders-with-th/
No one that I know of has fully implemented Arduino-based usb control for a Canon camera, but some work in that area has definitley been done. If all you want to do is trigger the shutter (or start a video), that can be done using the remote control jack on most cameras. I'd have to do a little more research on how to do that, but if I add it to the project I will provide an update here.