Building a photography macro rail for focus stacking (Part 2 - Prototyping)

avatar
(Edited)

Hi, and welcome to the fun part of this - building something that does stuff.

Part one of this series is here

Setting up the stepper motor

IMG_2937.JPG

The Nema 17 stepper motor

The stepper motor I am using for this test is a Nema 17 for which you can find the specification here.

As mentioned in the previous post, this motor has 1.8° steps, so 200 steps per full rotation. It has two coils in it, hence 4 wires, a +ve and -ve for each coil. You can work out which two wires are on the same coil quite easily. The motor spins freely when not connected to anything. If you touch two of the wires together and they are on the same coil, there will be increased resistance when trying to turn the motor.

In order to control a stepper motor with an Arduino, you need a stepper motor driver. I'll be using the common A4988 driver which has pinouts as per below.


image.png


The A4988 requires 5 volts to power the board and uses a higher voltage to power the motor itself. I'll take the 5 Volts from the Arduino and use a 12V plug to power the motor. The ones I am interested in are as per below
PinDetails
GNDGround for the 5-volt circuit - so connected to the Arduino GND terminal
VDD+5v from the Arduino to power the driver
GNDGround for the higher voltage circuit so connects to the 12v power source
VMOT+12v from the power source
1A/1BCircuit for motor coil 1
2A/2BCircuit for motor coil 2
DIRSet the direction of travel on the motor - set to high or low from the Arduino
STEPArduino sets this to high to do a single 1.8 degree step

The other pins are of no use to me at this time but you can find out what they are on any A4988 datasheet

The one thing you do need to do before running is to ensure that the current being sent to the motor is not so high as to burn out the windings. To do this, you have to find the max current for the motor specifications (in my case 1.2 amps) and then divide by 2. This gives you a "reference voltage" of 0.6 V. On the top of the driver there is a small potentiometer that you can turn. If you measure the voltage from the potentiometer to ground then you can see how this adjusts the reference voltage when you turn it.

Breadboard layout and a quick bit of test code

So here is the basic stepper motor diagram (created in Fritzing) and some very basic code just to test the motor is working. It does a full rotation in one direction and then two full rotations in the other direction
Screenshot 20191014 at 10.49.56.png

// defines pins numbers
const int stepPin = 3; 
const int dirPin = 4; 


void setup() {
 // Sets the two pins as Outputs 
  pinMode(stepPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);
}
void loop() {

    /* 
     *  Enables the motor to move in
     *   a particular direction
     */
    digitalWrite(dirPin,HIGH); 

    /*
     * Make 200 pulses for making one full cycle rotation
     */
    for(int x = 0; x < 200; x++) {
      digitalWrite(stepPin,HIGH); 
      delayMicroseconds(1000); 
      digitalWrite(stepPin,LOW); 
      delayMicroseconds(1000); 
    }
    delay(1000); // One second delay

    /*
     * Changes the rotations direction
     */
    digitalWrite(dirPin,LOW); 
    /*
     * Make 400 pulses for making two full cycle rotation
     */
    for(int x = 0; x < 400; x++) {
      digitalWrite(stepPin,HIGH);
      delayMicroseconds(1000);
      digitalWrite(stepPin,LOW);
      delayMicroseconds(1000);
    }
    delay(1000);
 
}

So the final result of this is shown in the gif on the right here. I've added some black tape to the motor shaft so that you can see more movement.

The next thing to consider here is what kind of functions we will need to implement on the rail itself. At the moment I can think of a few

  • Move the rail manually to a certain position - so a couple of buttons to press to hold down to move the rail forwards and backwards.
  • A way of manually setting the distance to move (in mm) and the number of steps to photograph during that movement
  • A cool thing would be to be able to set markers - so move the camera to the nearest focus point, set a marker. Move the camera to the farthest focus point, set a marker. Tell the app how many images you want and hit 'GO'. The app will then move the camera through from the front to the back without you having to think about measurements etc.

I think the setting up and usage of Blynk (phone app to control Arduino) has enough content for its own post so I'm going to leave this one here and then continue in the next day or two with a post on how to set that up and edit the code to control the motor from Blynk using the 3 use cases detailed above

Thanks for reading

Mark



0
0
0.000
10 comments
avatar

This looks too much like a science project for me, lol. I'm not smart enough for this level of technology in my photography.

0
0
0.000
avatar

Nor am I mate. I'm running a fine uneducated line between surprising myself if this actually works, partially electrocuting myself (with whatever damage 12v can do) or burning my office desk to the ground (and possibly the house). So far I've only blown up one stepper motor driver which was my mistake for pulling the motor out with it still being plugged into the mains.

Onwards and upwards though, im currently doing some cool stuff with this app and it is all currently working pretty well. Maybe another update to follow tomorrow

0
0
0.000
avatar

at least, keep your eyes and fingers safe, please !!

0
0
0.000
avatar


This post has been voted on by the SteemSTEM curation team and voting trail. It is elligible for support from @curie and @minnowbooster.

If you appreciate the work we are doing, then consider supporting our witness @stem.witness. Additional witness support to the curie witness would be appreciated as well.

For additional information please join us on the SteemSTEM discord and to get to know the rest of the community!

Please consider using the steemstem.io app and/or including @steemstem in the list of beneficiaries of this post. This could yield a stronger support from SteemSTEM.

0
0
0.000
avatar

This content has earned some GEEK. 15000 GEEK tokens has been transferred to your steem-engine.com account.

Geek Rewards (GEEK) is a steem engine token that rewards content creators for their geeky contributions to the community.

0
0
0.000