Showing posts with label camera. Show all posts
Showing posts with label camera. Show all posts

Saturday, January 18, 2014

Arduino Time-Lapse Dolly Project Part 3

Arduino Time-Lapse Dolly Project Part 3

Stepper Into Motion

Now that I have tried the relay hooked up to the camera, got a button to fire it, and now its time to test the stepper motor.

First I should briefly explain what a stepper motor is and why I choose to use one.  They are called stepper motors because they move in small incremental steps which is generally measured in degrees.  So a 1.8 degree motor will take 400 little steps per revolution.  Because the motor can move in these small increments, it can (depending on the quality of the motor) make some very precise movements.  That is why I chose such motor for my application since I need the camera to move in consistent, accurate movements between shots.

I am using the Adafruit motor shield.  After I bought it, and started to figure out more about these crazy motor shields they can only handle so much power which means the motors can't draw to much power itself.  The Adafruit ones can handle 1.2A and I found it difficult to find a motor that was less than that. I eventually got one that draws .4A but I am not sure it will be powerful enough to move the camera... we will see!  Regardless it was only $15 so it if doesn't work I can at least use it to test everything out.

The Adafruit website is actually pretty handy and they have a lot of tutorials which is super awesome (see this link here) - though the one for this motor shield was slightly wrong at points, it was right enough that you can figure it out.  First thing first was to download the motor shield library. For instance, the tutorial said once the library is installed it should be accessible through the File/Examples/AFMotor, but that never happened for me.  It does show up under Sketch/Import Library/AFMotor and when you select it you get a "#include " added to the code - I assume always to the top but I haven't done it when there was code present.  Don't let this bother you, keep following the Adafruit tutorial and it has a lot of useful information and some example programming.  I used that example to help with my code below.  

Next step was wiring the sucker up.  For a test, and test only, I used a 9v battery to power the motor.  In real life the battery probably doesn't have enough juice to fully power the stepper motor I am using nor will it have the longevity that I need - 600+ cycles.  I bought a 9v battery hookup and wired it to the board at the Ext. PWR block.  Next to that, there is a jumper. Per the Adafruit tutorial if you want to use an external power supply to run the motor that is separate from the Arduino board, then you remove the jumper.  If you Arduino power supply (ie USB cable) is going to power both then leave the jumper in place.  As a side note, my experience is that even with the jumper removed, when I plugged the Arduino in to the USB to update the program it moved the motor.

Blur block next to the EXT PWR is where you can hook up the power.  The red circle on the right is where the jumper is located.  In this photo, I have already removed the jumper. 

I got a Primopal motor because it was cheap (~$15 shipped), and it was nice that Primopal had data sheets available for all their motors.  Without some sort of tech sheet you will have to figure out how to wire the motor to the board.  Now I am not expert on stepper motors but some are uni-polar and some are bi-polar.  Uni-polar motors have 5 wires and bi-polar have 4.  Either one will work, the shield allowed for both to be hooked up.  There are online resources that will show you how to wire the motor if it doesn't have a data sheet.

To test the motor I used Adafruit's tutorial code with some simple changes.  The motor I have is 1.8 degrees per step, and Adafruit is using a 7.5 degrees per step.  So I changed the steps from 100 to 400 (see red text below).  I also changed the rpm from 10 to 60 just because.

#include


AF_Stepper motor(48, 2);


void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");

  motor.setSpeed(10);  // 10 rpm

  motor.step(100, FORWARD, SINGLE);
  motor.release();
  delay(1000);
}

void loop() {
  motor.step(400, FORWARD, SINGLE);
  motor.step(400, BACKWARD, SINGLE);

  motor.step(400, FORWARD, DOUBLE);
  motor.step(400, BACKWARD, DOUBLE);

  motor.step(400, FORWARD, INTERLEAVE);
  motor.step(400, BACKWARD, INTERLEAVE);

  motor.step(400, FORWARD, MICROSTEP);
  motor.step(400, BACKWARD, MICROSTEP);
}



Now - to tie my camera shutter, and stepper motor together I wrote this code.  A button sets the whole thing in motion.  It will take 20 photos and advance the camera on the track 20 times (see the yellow highlighted section of the code in which this number is set). Keep in mind I have a MEGA board and not the regular Uno board, so I have more pins.  The button and relay are hooked to ports 52 and 53.


#include

