Pages: [1]   Go Down
Author Topic: Canon T1i to Arduino  (Read 659 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Finland
Offline Offline
Sr. Member
****
Karma: 1
Posts: 270
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Leeds, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);   
}

Logged

Leeds, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: