This project is a sub-section of my larger project on focus stacking of fern gametophytes.
This section explains what hardware is required for a Raspberry Pi-driven system, and how it is all wired up. We are only covering the electronics here and the other hardware is discussed in the main page.
This is the full setup from above. At the top, the microscope block is connected via cogs to the stepper motor. The stepper motor is then wired to a stepper motor shield, which is in turn wired to the Raspberry Pi at the bottom of the photo.
This second image shows the setup from the side. On the left is the Raspberry Pi, connected to the stepper motor shield in the centre, which is in turn connected to the stepper motor on the right. The stepper motor drives the microscope focus block via a couple of blue cogs.
The exact positions of the jumper wires on the GPIO pins of the Raspberry Pi is shown here.
The three jumper wires on the left side of the image lead to the stepper motor shield. The black and white wires on the right hand side of this image lead to the infra red camera remote control.
The stepper motor shield is shown in this image:
The jumper wires go to the GPIO pins as shown below.
The exact positions of the jumper wires on the GPIO pins of the Raspberry Pi is shown again here.
The stepper motor has four wires which are all unlabelled. It took us some work to figure out which was which, so that we could connect them to the right places. Our four wires are blue, green, red and black. They are connected to the pairs of holes labelled "A" and "B" at the bottom centre of the shield as seen in the photo above.
The stepper motor needs power to operate, and this is provided via the stepper motor shield. We used a 12V transforner plug, the wires of which are soldered directly onto the stepper motor shield. Those wires are the black wires visible in the bottom left part of the image below. They are soldered to GND and M+.
The infra red remote control is also wired up to the Raspberry Pi, so that the camera shot can be triggered automatically, after each forward movement of the camera. Each time the camera has moved forward, the Raspberry Pi triggers the infra red remote control bulb to light, causing the camera to take a shot.
The photo below shows the position of the remote control in the setup.
The two images below show how the infra red camera trigger is wired up. Tim had to take the case right off and then he soldered on wires, and firmly connected them using a hot glue gun.
The wiring is shown below.
Below is the python program that I run on the Raspberry Pi to drive the rail. I do not have a screen attached to the Raspberry Pi, so I plug in a wireless dongle and then drive it from my laptop. I log into the raspberry pi using putty and then run the scripts from there. The scripts can be modified in between runs, so that if I feel that the movement of the microscope block needs to be a bigger step or a smaller step then I can quickly alter the distance in the programme. I can also alter the timing. For example I can have 1 micron steps with a 3 second gap in between to make sure that there is time for vibration to stop, or I can have a 5 micron step for a larger subject and 1 second gap if there is a risk that the subject will dry out and change shape during the series.
Code to allow the Raspberry Pi to drive the focus stacking railPython
#!/usr/bin/env python import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) #This assigns the pins of the raspberry pie to variables called "pin". pin0 = 18 pin1 = 23 pin2 = 24 pin3 = 17 #Set these pins to send messages out rather than listen for messages coming in. GPIO.setup(pin0, GPIO.OUT) GPIO.setup(pin1, GPIO.OUT) GPIO.setup(pin2, GPIO.OUT) GPIO.setup(pin3, GPIO.OUT) #Zero all of the pins between tests. def zero_pins(): time.sleep(0.1) GPIO.output(pin0, 0) GPIO.output(pin1, 0) GPIO.output(pin2, 0) GPIO.output(pin3, 0) #This runs the test. def test(): count = 1 while (count < 10000): print 'The count is:', count zero_pins() GPIO.output(pin0, 1) GPIO.output(pin1, 1) zero_pins() GPIO.output(pin1, 1) GPIO.output(pin2, 1) zero_pins() GPIO.output(pin2, 1) GPIO.output(pin3, 1) zero_pins() GPIO.output(pin3, 1) GPIO.output(pin0, 1) zero_pins() count = count + 1 test()
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!