Go Down

Topic: Voltage drop issue - camera intervalometer (Read 1 time) previous topic - next topic

geoland

Sep 12, 2010, 03:37 am Last Edit: Sep 12, 2010, 03:45 am by geoland Reason: 1
The code below I wrote to provide an endless automated long exposure sequence for astrophotography - the current exposure values are test only.

The circuit is very basic. Digital pin 5 and 6 are connected to separate inputs of an optocoupler via 1k ohm resistors in series. Pins are set HIGH or LOW to operate the camera mirror/focus and shutter respectively.

The problem that I cannot answer, is a voltage drops across the resistor connected to DP5, whereas there is no voltage drop across the resistor connected to DP6. I haven't yet connected the camera - in one sense the circuit is not complete.

The thing that I don't understand is that the voltage to both resistors is the same (+5v), and the voltage drop to +1.5v is across one resistor only.

Could this be something simple such as a poor GND connection?

Many thanks.

Code:
Quote
/* An intervalometer script for Canon DSLR 1000D.
Change int mirror and int shutter variables to adjust exposure times.
*/

int shutterval;        // Read this value
int mirrorval;         // Read this value

int mirror = 3000;      // Mirror lock up/focus time
int shutter = 6000;      // Shutter release time
int wait = 3000;      // Switch off opportunity

int mirrorpin = 5;      // Mirror lock up/focus
int shutterpin = 6;      // Shutter release

void setup() {

 pinMode(mirrorpin, OUTPUT);    
 pinMode(shutterpin, OUTPUT);

}

void loop() {

 mirrorval = digitalRead(mirrorpin);
 shutterval = digitalRead(shutterpin);
 if (mirrorpin != HIGH && shutterpin != HIGH);

 {

   digitalWrite(mirrorpin, HIGH);
   digitalWrite(shutterpin, HIGH);
   delay(wait);

 }

 mirrorval = digitalRead(mirrorpin);
 shutterval = digitalRead(shutterpin);
 if (shutterval == HIGH && mirrorval == HIGH); // make sure mirror and shutter are closed

 {

   digitalWrite(mirrorpin, LOW);      // Mirror lock up
   delay(mirror);            // Remains open until shutter close
 }
 {
   mirrorval = digitalRead(mirrorpin);
   shutterval = digitalRead(shutterpin);
   if (mirrorval == LOW && shutterval == HIGH); // make sure mirror is open

   digitalWrite(shutterpin, LOW);      // Shutter release
   delay(shutter);            // Exposure time - then start again

 }
}

RuggedCircuits

No voltage drop means no current, meaning current has nowhere to go. I'd check to see if the optocoupler cathode is solidly connected to GND.

Any chance you got the pinout of the optocoupler wrong and you're actually connecting DP6 to the cathode?

--
Need a custom shield? Let us design and build one for you.

James C4S

Quote
why you are READing the values of OUTput pins?... I don't know if it is even defined what happens if you read an output pin?  I certainly wouldn't trust writing code that depends on that.

Uh, this is a very clearly defined behavior.  (And a very common practice.)  Reading an OUTPUT pin will give the PORT's register value, returning the pin's current state (high or low).  The original poster is checking to see what state the pin was in before performing an action.

It is reason why this works for toggling:
Code: [Select]

 int ledPin = 13;
 pinMod(ledPin, OUTPUT);
 while(1) {
    digitalWrite(ledPin, !(digitalRead(ledPin)));
    delay(1000);
  }
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Osgeld

agreed, you should be in control of your program, if not you need to figure out why

deSilva

Quote
IMHO, that is terrible programing practice.

I don't know... As CMiYC said, this is common practice among most programmers (which I know) outside the Arduino world. It is quite elegant code in assembly language, and a memory element is a memory element. You are indeed forced to work so with RAM less controllers, and the output register - is just another register.


Go Up