I thought it was time that I set down the list of parts that were used to build my focus-stacker. The cost was less than £120. If you live in the USA you could probably do it for the same in dollars – or less! And it does depend a lot on what you have lying around at home that you can use for this project. I have not included anything to do with lighting or camera equipment other than the IR trigger. Most of the parts were purchased on e-bay with some like the Pi itself coming from Amazon. You do need to check when purchasing cheap electronic parts on e-bay to make sure they are not coming from Hong Kong if you want them quickly. Shipment from HK can involve up to a ten week wait for the item to be shipped surface, though sometimes items arrive remarkably quickly. Factor shipment time from HK into you procurement and build schedule if going down that road.
For the working parts – electronics, motor and rack drive:
Raspberry Pi RBCA000 ARM 1176JZF-S Motherboard 512MB RAM – £ 27.39
8GB SDHC SD Card pre-loaded with Raspbian “wheezy” Linux operating system – £8.29
iZKA® High Power Micro USB UK Dedicated Mains Power Wall Supply Charger For Raspberry Pi – (5V / 2.1A) – £6.99
40 wire ribbon cable Male to Female with ends broken out to individual contacts – £4.99
40 wire ribbon cable Female to Female with ends broken out to individual contacts – £4.99
Arduino 5V 4-Phase Stepper Motor with ULN2003 Control Board – £6.90
I have finally got round to drawing up the electrical schematic diagram for the focus stacker showing how my Raspberry Pi is connected to the various component that form part of my stacker. Please check very carefully before using any of this information. It works for me but may not for you! The information is shown on this page.
There has been a lot of progress, and the build and testing are advancing.
The new 2-channel Sainsmart relay module arrived; it worked perfectly without any difficulties, so I must assume that the cheepo version was defective out of the box. With all the hardware now available the only thing left to do was to connect up the Pi. To reduce the chances of getting something seriously wrong I prepared a table of connections to the Pi GPIO header so I knew exactly which wire went where, with insulation colours, pin numbers and destinations all clearly defined. I have decided to adopt the header pin number rather than the BCM2835 nomenclature in the software GPIO code as this seems an easier to understand option; less likely to cause confusion when connecting up the header ribbon cable; and easier to double check between code and hardware wiring. Then it was a matter of connecting things up carefully and testing them one at a time in the order motor, relay module, and individual inputs and outputs.
Except that all did not go exactly according to plan!
Having connected up the motor control board to the Pi, it was necessary to move to a new version of my programme which replaced the code for the “virtual” motor with the code for the correct GPIO callouts for my stepper motor controller. When I tried to run the new version, the Pi helpfully reported back that the programme needed to run in root because GPIO had to be controlled from there. That was quite easy to do by running the programme with the prefix “sudo”. However when I did that, my remote terminal running MobaXterm threw up the message:
X11 connection rejected because of wrong authentication…..
So now the Laptop could not display the GUI. That had worked fine when running from the Pi home directory. It seemed like an impossible conflict of demands. Googling the problem just returned a small number of results which just added to my confusion with no solution that I could understand how to implement and why it would work; I don’t like implementing things that I don’t understand! Luckily, Jim came to the rescue and provided a very simple and easy to implement solution that did the trick immediately. All I had to do was add a line at the end of the file .profile that lives on the pi in /home/pi: export XAUTHORITY=/home/pi/.Xauthority
A quick reboot and then we were off! Over the course of several days the various peripherals were connected and tested, and the Python 2.7 code modified here and there to introduce the GPIOs one by one and to fix the bugs that came with them that had not surfaced earlier.
Everything is now working more or less as intended. However, the stepper motor does seem to run quite slowly, even with the minimum time interval between pulses. I can implement either of two gearing options with different pulley sizes and I have swapped over to the step up ratio rather than the 1:1 ratio that it started with. The difference is that it now takes 450 motor steps per mm compared to the previous 1550.
I have noticed what appears to be the effects of stiction in the gearing and the rack, which is causing a very slight jerky movement of the stage as the rubber band drive has enough give in it to allow this to happen. Jerky movement is not a problem in itself but unequal movement between successive shots would be a big problem. There is very little backlash in the gearing that came with the DVD rack and so I am fairly sure this is the result of the rubber band stretching; so I am probably going to have to replace the rubber band drive with a geared drive. Gears are on order.
Still lots to do:
Finish implementing the software – mostly minor cosmetic issues apart from error/exception handling which needs a lot more work.
Tidy up the programme software to get rid of redundant code.
Implement a routine to turn on an LED when the Pi is booted up; so that I know when it is ready to connect to the laptop.
Build the stage platform and individual detachable mounts.
Devise an alignment tool for setting the height of the specimen on its mount, so that it can be prepared elsewhere and will then align perfectly with the central axis of the lens when installed on the stage.
Figure out how to put in place and light suitable backdrop(s); ideally different backdrops for different effects for different types of specimen.
Draw some neat circuit diagrams so that in six months’ time I know what I did!
Work out a diffused lighting arrangement and make necessary diffusers; possibly ping-pong balls?
Fix the broken LED light – too much heat applied when soldering – oops.
Add a warning beeper.
Tidy up the manual remote camera shutter trigger which is hard wired. It enables me to trigger the shutter when setting up to take test shots without using the programme features and without accidentally jiggling the rig. I am looking for a nice (inexpensive) push button on a wire – the sort of thing that used to be used for advancing slides on a slide projector. Used to have one in fact, but couldn’t find it now that it might have had a new lease of life.
Replace rubber band drive with gear wheels? Then recalibrate the rig.
Here are my jottings about my photographic projects and activities. I have been working on a focus stacking macro photography rig. There are quite a few posts about that. In addition I write about other photographic activities as and when!