AF_Stepper motor(200, 2);  //number of steps per revolution and indicates which port the motor is wired to.

const int buttonpin = 53;  //number of the pin the button is connected too
const int camerapin = 52; //number of the pin the relay to trigger the camera is connected too

int buttonstate = 0;

void setup() {

 pinMode(camerapin, OUTPUT);
 pinMode(buttonpin, INPUT);

 // Setting up the stepper motor
 Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");  //probably not a necessary line....

  motor.setSpeed(60);  // 60 rpm
 }

void loop(){
  buttonstate = digitalRead(buttonpin);

  if (buttonstate == HIGH){
 
    for (int i=0; i<20 span="">; i++) //this will be the stepper motor camera trigger loop, i dictates the number of times the camera shoots
  {
    digitalWrite(camerapin, HIGH);
    delay(3000);
    digitalWrite(camerapin, LOW);
    delay(500);
    motor.step(400, FORWARD, SINGLE);
    delay(1000);
  } //ends the FOR statement
 }  //end IF statement
} //ends LOOP



Next Steps - make a track and dolly for the camera!

Saturday, November 23, 2013

Arduino Time-Lapse Dolly Project Part 1

Let me preface this article by saying I am NOT an expert in electronics, or programming or the Arduino... I am pretty confident that I can hack something together, and perhaps my readers can help me along the way if I get stuck.

First I will briefly describe what I have in mind.  I have been taking a lot of Milky Way time-lapse movies recently and to add a little pizzazz to them I would like to have the camera move on a track.  So I can either I can stay up all night and move the camera manually - which sounds like work.  Or I could automate it with some programmable computer thingy.  Option two sounds way better.  The thought is I would have the Arduino trigger the camera for the appropriate amount of time.  When the shutter closes, move the camera on the track a short distance.  Then trigger the camera again and repeat until the sun comes up.  For those who are not aware of what is required to shoot Milky Way time lapse, it takes 300 individual pictures to make 10 seconds of video at 30 frames per second.  For each photo, the shutter is open for 30 seconds.  I prefer to try and shoot all night, which may be 8 hours worth of shooting and equals about 800 shots.  This is why I would like to automate it!  I would rather sleep all night than baby sit the camera. See my first video below:



Now, I am not very electronic savvy - most of my background is in car electronics so I am all about the relays and switches.  To me a transistor is something Harry Potter probably used.  I heard of something called a stepper motor which I think I need to move the camera dolly. After some research I know Arduinos have these shield things to control motors.

Step 1, buy and Arduino.  Check!  Actually I got the Mega because the shield I bought said it worked for the Mega but didn't explicitly say it worked for the Uno so I thought I would just get the Mega for now.

Step 2, buy a stepper motor shield. Check!  I got the SainSmart one off of Amazon.  Hopefully it does everything I need because I don't really know much about stepper motors and such.



The Arduino site suggests installing the "Blink" program.  Well when I plugged it in for the first time the LED was already blinking so that really doesn't help.  So what I did instead was take the standard blink program and change the blink interval.  Uploaded that and it worked great.

Here is the code I used:

int led = 13;

// the setup routine runs once when you press reset:
void setup() {              
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);  
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(250);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);
digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(250);
 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000); // wait for a second
}


I bought a cheap shutter release cable and opened it up to see how it triggered the camera and figure out how to wire it into the Arduino.  I cut the wires to the board (see photo below) and tried connecting different ones together to figure out what combination fired the camera.  What worked was connecting all three together.  If I connected the red and white together nothing happened, but if I connected the white and black it was like a half shutter press, and connecting the red and black did nothing.

See the cut wires in the black connector on the main board. 

With my simplified electronics background the firth thing I thought of was a relay.  Tie the red and white wires together, and use the Arduino to actuate a relay to connect the red and white wires to the black wire. So I wired one up like this:


Hooked up on a bread board it looks like this:


Now one special note - the Arduino can only support 40mA through each pin so you have to pick relay that doesn't draw more than that.  The first relay I got drew 90mA and though it worked, I think it will fry the Arduino over time. How do you figure it out?  Take the voltage, divide it by the resistance.   If its less than .04 then you are OK.  Since the Arduino puts out 5 volts, you take 5 and divide it by the resistance of the coil in the relay (expressed in Ohms).  You need a relay that can be triggered by 5v and has a coil resitance of 125 ohms or more.

