Home
SearchSearch MemberlistMemberlist RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in

DIY mini macrostage with raspberry pi and cd-rom stepper
View previous topic :: View next topic  


PostPosted: Tue Dec 06, 2016 12:32 pm    Post subject: DIY mini macrostage with raspberry pi and cd-rom stepper Reply with quote

This topic is a follow up of a discussion here:
http://forum.mflenses.com/viewtopic.php?t=76325&sid=49f653cb79e12b0dbafa8c8091b85ab1
As I mentioned in the above topic this project it is not my design, I've just adjusted a few online resources to my purpose.
This is not a full tutorial but more of a guide. Also : DO IT AT YOUR OWN RISK.

My setup looks like that:


The hardware diagram:


The camera uses the usb connection on raspberry pi.


Online resources used:

http://makeitgeek.blogspot.ro/2012/12/controlling-stepper-with-raspberrypi.html (main source for hardware setup and code -- credits to the article author)
http://www.schmalzhaus.com/EasyDriver/
https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/
http://www.instructables.com/id/Raspberry-Pi-photo-booth-controller/step2/Connect-the-Camera/ (the part about gphoto2 install; Raspbian repository package didn't work for me, this tutorial did )
http://www.gphoto.org/ (for list of supported cameras, commands and options)

Materials:

- Raspberry Pi 1 model B + sdcard > 4GB . I guess any Raspberry PI model will do. you'll have to conform to the specs/pinout of other models / versions.
- Easy Driver from Sparkfun . I've already had this one laying arround. Other stepper motor drivers could be used adapting everything to their specs.
- Old but working CD-ROM drive. There are lots of old IDE drives incompatible with modern PC mainboards.
- some system to place the subject on to the stage. I'm using some helping hands.
- Breadoard
- 2x 1 Kohm resistor ( ceramic type ). I think it will work without them but is safer to protect the raspberry's GPIO
- some male-female breadboard friendly wires (arround 15-17 pc.)
- soldering iron and solder (I use a low power soldering iron arround 30W to avoid burning things)
- 2x DC 5V 1A-2A power supplies. One is for raspberry and the other one is for the driver and motor. I use 2 old 5v 1A switching power supplies. Some say 1A it is not enough for raspberry nor for driver + motor. They work for me.

The code is a executable shell script and it looks like this (for now):

Code:
#!/bin/sh
pause=0.0001
pause2=0.0001
pauseaftereachpicture=7
#numberofpic=$1
#stepsbetweenpics=$2

numberofpic=35
stepsbetweenpics=2


#gpio 25 ms1
#gpio 22 ms2
#ms1 ms2 resolution
#0   0    full
#1   0    half
#0   1    quarter
#1   1    eight

gpio -g mode 22 out
gpio -g mode 23 out
gpio -g mode 24 out
gpio -g mode 25 out
echo $numberofpic
echo $stepsbetweenpics

for i in $(seq 1); do

echo round $i starts:
sleep 2

gpio -g write 25 1
gpio -g write 22 1

gpio -g write 24 1
for i in $(seq $numberofpic); do
  echo captura picture: $i
  gphoto2 --capture-image
  sleep $pauseaftereachpicture

  for q in $(seq $stepsbetweenpics); do
    echo picture: $i step: $q
    gpio -g write 23 1
    sleep $pause
    gpio -g write 23 0
    sleep $pause
  done

done
sleep 1

gpio -g write 25 0
gpio -g write 22 0

gpio -g write 24 0
returnsteps=$((($numberofpic * $stepsbetweenpics) / 8))
for i in $(seq $returnsteps); do
  ri=$(($returnsteps - $i + 1))
  echo $ri
  gpio -g write 23 1
  sleep $pause2
  gpio -g write 23 0
  sleep $pause2
done
done


The variables names are to long; I've translated them in english to be intuitive; It will be better to change them in someting shorter. A cleaner code nicely commented would be better ...

Some observations:
- don't forget to solder the 3/5V jumper on Easy Driver. It must use the logical voltage of Raspberry Pi that's 3V3
- the hardware connections must be perfect. A motor wire disconnected while the easy driver is powered on will burn it
- check the circuit for short.
- don't remove or add wires while any component is powered
- when soldering the wires to the motor pins don't remove the original ribbon cable. Solder over it and insulate the end of the cable.
- the setup is slow compared to low-level controllers, but if you use a flash the raspberry will have to wait for it to recycle anyway. My Nissin recycle time is about 5-7 sec. so the script and motor speed are not crucial.
-don't forget to connect your camera via usb to raspberry pi and check the standby time. If camera is in standby gphoto2 will return errors.

This is more of a toy, it is far from the professional solutions on the market, but is cheap and fun to play with. I've decided it's worth a try. You make your own decision Smile


PostPosted: Fri May 12, 2017 5:40 am    Post subject: Reply with quote

I had some spare time and took 2 stacks with this. Here are some downsized results (originals are 15 megapixels):




#1


#2


PostPosted: Fri May 12, 2017 5:57 am    Post subject: Reply with quote

Impressive, looks good! I lift my hat that you made this!! Like 1 small Like 1 small Like 1 small

I simply bought a StackShot a while ago and used it a few times, but haven't done much with it.
https://www.cognisys-inc.com/products/stackshot/stackshot.php

Friend of mine now makes a high resolution stacker, less 1 micron resolution!
http://www.stonemaster.eu/products/stackmaster
Also has some easy to use software for it made.


PostPosted: Fri May 12, 2017 7:48 am    Post subject: Reply with quote

Thanks Klaus !
It seems that the rather flimsy setup did what it had to do.
As a note: the stack was shot with nikon cfi e plan 10x wd 7.0 used at ~5:1 ratio with Nikkor 105/2.5 Ais as a tube lens (DIY adapter for the CFI lens). Subject size: ~3-4 mm. Using Kiron 105 as a tube lens the results were softer (diffraction maybe?).


PostPosted: Fri May 12, 2017 9:00 am    Post subject: Reply with quote

Awesome.

I have in my plan to make one of these, and a drop rigg as well.
I use mostly Arduino.


PostPosted: Fri May 12, 2017 9:16 am    Post subject: Reply with quote

lucca1x wrote:
Thanks Klaus !
It seems that the rather flimsy setup did what it had to do.
As a note: the stack was shot with nikon cfi e plan 10x wd 7.0 used at ~5:1 ratio with Nikkor 105/2.5 Ais as a tube lens (DIY adapter for the CFI lens). Subject size: ~3-4 mm. Using Kiron 105 as a tube lens the results were softer (diffraction maybe?).


Surprising that the Kiron delivered softer results? Ideally a 200mm lens should be used, as this is the ideal tube length for infinity objectives. Also the cheap(er) Raynox DCR-250 achromatic diopter is very good as such a lens. Bit tricky to mount, but my friend sells a special adapter for it.


PostPosted: Fri May 12, 2017 10:29 am    Post subject: Reply with quote

Indeed a 200mm tube should be used, but it comes with 10:1 ratio, this mean under ~2mm subject size ... I'm more comfortable with 5:1 ratio.
This was taken with Kiron as tube lens:

I know is to small to judge the sharpness...
It is also said the dedicated macro lenses are not great as tube lenses, perhaps the recessed front element has something to do with it.


PostPosted: Fri May 12, 2017 4:10 pm    Post subject: Reply with quote

Thanks for sharing your work -- your first post can be used as a form for any rp project! The toys that can be made...