fork of shutter test program

Fork of test_shutter by james kain

Committer:
sam_grove
Date:
Tue Jun 25 05:09:09 2013 +0000
Revision:
3:e00270ed0259
Parent:
2:ec6da58dab61
change interval time to a define

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jekain314 0:7a527a9bedce 1 #include "mbed.h"
jekain314 0:7a527a9bedce 2
jekain314 1:7972095b7aea 3 //are these actually used ??? - not used sg. Was for the inital LED's you had. Then I thought of the 4 into 16 while coding
jekain314 0:7a527a9bedce 4 DigitalOut ext_led[8] = {p21,p22,p23,p24,p25,p26,p27,p28};
jekain314 0:7a527a9bedce 5 //DigitalOut int_led[4] = {LED1, LED2, LED3, LED4};
sam_grove 2:ec6da58dab61 6
jekain314 0:7a527a9bedce 7 // from handbook for BusOut: Flexible way to write multiple DigitalOut pins as one value
jekain314 0:7a527a9bedce 8 BusOut int_led(LED1, LED2, LED3, LED4); //four built-in LEDs used to display the counter from the trigger
jekain314 0:7a527a9bedce 9
jekain314 1:7972095b7aea 10 //original from Sam in Seaside
jekain314 1:7972095b7aea 11 //DigitalInOut fire(p20); //connected to the tip of 2.5mm connector (T2i)
jekain314 1:7972095b7aea 12 //DigitalInOut pre_fire(p19); //connected to the mid-connection for 2.5mm connector (T2i)
sam_grove 2:ec6da58dab61 13
jekain314 1:7972095b7aea 14 //modification to connect to the IMU carrier board
jekain314 1:7972095b7aea 15 DigitalInOut fire(p29); //connected to the tip of 2.5mm connector (T2i)
jekain314 1:7972095b7aea 16 DigitalInOut pre_fire(p30); //connected to the mid-connection for 2.5mm connector (T2i)
sam_grove 2:ec6da58dab61 17
jekain314 1:7972095b7aea 18 // using ADIS hardware
jekain314 1:7972095b7aea 19 //DigitalInOut fire(p29); //connected to the tip of 2.5mm connector (T2i)
jekain314 1:7972095b7aea 20 //DigitalInOut pre_fire(p30); //connected to the mid-connection for 2.5mm connector (T2i)
sam_grove 2:ec6da58dab61 21
jekain314 0:7a527a9bedce 22 InterruptIn x(p18);
jekain314 0:7a527a9bedce 23 Serial pc(USBTX, USBRX);
sam_grove 2:ec6da58dab61 24
sam_grove 2:ec6da58dab61 25
jekain314 0:7a527a9bedce 26 #define US_INTERVAL 500
jekain314 0:7a527a9bedce 27
jekain314 0:7a527a9bedce 28 //set the resolution of the timing information
sam_grove 3:e00270ed0259 29 #define MS_INTERVAL 1 //interval used to change the counter display
sam_grove 3:e00270ed0259 30 #define WAIT_KNOWN_MS 145 // known delay between trigger and shutter time (allows to better use 4 leds)
sam_grove 3:e00270ed0259 31 #define TRIGGER_INTERVAL 7.5f // amount of time between triggers
jekain314 0:7a527a9bedce 32
jekain314 0:7a527a9bedce 33 void resetLed()
jekain314 0:7a527a9bedce 34 {
jekain314 0:7a527a9bedce 35 for(int i=0; i<8; i++)
jekain314 0:7a527a9bedce 36 {
jekain314 0:7a527a9bedce 37 ext_led[i] = 0;
jekain314 0:7a527a9bedce 38 }
jekain314 0:7a527a9bedce 39 int_led = 0;
jekain314 0:7a527a9bedce 40 }
sam_grove 2:ec6da58dab61 41
jekain314 1:7972095b7aea 42 //xFire procedure is not used in the logic in main. This was to test the accuracy of the hotshoe trigger and it was spot on sg
jekain314 0:7a527a9bedce 43 void xFire()
jekain314 0:7a527a9bedce 44 {
jekain314 0:7a527a9bedce 45 for(int i=1; i<16; i++)
jekain314 0:7a527a9bedce 46 {
jekain314 0:7a527a9bedce 47 wait_us(US_INTERVAL);
jekain314 0:7a527a9bedce 48 int_led = i;
jekain314 0:7a527a9bedce 49 }
jekain314 0:7a527a9bedce 50 return;
jekain314 0:7a527a9bedce 51 }
sam_grove 2:ec6da58dab61 52
jekain314 0:7a527a9bedce 53 volatile bool trigger = 0;
jekain314 0:7a527a9bedce 54 Ticker trig;
jekain314 0:7a527a9bedce 55 void setTrig()
jekain314 0:7a527a9bedce 56 {
jekain314 0:7a527a9bedce 57 trigger = 1;
jekain314 0:7a527a9bedce 58 }
jekain314 0:7a527a9bedce 59
jekain314 0:7a527a9bedce 60 int main()
jekain314 0:7a527a9bedce 61 {
jekain314 0:7a527a9bedce 62 // try open drain driving (internal pullup in camera?)
jekain314 0:7a527a9bedce 63 //x procedure not used below
jekain314 0:7a527a9bedce 64 x.mode(PullUp);
jekain314 0:7a527a9bedce 65 x.fall(&xFire);
jekain314 0:7a527a9bedce 66
jekain314 0:7a527a9bedce 67 fire.output(); //set the fire pin as outoput
jekain314 0:7a527a9bedce 68 pre_fire.output(); //set the pre-fire pin as output
jekain314 0:7a527a9bedce 69 //fire.mode(OpenDrain);
jekain314 0:7a527a9bedce 70
jekain314 0:7a527a9bedce 71 //set up for the first trigger
jekain314 0:7a527a9bedce 72 fire = 1;
jekain314 0:7a527a9bedce 73 pre_fire = 1;
jekain314 0:7a527a9bedce 74
jekain314 0:7a527a9bedce 75 // reset the LED's
jekain314 0:7a527a9bedce 76 resetLed();
jekain314 0:7a527a9bedce 77
jekain314 0:7a527a9bedce 78 //trig is a ticker used to repeatedly fire a trigger at the interval (e.g., 7.5 secs)
sam_grove 3:e00270ed0259 79 trig.attach(&setTrig, TRIGGER_INTERVAL); //set ticker interval to 7.5secs
jekain314 0:7a527a9bedce 80
jekain314 0:7a527a9bedce 81 // start the program
jekain314 0:7a527a9bedce 82 while(1)
jekain314 0:7a527a9bedce 83 {
jekain314 0:7a527a9bedce 84 // if(pc.readable()) //used to trigger from a keyboard click
jekain314 0:7a527a9bedce 85 // {
jekain314 0:7a527a9bedce 86 // char ch = pc.getc(); //read the keyboard click
sam_grove 2:ec6da58dab61 87
jekain314 0:7a527a9bedce 88 //below used for repeatedly triggering on a ticker
jekain314 0:7a527a9bedce 89 if(trigger) //is the ticker has fired the trigger, proceed ...
jekain314 0:7a527a9bedce 90 {
jekain314 0:7a527a9bedce 91 trigger = 0; //reset the trigger to zero
jekain314 0:7a527a9bedce 92
jekain314 0:7a527a9bedce 93 // turn all leds off to start the counter
jekain314 0:7a527a9bedce 94 resetLed();
jekain314 0:7a527a9bedce 95
jekain314 0:7a527a9bedce 96 // pre-fire the trigger using the mid-body 2.5mm connection (T2i)
jekain314 0:7a527a9bedce 97 pre_fire = 0;
jekain314 0:7a527a9bedce 98
jekain314 0:7a527a9bedce 99 wait(.25f); //wait for 0.25 secs
jekain314 0:7a527a9bedce 100
jekain314 0:7a527a9bedce 101 fire = 0; //fire the trigger using the tip connection
jekain314 0:7a527a9bedce 102
sam_grove 2:ec6da58dab61 103 wait_ms(WAIT_KNOWN_MS); // empirically known delay to get us to the range of the 4 timing LEDs
jekain314 0:7a527a9bedce 104
jekain314 0:7a527a9bedce 105 // maybe we need more or later just use these...
jekain314 0:7a527a9bedce 106 //just count up to 16 diaplaying the results on the LEDs
jekain314 0:7a527a9bedce 107 for(int i=1; i<16; i++)
jekain314 0:7a527a9bedce 108 {
jekain314 0:7a527a9bedce 109 wait_ms(MS_INTERVAL);
jekain314 0:7a527a9bedce 110 int_led = i; //write to the BusOut to display the counter on 4 LEDs
jekain314 0:7a527a9bedce 111 }
jekain314 0:7a527a9bedce 112
jekain314 0:7a527a9bedce 113 //reset for the next trigger
jekain314 0:7a527a9bedce 114 // release the trigger
jekain314 0:7a527a9bedce 115 fire = 1;
jekain314 0:7a527a9bedce 116 pre_fire = 1;
jekain314 0:7a527a9bedce 117 }
jekain314 0:7a527a9bedce 118 }
jekain314 0:7a527a9bedce 119 }