Hardware h1.1

= Overview =
The device consists of three separate blocks: 
# 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, a diode, a relay, RJ-45 connector);
# 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 (just for the connectors: RJ-45 and 2.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".)
# 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.
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 (2 wires), and reading the limiting switches on the rail (two wires). Either straight or crossover cables can be used (for that, I had to carefully plan which pins to use for which functions - I wanted a zero chance to burn my camera's circuits by using a wrong cable). One of the important advantages of Cat 5/6 patch cables compared to many other types of cables is the fact that Cat 5 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):
Part 	Price ($)	Comments
Velbon Super Mag Slider 	109.93 	Likely the cheapest decent quality manual focusing rail you can find. Has both a focusing knob (this is the one which will be driven by the stepper motor in this project) and a side motion knob (remains fully functional in this project). The rail remains fully functional for its original purpose (manual focusing) after the modifications; one has to simply unscrew the motor unit and remove the two micro-switches glued to the plastic cover of the rail.
Stepper motor 	7.17 	Ultrathin 2-Phase 4-Wire 42 Stepper Motor 1.8 Degree 0.7A; diameter of the shaft is 4 mm
Arduino Uno R3 (knockoff) 	4.39 	
Nokia 5110 display 	2.50 	LCD display. Be careful - different models have different pin numbering, so only pay attention to the names of the pins, not their numbers!
EasyDriver v4.4 (knockoff) 	1.15 	Stepper motor driver. Has a tiny pot which I set to the maximum motor current (0.7A), to maximize the torque. Some parts can get extremely hot (>100 C) which is normal.
8 batteries box 	2.49 	Very convenient 8-AA battery holder: flat, the size matches nicely that of the controller enclosure, has a power switch, the power plug matches exactly the power socket of the Arduino Uno board. I attach it to the bottom of the controller unit using a few Velcro pads.
4x4 keypad 	2.68 	These are real (comfortable) keys, not a cheap membrane keyboard.
Relay SIP-1A05 	0.99 	To operate the camera shutter. In my design (works with my Canon 50D camera), I placed it inside my controller unit (with a diode and 33 Ohm resistor). If you have a camera which requires both shutter and autofocus wires to be grounded to make a shot, you should modify my deisgn: get two relays (use one diode and one 33 Ohm resistor for both) and put them inside the motor unit; operate both with a single Arduino pin.
Female headers 	0.99 	To make female connectors for your controller unit, to connect different boards.
Two headphone jacks 2.5 mm 	1.30 	See my warning. I already received a replacement: 3.5mm true stereo socket + matching jack, and will upgrade my design soon
Motor coupler 4-7mm 	2.68 	This coupler likely will not work for you. You'll have to find a coupler with the 4mm hole on one side (for the motor shaft), and a hole matching the screw you attach to the focusing knob on the other side.
Two RJ45 sockets 	1.98 	One goes inside the motor unit, the other one - inside the controller unit.
Ten M3x35 bolts 	3.48 	The stepper motor's four M3 bolts are too short (if you use brackets 2mm thick or thicker to attach the motor to the rail); I used these longer ones instead (you only need two).
Fifty M3 x 12mm countersunk machine screws	3.00 	Great to attach boards to the plastic controller unit enclosure, and DIY aluminum motor unit enclosure, so that the bolt heads are not protruding.
Plastic enclosure, 135x80x32mm 	3.81 	Probably the smallest enclosure you can find on ebay which would fit all the controller unit boards.
I already had some other parts (resistors - 33, 330, 1k, 5 x 10k, 275k, 475k; capacitor - 0.1 uF; diode - 1N4004; 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) 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 =
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 with two connectors (RJ-45 and 2.5 mm phone) 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 external connectors (RJ-45 and 2.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 - around 3mm - 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.
==Schematic ==
https://farm1.staticflickr.com/638/21989801954_5a1076dff4.jpg
== Wiring ==
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.
In a straight Ethernet patch cable, each wire will go to the corresponding pin of the second RJ-45 socket. A cross-over patch cable will have the following two pairs of wires swapped:
 1 <-> 3
 2 <-> 6
I created my RJ-45 pin assignment in the way that either straight of cross-over cables should work:
* 1,3* (white-orange - white-green): camera shutter
* 2,6* (orange - green): microswitch
* 4,5 (blues) : motor A
* 7,8 {browns): motor B
(*): order swapped in a cross-over cable (instead of 1,3 you get 3,1 etc.)
= 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 "Schematics" and "Wiring" sections 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, a female header for the 6-wire cable to go to the LCD display, and relay + 33 Ohm resistor + 1N4004 diode - for camera shutter triggering. 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, as some of them can have different wiring (crossover / straight). I used the RJ-45 pins in the way that both crossover and straight Cat5/6 cables should work properly, but you never know!
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 ==
https://farm6.staticflickr.com/5680/23616365925_35e3461e57.jpg
== Wiring ==
=== Keypad to Arduino ===
Keypad pin	Arduino pin
1 	A2
2 	A3
3 	A4
4 	A5
5 	4
6 	7
7 	12
8 	A1
 
=== Nokia 5110 LCD to Arduino ===
Different Nokia 5110 boards have different pin numbering, so be careful!
LCD pin	Arduino pin
VCC 	3.3V
GND 	GND
 
=== Nokia 5110 LCD to breadboard ===
Different Nokia 5110 boards have different pin numbering, so be careful!
LCD pin	Breadboard pin	Via resistor	to Arduino pin
SCE 	1 	10k 	Ground (on the LCD)
RST 	2 	10k 	6
DC 	3 	10k 	5
DN 	4 	10k 	11
SCL 	5 	10k 	13
LED 	6 	330 	9
Reference: https://learn.sparkfun.com/tutorials/graphic-lcd-hookup-guide
=== EasyDriver v4.4 motor driver to Arduino ===
Driver pin	Arduino pin
M+ 	Power Plug +
GND 	Power plug GND
STEP 	0
DIR 	1
ENABLE 	2
 
=== Motor driver to breadboard (to RJ-45) ===
Driver pin	RJ-45 pin
A1 	4
A2 	5
B1 	7
B2 	8
 
=== Relay SIP-1A05 ===
https://c2.staticflickr.com/6/5660/22351066681_9ab3378e7a_o_d.png
Diode: 1N4004
Reference: http://www.forward.com.au/pfod/HomeAutomation/OnOffAddRelay/index.html#DDreeds
=== Limiters: RJ-45 (breadboard) to Arduino ===
RJ- pin	Arduino pin
2 	[GND from breadboard]
6 	8
 
=== Battery sensor (directly soldered to the bottom and top of the Arduino board) ===
https://c1.staticflickr.com/1/687/22152355160_999f9b30d2_o_d.png
 R1 + R2 ~ 500 kOhm; (R1+R2)/R2 ~ 2.4
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.
See my warning about the 2.5mm stereo phone socket
Changed from the previous hardware version