Hardware h1.2

# Overview

The device consists of three separate blocks:

1. **The controller unit** (125x80x32 mm plastic enclosure), containing most of electronics: Arduino Uno R3, EasyDriver motor driver board, Nokia 5110 LCD display, 4x4 keypad, and a small breadboard with a few components (resistors, capacitors, and an RJ-45 connector);
2. **The motor unit**: stepper motor attached to the Velbon Mag Slider macro rail with two steel brackets and a shaft-to-focusing-knob coupler, in an aluminum DIY enclosure, with a small breadboard (two relays, two diodes, two resistors, connectors: RJ-45 and 3.5mm stereo-phone socket, to connect to the camera.) The other addition is two limiting micro-switches glued to the plastic top of the macro rail - this is essential to prevent the rail hitting the two physical limits while in operation. (Once properly calibrated, the rail is programmed to never hit the switches. Re-calibration should be rarely required, and is easily accomplished by pressing a two-key command "#C".)
3. **The battery unit**: a flat plastic enclosure for 8 AA rechargeable batteries, with a switch and a plug matching the power socket on Arduino board. This can be attached to the bottom of the controller unit using Velcro pads. The whole module was purchased on ebay; no modifications were required. The macro rail can also be powered with an external AC-DC adapter which produces ~12.0V without load and at least 1.5A.

I use a standard Ethernet (Cat 5/6) patch cable to connect the controller unit to the motor unit (this is the only cable connecting the two modules). The cable has 8 wires, and handles everything: driving the stepper motor (4 wires), driving the camera shutter and autofocus (two wires), reading the limiting switches on the rail (one wire), plus the common ground wire. **Only straight 8-wire Ethernet patch cables can be used** (with my design, connecting a crossover cable by accident shouldn't damage anything, but don't take any chances!). One of the important advantages of Ethernet patch cables compared to many other types of cables is the fact that Cat 5/6 connectors securely lock to sockets, so the chance of disconnecting during the rail operation is minimized. This is critical, as disconnecting the stepper motor cable during its operation will likely fry the motor driver circuits. The controller unit is programmed to detect if the cable is not attached to the motor module when it is powered on, and produce a corresponding warning.

Here is the list of the essential parts I used (USD; prices include shipping):

I already had some other parts (nuts and bolts, wires, sheet metal for DIY brackets and metal enclosure, breadboards etc.). I couldn't find good micro-switches (small enough, but with fairly long levers - should have at least 2 mm travel distance) on ebay, but I managed to find good ones in a local surplus store, 1$ apiece.

The essential non-trivial tools you'll need:

* **Drill press with a drill press vise.** I almost ruined my Velbon Mag Slider by trying to drill the holes for the motor brackets with a hand-held drill. The Velbon is made of a special kind of hardened magnesium alloy, with the nasty property that when one uses a hand drill to make a hole, the drill bit travels a lot sideways (can be 2-3 mm), which will make it impossible to attach motor brackets properly. I ended up buying a drill press because of this. (But I always wanted to have one.) With a drill press one can do a much better job - just make sure the head doesn't move much sideways (<0.5 mm), and make the exposed part of your drill bit fairly short (so it doesn't bend much).
* **Taps and dies set.** You'll need these to cut a thread (M4 is about right) in the Velbon rail, for four bolts, to attach two motor brackets to the rail.
* **Fret saw (or coping saw)**: to make rectangular holes in the plastic (controller unit) and aluminum (motor unit) enclosures - for two RJ-45 sockets, USB socket, Nokia LCD display, and 16-keys keypad.

# Motor unit

**Warning**: the photographs below show the original hardware version 1.0 (h1.0). For the accurate instructions for the current hardware version, refer to the "Schematic" section below.

View from the top:

https://farm1.staticflickr.com/624/22415906356\_6bec5e1f26.jpg

View from the side (bottom part of the rail attached):

https://farm6.staticflickr.com/5772/22428636112\_3809ef3343.jpg

https://farm6.staticflickr.com/5619/21819185734\_437afa13b0.jpg

View from the bottom (bottom part of the rail detached):

https://farm6.staticflickr.com/5766/22452813701\_718a1b6664.jpg

The most critical step (don't do anything else until/unless you've succeeded with this one): proper coupling between the stepper motor and the focusing knob of the Velbon rail. Unfortunately the core of the focusing knob is made of (very hard) plastic, not metal:

https://farm1.staticflickr.com/540/19024458298\_c5459b24db.jpg

