Focus Stacking with a Raspberry Pi – Focus-Stacker Project Parts List

    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:

    1. Raspberry Pi RBCA000 ARM 1176JZF-S Motherboard 512MB RAM – £ 27.39
    2. 8GB SDHC SD Card pre-loaded with Raspbian “wheezy” Linux operating system – £8.29
    3. iZKA® High Power Micro USB UK Dedicated Mains Power Wall Supply Charger For Raspberry Pi – (5V / 2.1A) – £6.99
    4. 40 wire ribbon cable Male to Female with ends broken out to individual contacts – £4.99
    5. 40 wire ribbon cable Female to Female with ends broken out to individual contacts – £4.99
    6. Arduino 5V 4-Phase Stepper Motor with ULN2003 Control Board – £6.90
    7. SainSmart 2-Channel 5V Relay Module – £8.00
    8. Micsc LEDs, resistors, switches, nylon stand-offs, nylon screws and bolts, solder pins, Veroboard, fibreglass sheet, and project boxes – approx £35
    9. Camera infrared remote control for Sony Alpha – £2.69
    10. Stalk for camera remote IR  – salvaged from flexible USB LED lamp £ 1.98
    11. DVD Rack – salvaged from old DVD player
    12. Misc Lego Technic gear wheels – approx £5
    13. Other miscellaneous electrical components and cable ties – from a box in my shed

    For the chassis:

    1. Aluminium channel 3/4″ x 3/4″, aluminium angle 3/4″ x 3/4″ and 1/8″ aluminium plate – all  from  my shed
    2. S/S and other hardware to hold everything together and three rubber feet
    3. Camera Rack – old Minolta rack lurking in my junk cupboard

    I will cover the software side of things in another post.

    Focus Stacking with a Raspberry Pi – Focus Stacker Circuit Details

    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.

    Focus Stacking with a Raspberry Pi – Connecting the Pi to Hardware – Testing

    There has been a lot of progress, and the build and testing are advancing.

    20140111_home_011
    Here you can see the finished wiring neatly finished with cable ties ( I hate untidy wiring!). The Sainsmart relay module in the foreground left.

    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.

    Table of wiring
    Table of wiring

    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

    20140111_home_010
    The laptop connected to the Pi via a network cable and interfacing through MobaXterm.

    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.

     

    20140111_home_012
    Everything is now functional on the control panel apart from the top LED marked PI which requires a separate piece of software code

    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.
    • Build a dust cover for the working parts
    • Find some specimens
    • Test, test, test!
    shoot seq
    Screen shot of the GUI for controlling the actual shoot sequence. The stage advances from the parked position to the first shot position and pauses so that I can check everything is good to go. If OK then a click on the “TAKE SEQUENCE” button and it shoots the rest of the sequence. Counters show progress. The GUI uses Tkinter for its implementation. Code is written in Python 2.7.
    dry-run screen
    Screen shot of the GUI for checking the set up. This is a for checking the set up after all the parameters have been chosen and before shooting the sequence.

What’s it all about?

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!

Archives

Category Specific RSS

Share


Warning: A non-numeric value encountered in /home/public/mhp_blog/wp-content/plugins/ultimate-social-media-icons/libs/sfsi_widget.php on line 238
RSS
EMAIL
Facebook
Google+
http://www.picsbymike.co.uk/mhp_blog/tag/stepper-motor-controller/">
Twitter