Welcome, Guest. Please Login or Register
Home Help Search Login Register
Page Index Toggle Pages: 1
Send Topic Print
New firmware sketch (Read 4429 times)
Steve Chapman
Ex Member


New firmware sketch
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;
}
Back to top
 
 
IP Logged
 
Steve Chapman
Ex Member


Re: New firmware sketch
Reply #1 - 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;
} 


Back to top
« Last Edit: 06/09/10 at 21:25:54 by N/A »  
 
IP Logged
 
Achim Berg
Moderator
*****
Offline


I love HDR

Posts: 177
Germany, near Cologne
Re: New firmware sketch
Reply #2 - 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
Back to top
« Last Edit: 05/12/10 at 22:42:19 by Achim Berg »  
WWW  
IP Logged
 
Blochi
Administrator
*****
Offline



Posts: 1726
Hollywood
Re: New firmware sketch
Reply #3 - 05/18/10 at 22:29:20
 

Updated the DIY Cable page and respective PDF download to include this new code. With corrections.
Back to top
 
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print