Changes to allow hardware camera trigger

Dependencies:   mbed

Fork of GPS_Incremental by james kain

Files at this revision

API Documentation at this revision

Comitter:
dannyman939
Date:
Thu Apr 18 00:59:49 2013 +0000
Parent:
9:13724ed3f825
Commit message:
Hardware trigger camera using the DigitalOut of Pin 2

Changed in this revision

PCMessaging.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 13724ed3f825 -r 078891935385 PCMessaging.h
--- a/PCMessaging.h	Wed Apr 17 13:50:21 2013 +0000
+++ b/PCMessaging.h	Thu Apr 18 00:59:49 2013 +0000
@@ -8,6 +8,7 @@
 const unsigned char  STOPSTREAM_MSG     =5;
 const unsigned char  STARTLOGINFO_MSG   =6;
 const unsigned char  STOPLOGINFO_MSG    =7;
+const unsigned char  SEND_TRIG          =8;
 
 const double  DEGREES_TO_RADIANS = acos(-1.0)/180.0;
 const double eccen          = 0.0818191908426;  //WGS84 earth eccentricity
@@ -25,9 +26,10 @@
 bool logMsgInfo     =false;
 bool sendLogMsgInfo =false;
 bool recordData     =false;
+bool camtrg         =false;
 
 
-const unsigned char numMessages = 8;    //number of potential messages
+const unsigned char numMessages = 9;    //number of potential messages
 char msgList[numMessages][32];          //text array storing the command messages from the PC
 char minMessageSize = 11;               //minimum size of a text message
 unsigned char CR = 0x0d;                //ASCII Carriage Return
@@ -44,6 +46,7 @@
     sprintf(msgList[STOPSTREAM_MSG],    "WMsg POSSTREAM N");
     sprintf(msgList[STARTLOGINFO_MSG],  "WMsg LOGINFO Y");
     sprintf(msgList[STOPLOGINFO_MSG],   "WMsg LOGINFO N");
+    sprintf(msgList[SEND_TRIG],         "WMsg SEND_TRIG");
     //message length is from 10 to 16 chars
     
     toPC.printf(" finished setting up messages \n");
@@ -116,7 +119,10 @@
                     case STOPLOGINFO_MSG:
                         logMsgInfo = (m == STARTLOGINFO_MSG);
                         sendLogMsgInfo = true;
-                    break;  
+                    break;
+                    case SEND_TRIG:
+                        camtrg = true;  //send a posvel message back to PC
+                    break; 
                 }  //end Switch statement
                 break;
             } //end test for a valid message
@@ -213,6 +219,12 @@
         //we should put the below stuff into the readPC() procedure.
         //only do these actions in response to a command so no need for the tests w/o an inoput byte from the PC
         //perform the activities as a response to the commands
+        
+        if (camtrg)  //true if camera trigger command sent from PC
+        {
+            camera1EventDetected=true;
+            
+        }
         if (sendPosVel)  //true if we want to return a position solution
         {
             sendPosVel=false; //set to true if a POSVEL is requested from the PC
diff -r 13724ed3f825 -r 078891935385 main.cpp
--- a/main.cpp	Wed Apr 17 13:50:21 2013 +0000
+++ b/main.cpp	Thu Apr 18 00:59:49 2013 +0000
@@ -14,7 +14,7 @@
 DigitalOut ppsled(LED1);        //blink an LED at the 1PPS
 DigitalOut trig1led(LED2);      //blink an LED at the camera trigger detection
 DigitalOut recordDataled(LED4); //set the led when the record is on
-InterruptIn camera1Int(p30);    // camera interrupt in
+//InterruptIn camera1Int(p30);    // camera interrupt in
 DigitalOut camera2Pin(p29);     // We dont use the second camera interrupt
 //USB serial data stream back to the PC
 Serial toPC(USBTX, USBRX);      //connect the GPS TX, RX to p9 and p10
@@ -65,15 +65,15 @@
 };
 
 //ISR for detection of the hotshoe trigger 1
-void camera1ISR(void)
-{
+//void camera1ISR(void)
+//{
     //GPSTime is from POS message header
     //PPSTimeOffset is an even sec to account for Time becoming known AFTER the 1PPS
     //PPSTimeOffset + timeFromPPS.read() can be as large as 1.02 secs
-    camera1Time = GPSTime + PPSTimeOffset + timeFromPPS.read();    
-    camera1EventDetected = true;  //reset to false in main after processing the image detection
-    trig1led = !trig1led;  //blink an LEWD at the camera event detection
-};
+//    camera1Time = GPSTime + PPSTimeOffset + timeFromPPS.read();    
+//    camera1EventDetected = true;  //reset to false in main after processing the image detection
+//    trig1led = !trig1led;  //blink an LEWD at the camera event detection
+//};
 
 ///////////////////////////////////////////////////////
 //set up the USB port and the GPS COM port
@@ -171,10 +171,10 @@
 
 void setupTriggers()
 {
-    camera1Int.mode(PullUp);
+//    camera1Int.mode(PullUp);
     camera2Pin = 1;
     //establish Trigger ISR 
-    camera1Int.rise(&camera1ISR);
+//    camera1Int.rise(&camera1ISR);
     
 };
 
@@ -352,7 +352,14 @@
         
         if (camera1EventDetected)  //we have detected a camera trigger event
         {
+            camera2Pin=0;
+            wait(.25);
+            camera2Pin=1;
+            wait(.50);
+            camera2Pin=0;
+            camera1Time = GPSTime + PPSTimeOffset + timeFromPPS.read();
             toPC.printf("WMsg TRIGGERTIME %5.3lf\n", camera1Time);
+            camera2Pin=1;
             camera1EventDetected = false;
         }