HDRI Community
http://www.hdrlabs.com/cgi-bin/forum/YaBB.pl
Open Camera Controller >> OCC Developer Zone >> New firmware sketch
http://www.hdrlabs.com/cgi-bin/forum/YaBB.pl?num=1271555020

Message started by Steve Chapman on 04/18/10 at 02:43:40

Title: New firmware sketch
Post by Steve Chapman on 04/18/10 at 02:43:40
This needs a little sprucing, but here we've added a heartbeat routine. By tapping a 3V or properly resistor-limited lower voltage LED between pin 6 on the microcontroller and GND, we can see a flashing LED that helps us to troubleshoot assembly and confirm that the firmware has booted properly.  We should probably add some variations to the flashing pattern during shooting as well, to confirm the shooting signal pin is reading & the interrupt routines are interrupting. If you've assembled the cartridge and it doesn't seem to work, but the heartbeat is visible, the problem may be "downstream" from the MC, in the isolators, cable, or camera.

int FullPressPin = 13;
int HalfPressPin = 12;
int ShutterState=LOW;
int IsShooting=0;
int x = 0;
int HeartbeatPin = 4;
int HeartbeatPulse=0;
int HeartbeatState=LOW;
volatile int state = LOW;
void setup()
{
  pinMode(HalfPressPin, OUTPUT);    
  pinMode(FullPressPin , OUTPUT);
  pinMode(HeartbeatPin, OUTPUT);
  attachInterrupt(0, ProcessDSSignalRising, RISING);
  attachInterrupt(1, ProcessDSSignalFalling, FALLING);
  ShutterState=LOW;//Unpress shutter button if it is an unknown state
  digitalWrite(FullPressPin, ShutterState);
  digitalWrite(HalfPressPin, ShutterState);
 
}
void loop()                     
{
   if (IsShooting = 0){
      ShutterState=LOW;
      digitalWrite(FullPressPin, ShutterState);
      digitalWrite(HalfPressPin, ShutterState);
   }
   
   HeartbeatPulse=HeartbeatPulse++;
   if (HeartbeatPulse > 9999) {
      //HeartbeatState=!HeartbeatState;
      if (HeartbeatState==LOW){
         HeartbeatState=HIGH;}
         else{
             HeartbeatState=LOW;}
      digitalWrite(HeartbeatPin, HeartbeatState);
      delay(50);
      HeartbeatPulse=0;
   }
   
   
}
void ProcessDSSignalRising()
{
   ShutterState=LOW;
   digitalWrite(FullPressPin, ShutterState);
   digitalWrite(HalfPressPin, ShutterState);
   IsShooting=0;
}
void ProcessDSSignalFalling()
{
   ShutterState=HIGH;
   // add a delay here to make HalfPress longer
   for (x=0;x< 5; x++){
     digitalWrite(HalfPressPin, ShutterState);
   }
   digitalWrite(FullPressPin, ShutterState);
   IsShooting=1;
}

Title: Re: New firmware sketch
Post by Steve Chapman on 05/10/10 at 20:12:03
That last version was a bit irritating, The following rev gives a triple heartbeat flash when the MC is first powered up, then sends a flashing light signal whenever a shot is taken. This may help troubleshoot or visualize what the OCC is thinking.

BTW: little known trick: hold the A button during a sequence to cancel shooting after the current shot finishes.
[code]int FullPressPin = 13;
int HalfPressPin = 12;
int ShutterState=LOW;
int IsShooting=0;
int x = 0;
int HeartbeatPin = 4;
volatile int state = LOW;
void setup()
{
  pinMode(HalfPressPin, OUTPUT);    
  pinMode(FullPressPin , OUTPUT);
  pinMode(HeartbeatPin, OUTPUT);
  attachInterrupt(0, ProcessDSSignalRising, RISING);
  attachInterrupt(1, ProcessDSSignalFalling, FALLING);
  ShutterState=LOW;//de-depress shutter button if it is an unknown state
  digitalWrite(FullPressPin, ShutterState);
  digitalWrite(HalfPressPin, ShutterState);
 
  //May 2010 Heartbeat code variation
     digitalWrite(HeartbeatPin, HIGH);
     delay(1000);
     digitalWrite(HeartbeatPin, LOW);
     delay(500);
     digitalWrite(HeartbeatPin, HIGH);
     delay(1000);
     digitalWrite(HeartbeatPin, LOW);
     delay(500);
     digitalWrite(HeartbeatPin, HIGH);
     delay(1000);
     digitalWrite(HeartbeatPin, LOW);

}
void loop()                     
{
   if (IsShooting == 0){
      ShutterState=LOW;
      digitalWrite(FullPressPin, ShutterState);
      digitalWrite(HalfPressPin, ShutterState);
   }
}
   
   
}
void ProcessDSSignalRising()
{
   ShutterState=LOW;
   digitalWrite(FullPressPin, ShutterState);
   digitalWrite(HeartbeatPin, LOW);
   digitalWrite(HalfPressPin, ShutterState);
   IsShooting=0;
}
void ProcessDSSignalFalling()
{
   ShutterState=HIGH;
   // add a delay here to make HalfPress a tad longer
   for (x=0;x< 5; x++){
     digitalWrite(HalfPressPin, ShutterState);
   }
   digitalWrite(HeartbeatPin, HIGH);
   digitalWrite(FullPressPin, ShutterState);
   IsShooting=1;
}[/code]

Title: Re: New firmware sketch
Post by Achim Berg on 05/12/10 at 21:39:31
Hello Steve,

the new firmware could not be programed because there is a little failure inside the sketch.

The code sequence has to be reworked because one "}" is to much and causes an error
-> Line 40 has to be deleted.

The arduino programmer software produces a failure while compiling the code -> "error: expected declaration before '}' token"

After deleting line 40 the new firmware works fine.

I burned the corrected source code to the occ and tested ist. The new firmware works very good, well done Steve.

Yours Achim

Title: Re: New firmware sketch
Post by Blochi on 05/18/10 at 22:29:20

Updated the DIY Cable page and respective PDF download to include this new code. With corrections.

HDRI Community » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2018. All Rights Reserved.