As for the code I took the Blink code and changed the pin to 10 and wired the relay up as shown above.  Plugged the Arduino into the computer and listened for the click.  Then I plugged the wires from the shutter release to the camera and did the same thing this time the camere should fire at a regular interval.

Sure enough, it did!  Great success!

Stay tuned for more updates!

Thursday, May 14, 2009

My Digital Pinhole Camera

I have never seriously pursued pinhole photography, but idea of it, and the soft dreamy scenes have always appealed to me. One day I got this wild idea to make a pinhole lens for my D300. So, without consulting the all mighty internet for ideas, I set about making this lens. Whatever the outcome, I wanted a lens that was professional looking, and not something like a cardboard tube with aluminum foil taped over the front or something like that. To me, this dictated that the lens had to mount to the camera on the Nikon F mount. The only items that I could think of that could mount to the body of the camera were a lens or extension tubes used for macro photography. If I wanted to use a lens, I would have to strip it of its glass, or remove the mount from the lens and somehow attach the pinhole to the mount. I looked at my small inventory of lenses, and though I had some real cheap lenses, they all worked, and I couldn't make myself disassemble one. That left me, in my mind, two options. Try and find a broken or very cheap lens (I was thinking $5-15 is my budget for this project) or find really cheap extension tubes. For some reason, I thought a set of extension tubes would run me $50+, so I didn't bother to look at what was available. Instead, I search craigslist, and ebay for broken lenses. No luck. On a whim, I search ebay for extension tubes and found a ton that were only $10 (that included shipping). So I bought a set. Of course it was coming all the way from China, and I didn't expedite the shipment so it took about 2 weeks to get the extension tube set in the mail. My expectations for this product was fairly low, and I pretty much expected them to be made out of plastic, but they are aluminum. Even still, I am very careful not to cross thread them or try and tighten the various extension tubes to much since I am sure the threads will just get torn apart.

With extension tubes in hand, how do I turn them into a pinhole lens? I am lucky and work for a medium to large machine shop and a friend of mine who is a machinist offered to make me something if I drew up a print. So, 2 minutes to draw something up for him, and a day for him to machine it for me I had a part that looked like a lens cap that as threaded and could be screwed onto the entension tubes. Below are some pictures.

Here is the extension tube set with the aluminum pinhole adapter.




For those not aware of how extension tubes work, the tubes are a set of 5 parts, first part has the nikon body mount on one side and threaded on the other. Three parts ar basically just spacers that thread onto the first part. The last part threads on the end and the lens mounts onto it. So the pinhole adapeter is threaded to screw onto any one of the spacers.

Here is another image with the extension tubes and adapter.


Here is a picture with the adapter screwed onto the end of the extension tube.



So now I need to make a pinhole in something. My first attempt was using aluminum foil like most pinhole cameras are made with. The results were less than desirable. At first I thought this project was all for not. I was not naive to think that I was the first one to come up with this hair brained idea, and given my poor results, I decided to look on the internet and see how other people's pinhole cameras turned out. I found one guy who punctured a hole in a can and seemed to have the image quality that I wanted mint to have.

Here is a sample image using the aluminum foil.


So I took a coke can and cut it up, sanded it on both sides and used a thumb tack to make a hole. The idea, when making the hole, was to make the smallest possible hole. So I tried to stick it in just enough to start penetrating the aluminum. Since the pressure of the pin dents the aluminum, I sanded the front and back one more time.

Here are some of the tools I used.


Here is a macro shot of the hole (using the extension tubes as intended!).


Now I need to affix this to my pinhole adapter. This image has a close up of the hole along to the top since its difficult to see.


Now for a picture of the whole rig on my N80 film camera.


Pretty sexy for a pinhole camera... well I think so anyways, but I am a bit of a photo geek.

So how does this new hole compare to the terrible picture above? Check it out!

Yeah, its soft, but much better than the other, in my opinion. I even refined the hole a bit, and made one a touch smaller and got an image that was a little better. These small images may make it difficult to see the difference but here is a comparison anyways.

When using the aluminum foil, my hypothesis is that the pin creates a ridge of displaced material on one side of the pinhole. This ridge interferes with the image quality, but when using an aluminum can, the ridge can be sanded away, and the image quality is much improved.

Now I need to take it into the field and really play around!

Until next time...

Matthew Eddy
Photographer
http://www.oil-rigs.net/