In addition, it has a hole in the middle (you'll see it once you remove the rubber covering of the knob), so one has to be very careful with creating the coupling to the motor:

https://farm1.staticflickr.com/321/19025886439\_bd4f33db1a\_n.jpg

May be I was lucky, but I happened to have some old steel furniture screws laying around, with the threaded part which fitted perfectly the hole inside the focusing knob. I just had to carefully screw the bolt into the hole keeping it parallel to the knob axis, until the wider screw part touched the end of the knob:

https://farm1.staticflickr.com/384/19215708001\_20f05116d3.jpg

I didn't use any glue. At the end, the screw was sitting almost perfectly parallel to the knob's axis, and very tight (I couldn't turn it with my hand):

https://farm1.staticflickr.com/536/19024399990\_ef614035c9.jpg

Another great feature of the screw was that the non-threaded part is a solid metal with exactly 7mm diameter. I managed to find on ebay a nice metal coupler from 7mm to 4mm (the shaft diameter of the stepper motor I used) which worked perfectly with the screw I had (I just had to cut off the head of the screw). I couldn't find identical furniture screws on ebay, but hopefully you can find something similar in a local store, or perhaps will come up with another idea on how to couple the plastic knob with the motor.

For the best possible coupling, I shaved a bit of metal off on one side of the screw, and on one side of the motor shaft. Warning: the motor shaft is made of extremely hard steel, so no regular file will work on it (perhaps a diamond file will do the job - if you have one). I ended up using a sharpening stone, and spent quite a bit of efforts shaving off a small amount of steel from one side of the shaft. At the end it was worth the efforts as the coupling was very secure (once you tightened the small bolts inside the coupler).

**Warning:** before doing anything to the focusing knob, you have to remove it from the Velbon rail - otherwise you will likely damage the mostly plastic bearings inside the rail. Once you attached the screw to the knob, cut off its head, and shaved off one side, you can put the knob back into the rail. Check the post #3 here for the instructions on how to remove the focusing knob from the rail.

The next critical step is to find (or make - as I did) two metal (best if steel or iron) brackets shaped like this : [ ] . They should be thick enough (probably at least 1.5 mm; I used 3mm iron) to provide a good support to the motor unit, and should be made with a high accuracy: the longer side should have the same length for the both brackets, and the shorter sides should be exactly parallel to each other, for each bracket. On one side the short ends will be attached to the Velbon rail (to the left and to the right from the focusing knob); you'll have to use a drill press to make four holes in the Velbon rail (very close to the edges of the rail - make sure the holes don't go inside the rail and potentially damage the rail's bearings), and then use taps and dies set to cut a thread inside the holes (I did M4 threading). The stepper motor will be attached to the opposite shorter sides of the brackets. (I used only two diagonally placed bolts in the motor to attach the motor to the two brackets; the remaining two bolts were left unattached).

**Warning:** if you use a fairly thick (2mm or more) metal for the two brackets, the length of the exposed part of the M3 bolts in the stepper motor will not be sufficient to attach the motor to the brackets. I ended up ordering some M3x35mm bolts on ebay and replacing two of the motor bolts with these, longer ones.

The length of the longer side of the brackets will be determined by the length of the exposed part of the focusing knob + the length of the exposed part of the screw you put inside the focusing knob + the length of the motor shaft. You don't have to be super-accurate here, as the coupler gives you a bit of a leeway in terms of the distance between the motor and the rail. Drilling the two holes for the motor in the short sides of the brackets should be the last operation here: you want to find such locations for the holes that the motor shaft is almost exactly on the same axis as the focusing knob, or else the motor will not have enough of torque to move the rail. I accomplished this step by securing the coupler to the motor shaft (tightening a bolt), inserting the screw put inside the focusing knob inside the coupler (don't secure it with a bolt), and then finding the positions for the two holes on the short sides of the brackets for the two motor bolts.

This is how it looks like assembled:

https://farm6.staticflickr.com/5749/21819177224\_c0929bdfeb.jpg

The remaining steps are much less critical. One can put a metal (better aluminum) enclosure around the brackets, which has multiple purposes:

* It simplifies attaching the small bread board to the motor unit.
* It makes the motor attachment to the rail more tight and secure.
* It hides all the wiring inside.
* It prevents you from turning the focusing knob by hand - this is bad because it breaks the rail calibration, and it can also burn your motor driver (by induced voltage) if the controller is attached to the motor unit.
* It looks nicer and more professional.

**Warning:** when designing the brackets and the enclosure, make sure that the bottom part of the assembly doesn't protrude below the bottom of the rail (specifically the top part of the rail, with the focusing knob), otherwise you won't be able to use the detachable bottom part of the rail, with the manual knob to move your camera sideways:

https://farm1.staticflickr.com/573/22253937830\_101fbc541b.jpg

This is not absolutely essential, but it would be a pity if the bottom part of the rail was wasted, and the sideway motion knob does simplify the job of macro-photography.

Then you should make a small breadboard and solder there the two relays, two diodes, two resistors, two external connectors (RJ-45 and 3.5 mm phone) and ideally a couple of internal connectors (for the motor and the limiting micro-switches; this will make it easier to disassemble the motor unit):

https://farm1.staticflickr.com/741/22199807430\_05cb9bb27a.jpghttps://farm1.staticflickr.com/566/22199805000\_7a05b37e71.jpg

https://farm1.staticflickr.com/671/22452812631\_d5fdb71f15.jpg

https://farm1.staticflickr.com/694/22255087809\_8ecd458d93.jpg

Finally, you need to attach the two limiting micro-switches to the rail, in a way that one of them would be triggered before the rail hits one of the physical limits. When a switch is triggered, there still should be enough of travel distance - 2 mm or more - left for the rail to properly decelerate and stop. The only way I could attach my micro-switches to the rail was by gluing them with a super-glue to the plastic cover of the rail, at a slight angle (to ensure there is the required 3mm gap when the switch is triggered). This worked pretty well:

https://farm1.staticflickr.com/706/21820750243\_d77af9eae3.jpg

Then you have to solder the switches sequentially, in a way that normally (when switches are not engaged) the two wires going to the controller unit would be shorted, and only if one of the switches is triggered the connection would be broken. This is used by Arduino to calibrate the rail (to make sure that the rail will never trigger the switches during its normal operation.) With time the calibration will be lost, so a re-calibration would be required once in a while. Calibration is triggered automatically if during its normal work the moving rail will trigger one of the switches, or one can request a re-calibration manually.

# Controller unit

**Warning**: the photographs below show the original hardware version 1.0 (h1.0). For the accurate instructions for the current hardware version, refer to the "Schematic" section below.

https://farm1.staticflickr.com/713/21820758783\_77c80d3e58.jpg

https://farm6.staticflickr.com/5741/22415911926\_bff7952648.jpg

https://farm1.staticflickr.com/640/21819190094\_af419cdb30.jpg

I managed to fit all other components (except for the batteries module) inside a small (125x80x32 mm) plastic enclosure from ebay:

https://farm1.staticflickr.com/749/22253928730\_e8ca2e52a2.jpg

Bottom part, cables attached:

https://farm6.staticflickr.com/5823/22452804821\_1fba2e0974.jpg

Removable cables detached:

https://farm6.staticflickr.com/5670/22415886926\_3036e82e23.jpg

Only one cable (Cat 5/6) is connecting the controller unit to the motor unit, and one cable is connecting it to the power source (the battery module, or 10-12 V AC power adapter.) There are three boards inside, all attached to the bottom of the enclosure via ~5 mm long plastic spacers:

* **Arduino Uno R3** knockoff board. The size of the enclosure is perfect in the sense that the Arduino board fits it nicely in the landscape orientation, with the USB and power sockets accessible from the outside (once you cut the corresponding holes in the side of the enclosure - use fret/coping saw for the rectangular hole).
* **EasyDriver v4.4** knockoff board (motor driver). This board is extremely small, and a bit of a challenge to attach to the enclosure: I ended up shaving the sides of two M3 nuts to prevent them from shorting circuits on the board. There is a tiny pot on board (motor current regulator). I set it to the largest motor current (0.7A), to maximize the motor's torque. See Question 5 at the bottom of this page: http://www.schmalzhaus.com/EasyDriver/ .
* **Breadboard** with some other components soldered in: RJ-45 socket, a few voltage limiting resistors to connect the 5 V Arduino to the 3.3 V Nokia LCD display, and a female header for the 4-wire cable to go to the LCD display. This board is attached at the top of the enclosure.

Bottom view on the three boards:

https://farm1.staticflickr.com/599/22199806860\_c54411bf36.jpg

Two more components are attached to the top part of the enclosure (you'll have to make corresponding rectangular holes for them, with fret/coping saw):

* Nokia 5110 LCD module.
* 4x4 keys keypad.

https://farm1.staticflickr.com/702/22441885575\_d3d03fa4b0.jpg

The most time consuming part here is soldering all the required connections between these five components.

The power for the motor driver is taken directly from the Arduino's power plug. You'll have to solder the two wires, for - and +, directly to the Arduino plug, on the bottom of the board.

You have to check and recheck multiple times all the connections before attempting to power it on for the first time. It is especially critical for the camera shutter connectors: **make it absolutely sure you are not sending high voltage inside your DSLR by mistake**. Test this with any new Cat5/6 cable you plan to use with the rail.

**Warning:** never let anyone to attach your rail to a networking device (computer, laptop, router) via Cat5/6 cable! I use RJ-45 sockets and Cat5/6 cables here for convenience; they have nothing to do with Ethernet. If somebody does attach the rail to another device, this will most likely burn the networking board on that device, and might also burn the motor driver in the controller unit. It wouldn't hurt to put a red label on your controller unit next to the RJ-45 socket with such a warning.

# Schematic

The schematic was drawn using the online software SchemeIt.

https://farm2.staticflickr.com/1662/24110281681\_5e3cd2450e.jpg

## RJ-45 sockets

RJ-45 socket (view from the bottom of the breadboard):

https://c2.staticflickr.com/6/5690/22314781196\_4be86083ca\_o\_d.png

This is the wiring I did for the RJ-45 socket I got on ebay. The one you have might have a different layout.

**You can only use a straight (not crossover) Cat5/6 patch cable!**. Test first any cable you plan to use with the rail.

Here is the RJ-45 pin assignment:

* 1 (white-orange): camera shutter
* 2 (orange): common ground
* 3 (white-green): camera autofocus
* 6 (green): micro switches
* 4,5 (blues) : motor A
* 7,8 (browns): motor B

The pin assignment was done to minimize the risk of damaging anything if you by accident connect a wrong (crossover) patch cable. In a crossover patch cable, the following pins are swapped: 1<->3, 2<->6. As you can see, using a crossover cable will render the macro rail non operational, but will not send the high voltage / high current motor signals to a wrong destination. Still, better be safe than sorry, so always test any Cat5/6 cable you plan to use (to make sure it is a 8-wire straight cable) before using it in your rail!

## Nokia 5110

Different Nokia 5110 boards have different pin numbering, so be careful!

In h1.2, LCD's SCE pin is permanently soldered to the ground via a 10k pull-down resistor R9, and RST pin is powered via RC delay circuit (R10=47k, C2=0.1uF -> delay 3.3 ms; my LCD works fine with R10=30k...680k; it is best to choose a lower value for R10 from this range, with a bit of leeway to account for environmental changes) from +3.3V (VCC). You might need to adjust the values of R10 and/or C2 if your Nokia 5110 board requires a substantially different delay to work properly. I soldered most of these components directly to the Nokia board.

Original Nokia 5110 wiring reference: https://learn.sparkfun.com/tutorials/graphic-lcd-hookup-guide

## EasyDriver

For the motor driver (EasyDriver v4.4), solder M+ pin directly to the "+" pin of the Arduino board power plug, and GND pin - directly to the "-" pin of the Arduino board power plug.

EasyDriver reference: http://www.schmalzhaus.com/EasyDriver/ .

## Battery sensor

Battery sensor consists of a passive voltage divider (resistors R3, R4) with high enough total (R3+R4) impedance to make energy losses negligible, and with the ratio R4/(R3+R4) chosen to make the largest expected power voltage (~13V) fit within the allowed range for the input pin voltage for Arduino (0...5V), after the divider. I also added C1=0.1 uF parallel to R4 to reduce the measurement noise. I soldered all these components directly to the Arduino board.

Original reference: http://electronics.stackexchange.com/questions/154371/lower-voltage-with-a-zener-diode

# Battery unit

https://farm6.staticflickr.com/5645/21819188204\_f15cb4d645.jpg

Nothing to do here - just buy and use one of those 8-AA battery flat enclosures with a switch and a cable with a plug. Double check that the polarity of the plug matches that of the Arduino power socket.

# Electronic shutter adapter

Starting from s1.14, my rail supports Full Resolution Silent Picture mode of Magic Lantern (alternative firmware for Canon cameras), which is basically electronic shutter (great for extending the lifespan of your camera when doing focus stacking). Very importantly, I figured out and implemented a way to use the electronic shutter with an external flash, which is a must for focus stacking. This required a new software feature - mirror\_lock=2 mode, and soldering a simple adapter consisting of one 3.5mm stereo jack, one 3.5mm stereo socket, and a hot shoe for flash (I use it to connect it to my RF flash controller, YN-RF603, which wirelessly triggers my flash, YN-560III). The purpose of the adapter is to let the shutter relay inside my rail to operate an external flash. (Under FRSP, photos are taken by using the AF switch, not the shutter switch.)

Here is the schematics for the adapter:

https://farm2.staticflickr.com/1510/25251015024\_b33d2d1041.jpg