this test code is used to test trigger a Canon T2i DSLR camera using its 2.5mm bulb trigger input signals. A 4-LED diaplay is presented to the camera used to measure the time between the trigger input and the actual recorded image.
main.cpp@1:7972095b7aea, 2013-04-23 (annotated)
- Committer:
- jekain314
- Date:
- Tue Apr 23 14:11:00 2013 +0000
- Revision:
- 1:7972095b7aea
- Parent:
- 0:7a527a9bedce
test of a canon T2i shutter command from bulb trigger.
Who changed what in which revision?
User | Revision | Line number | New 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}; |
jekain314 | 0:7a527a9bedce | 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) |
jekain314 | 1:7972095b7aea | 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) |
jekain314 | 1:7972095b7aea | 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) |
jekain314 | 0:7a527a9bedce | 21 | |
jekain314 | 0:7a527a9bedce | 22 | InterruptIn x(p18); |
jekain314 | 0:7a527a9bedce | 23 | Serial pc(USBTX, USBRX); |
jekain314 | 0:7a527a9bedce | 24 | |
jekain314 | 0:7a527a9bedce | 25 | |
jekain314 | 0:7a527a9bedce | 26 | #define US_INTERVAL 500 |
jekain314 | 0:7a527a9bedce | 27 | |
jekain314 | 0:7a527a9bedce | 28 | //set the resolution of the timing information |
jekain314 | 0:7a527a9bedce | 29 | #define MS_INTERVAL 2 //interval used to change the counter display |
jekain314 | 0:7a527a9bedce | 30 | |
jekain314 | 0:7a527a9bedce | 31 | void resetLed() |
jekain314 | 0:7a527a9bedce | 32 | { |
jekain314 | 0:7a527a9bedce | 33 | for(int i=0; i<8; i++) |
jekain314 | 0:7a527a9bedce | 34 | { |
jekain314 | 0:7a527a9bedce | 35 | ext_led[i] = 0; |
jekain314 | 0:7a527a9bedce | 36 | } |
jekain314 | 0:7a527a9bedce | 37 | int_led = 0; |
jekain314 | 0:7a527a9bedce | 38 | } |
jekain314 | 0:7a527a9bedce | 39 | |
jekain314 | 1:7972095b7aea | 40 | //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 | 41 | void xFire() |
jekain314 | 0:7a527a9bedce | 42 | { |
jekain314 | 0:7a527a9bedce | 43 | for(int i=1; i<16; i++) |
jekain314 | 0:7a527a9bedce | 44 | { |
jekain314 | 0:7a527a9bedce | 45 | wait_us(US_INTERVAL); |
jekain314 | 0:7a527a9bedce | 46 | int_led = i; |
jekain314 | 0:7a527a9bedce | 47 | } |
jekain314 | 0:7a527a9bedce | 48 | return; |
jekain314 | 0:7a527a9bedce | 49 | } |
jekain314 | 0:7a527a9bedce | 50 | |
jekain314 | 0:7a527a9bedce | 51 | volatile bool trigger = 0; |
jekain314 | 0:7a527a9bedce | 52 | Ticker trig; |
jekain314 | 0:7a527a9bedce | 53 | void setTrig() |
jekain314 | 0:7a527a9bedce | 54 | { |
jekain314 | 0:7a527a9bedce | 55 | trigger = 1; |
jekain314 | 0:7a527a9bedce | 56 | } |
jekain314 | 0:7a527a9bedce | 57 | |
jekain314 | 0:7a527a9bedce | 58 | int main() |
jekain314 | 0:7a527a9bedce | 59 | { |
jekain314 | 0:7a527a9bedce | 60 | // try open drain driving (internal pullup in camera?) |
jekain314 | 0:7a527a9bedce | 61 | //x procedure not used below |
jekain314 | 0:7a527a9bedce | 62 | x.mode(PullUp); |
jekain314 | 0:7a527a9bedce | 63 | x.fall(&xFire); |
jekain314 | 0:7a527a9bedce | 64 | |
jekain314 | 0:7a527a9bedce | 65 | fire.output(); //set the fire pin as outoput |
jekain314 | 0:7a527a9bedce | 66 | pre_fire.output(); //set the pre-fire pin as output |
jekain314 | 0:7a527a9bedce | 67 | //fire.mode(OpenDrain); |
jekain314 | 0:7a527a9bedce | 68 | |
jekain314 | 0:7a527a9bedce | 69 | //set up for the first trigger |
jekain314 | 0:7a527a9bedce | 70 | fire = 1; |
jekain314 | 0:7a527a9bedce | 71 | pre_fire = 1; |
jekain314 | 0:7a527a9bedce | 72 | |
jekain314 | 0:7a527a9bedce | 73 | // reset the LED's |
jekain314 | 0:7a527a9bedce | 74 | resetLed(); |
jekain314 | 0:7a527a9bedce | 75 | |
jekain314 | 0:7a527a9bedce | 76 | //trig is a ticker used to repeatedly fire a trigger at the interval (e.g., 7.5 secs) |
jekain314 | 0:7a527a9bedce | 77 | trig.attach(&setTrig, 7.5f); //set ticker interval to 7.5secs |
jekain314 | 0:7a527a9bedce | 78 | |
jekain314 | 0:7a527a9bedce | 79 | // start the program |
jekain314 | 0:7a527a9bedce | 80 | while(1) |
jekain314 | 0:7a527a9bedce | 81 | { |
jekain314 | 0:7a527a9bedce | 82 | // if(pc.readable()) //used to trigger from a keyboard click |
jekain314 | 0:7a527a9bedce | 83 | // { |
jekain314 | 0:7a527a9bedce | 84 | // char ch = pc.getc(); //read the keyboard click |
jekain314 | 0:7a527a9bedce | 85 | |
jekain314 | 0:7a527a9bedce | 86 | //below used for repeatedly triggering on a ticker |
jekain314 | 0:7a527a9bedce | 87 | if(trigger) //is the ticker has fired the trigger, proceed ... |
jekain314 | 0:7a527a9bedce | 88 | { |
jekain314 | 0:7a527a9bedce | 89 | trigger = 0; //reset the trigger to zero |
jekain314 | 0:7a527a9bedce | 90 | |
jekain314 | 0:7a527a9bedce | 91 | // turn all leds off to start the counter |
jekain314 | 0:7a527a9bedce | 92 | resetLed(); |
jekain314 | 0:7a527a9bedce | 93 | |
jekain314 | 0:7a527a9bedce | 94 | // pre-fire the trigger using the mid-body 2.5mm connection (T2i) |
jekain314 | 0:7a527a9bedce | 95 | pre_fire = 0; |
jekain314 | 0:7a527a9bedce | 96 | |
jekain314 | 0:7a527a9bedce | 97 | wait(.25f); //wait for 0.25 secs |
jekain314 | 0:7a527a9bedce | 98 | |
jekain314 | 0:7a527a9bedce | 99 | fire = 0; //fire the trigger using the tip connection |
jekain314 | 0:7a527a9bedce | 100 | |
jekain314 | 0:7a527a9bedce | 101 | wait(0.100f); // empirically known delay to get us to the range of the 4 timing LEDs |
jekain314 | 0:7a527a9bedce | 102 | |
jekain314 | 0:7a527a9bedce | 103 | // maybe we need more or later just use these... |
jekain314 | 0:7a527a9bedce | 104 | //just count up to 16 diaplaying the results on the LEDs |
jekain314 | 0:7a527a9bedce | 105 | for(int i=1; i<16; i++) |
jekain314 | 0:7a527a9bedce | 106 | { |
jekain314 | 0:7a527a9bedce | 107 | wait_ms(MS_INTERVAL); |
jekain314 | 0:7a527a9bedce | 108 | int_led = i; //write to the BusOut to display the counter on 4 LEDs |
jekain314 | 0:7a527a9bedce | 109 | } |
jekain314 | 0:7a527a9bedce | 110 | |
jekain314 | 0:7a527a9bedce | 111 | //reset for the next trigger |
jekain314 | 0:7a527a9bedce | 112 | // release the trigger |
jekain314 | 0:7a527a9bedce | 113 | fire = 1; |
jekain314 | 0:7a527a9bedce | 114 | pre_fire = 1; |
jekain314 | 0:7a527a9bedce | 115 | } |
jekain314 | 0:7a527a9bedce | 116 | } |
jekain314 | 0:7a527a9bedce | 117 | } |