Go Down

Topic: Canon T1i to Arduino (Read 773 times) previous topic - next topic

imagiro1

I am trying to setup my Arduino to trigger my Canon camera. I have a potentiometer to set the delay between pictures. A pulse goes high, waits a given amount of time, and goes low again. This just repeats over and over. I also have it going to an LED so I can tell how fast it will take pictures.

The pulse goes to a transistor. I have tried both BS170 and 2222A NPN transistors.

The cable going to the camera works. If I short the two wires together, it snaps a picture.

When I connect the two wires from the camera to the drain/source or collector/emitter depending on the transistor, nothing happens. I have tried different things including different transistors and setting the pulse width to the camera to be longer/shorter.

The circuit itself seems to be working just fine. Still, I am not able to trigger the camera. Any ideas? Thanks.

pekkaa

Have you checked polarity of the wires from the camera, and wired them in a right way into the transistor? Have you tested the transistor circuit in some other way, i.e., using a multimeter?

imagiro1

Yes, I have tested the transistor. I went from the 3.3V -> Resistor -> Source (pin) -> Drain (pin) -> Ground. I used an O'scope to view the pulse each time the transistor was biased.

I checked the polarity. Most of the time I switched the Drain/Source to verify that wasn't the problem.

a.d

It should be quite straightforward - connect the base of the transistor to the arduino pin through a resistor, the collector to the 'tip' of the mini-jack (for the trigger) and the emitter to the 'sleeve' of the mini-jack. The sleeve is ground.

There's a schematic at the bottom of this page.

imagiro1

Thanks a.d. I thought so too last night when I started this project last night. I basically have the same circuit. I'll take a look tomorrow.

imagiro1

A.D. I got a few questions. First, on my connector going to the camera, the tip and middle are shorted together. I am not using the middle for focus. And if I plug the connector in and short my two wires, the camera triggers every time.

Second, I am having trouble following your code. I'm posting my code which is much more basic. I think it may to do with the way I am triggering the camera. The pulse I am sending.

Third, what is the point of the 2.2k resistor?

Great page. Some awesome pictures.

Code: [Select]
int trig_cam = 7; //pin 3 to trigger camera
int trig_pulse = 200; //Actual pulse to the camera
int max_time = 1000; //Max interval in milliseconds

int led = 12;

int pot_in = 0;
int pause;
int in_temp;

void trigger() {
 
  digitalWrite(led, HIGH);
  digitalWrite(trig_cam, HIGH);
  delay(trig_pulse);
  digitalWrite(led, LOW);
  digitalWrite(trig_cam, LOW);
 
}

void setup() {

  pinMode(trig_cam, OUTPUT);
  pinMode(led, OUTPUT);
}

void loop() {
 
  //Read analog
  in_temp = analogRead(pot_in);
 
  //Read pot value and map in milliseconds
  pause = map(in_temp, 0, 1023, 1, max_time);

  //Send pulse
  trigger();
 
  //Pause
  delay(pause);   
}


a.d

The resistor is just there as a current limiter to stop things breaking.

If you are using variables to set your pin numbers, it might be an idea to set them as const so you can't accidentally change the value at some point in the future.

Just to check, where it says

Code: [Select]
int trig_cam = 7; //pin 3 to trigger camera

Which pin are you actually using? 7 or 3?

There's nothing wrong with your code, what happens if you hook it up and turn the transistor on manually with a piece of hookup wire or a push button going to +5?

imagiro1

Sorry, it's pin 7. I will start using the const. I was actually just reading about that for a school project.

Now it started working. But it works fine for a bit. Then it'll randomly stop working for a minute, then start working again. It's very intermittent. Also, it will randomly take a picture even if I'm not touching it. I spent a minute making sure everything was secure on the breadboard. Everything was. Then with the power off to the Arduino, it took a picture. Sometimes I'll turn the Arduino on and nothing will happen. After a minute or so, it will start working fine. If I power down the Arduino, and give the Arduino a good tap, it will snap a picture.

I feel like that breadboard or a loose wire might be the root of this evilness. It's too random for it to be bad code.

I used optoisolators in the camera trigger I built, and haven't had any problems hardware-wise. (I was looking on SparkFun for the components, and found both what I needed and a circuit schematic for what I had to build.) It must have taken a few tens of thousands of shots without issue. (Timelapses are camera-hungry!)

There's the advantage that, as the name suggests, the cable is completely electrically isolated from the Arduino, so there's no chance of damaging either the Arduino or the camera with weirdness.

imagiro1

Thanks CargoCult. The transistor acts the same way as the optoisolator as far as triggering the camera. The advantage is you isolate the camera from the rest of the circuit. I thought about switching over. (I just realized you explained it too, sorry). I hope once I build the circuit, the randomness goes away. If not, I might switch over to an optoisolator and give that a try. I honestly think it's the crappy breadboard and/or a loose connection.

Go Up