Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of test_shutter by
main.cpp@2:ec6da58dab61, 2013-04-29 (annotated)
- Committer:
- sam_grove
- Date:
- Mon Apr 29 04:05:47 2013 +0000
- Revision:
- 2:ec6da58dab61
- Parent:
- 1:7972095b7aea
- Child:
- 3:e00270ed0259
Added defines and comments for quick testing configuration
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}; |
| 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 | 2:ec6da58dab61 | 29 | #define MS_INTERVAL 1 //interval used to change the counter display |
| sam_grove | 2:ec6da58dab61 | 30 | #define WAIT_KNOWN_MS 125 // known delay between trigger and shutter time (allows to better use 4 leds) |
| jekain314 | 0:7a527a9bedce | 31 | |
| jekain314 | 0:7a527a9bedce | 32 | void resetLed() |
| jekain314 | 0:7a527a9bedce | 33 | { |
| jekain314 | 0:7a527a9bedce | 34 | for(int i=0; i<8; i++) |
| jekain314 | 0:7a527a9bedce | 35 | { |
| jekain314 | 0:7a527a9bedce | 36 | ext_led[i] = 0; |
| jekain314 | 0:7a527a9bedce | 37 | } |
| jekain314 | 0:7a527a9bedce | 38 | int_led = 0; |
| jekain314 | 0:7a527a9bedce | 39 | } |
| sam_grove | 2:ec6da58dab61 | 40 | |
| jekain314 | 1:7972095b7aea | 41 | //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 | 42 | void xFire() |
| jekain314 | 0:7a527a9bedce | 43 | { |
| jekain314 | 0:7a527a9bedce | 44 | for(int i=1; i<16; i++) |
| jekain314 | 0:7a527a9bedce | 45 | { |
| jekain314 | 0:7a527a9bedce | 46 | wait_us(US_INTERVAL); |
| jekain314 | 0:7a527a9bedce | 47 | int_led = i; |
| jekain314 | 0:7a527a9bedce | 48 | } |
| jekain314 | 0:7a527a9bedce | 49 | return; |
| jekain314 | 0:7a527a9bedce | 50 | } |
| sam_grove | 2:ec6da58dab61 | 51 | |
| jekain314 | 0:7a527a9bedce | 52 | volatile bool trigger = 0; |
| jekain314 | 0:7a527a9bedce | 53 | Ticker trig; |
| jekain314 | 0:7a527a9bedce | 54 | void setTrig() |
| jekain314 | 0:7a527a9bedce | 55 | { |
| jekain314 | 0:7a527a9bedce | 56 | trigger = 1; |
| jekain314 | 0:7a527a9bedce | 57 | } |
| jekain314 | 0:7a527a9bedce | 58 | |
| jekain314 | 0:7a527a9bedce | 59 | int main() |
| jekain314 | 0:7a527a9bedce | 60 | { |
| jekain314 | 0:7a527a9bedce | 61 | // try open drain driving (internal pullup in camera?) |
| jekain314 | 0:7a527a9bedce | 62 | //x procedure not used below |
| jekain314 | 0:7a527a9bedce | 63 | x.mode(PullUp); |
| jekain314 | 0:7a527a9bedce | 64 | x.fall(&xFire); |
| jekain314 | 0:7a527a9bedce | 65 | |
| jekain314 | 0:7a527a9bedce | 66 | fire.output(); //set the fire pin as outoput |
| jekain314 | 0:7a527a9bedce | 67 | pre_fire.output(); //set the pre-fire pin as output |
| jekain314 | 0:7a527a9bedce | 68 | //fire.mode(OpenDrain); |
| jekain314 | 0:7a527a9bedce | 69 | |
| jekain314 | 0:7a527a9bedce | 70 | //set up for the first trigger |
| jekain314 | 0:7a527a9bedce | 71 | fire = 1; |
| jekain314 | 0:7a527a9bedce | 72 | pre_fire = 1; |
| jekain314 | 0:7a527a9bedce | 73 | |
| jekain314 | 0:7a527a9bedce | 74 | // reset the LED's |
| jekain314 | 0:7a527a9bedce | 75 | resetLed(); |
| jekain314 | 0:7a527a9bedce | 76 | |
| jekain314 | 0:7a527a9bedce | 77 | //trig is a ticker used to repeatedly fire a trigger at the interval (e.g., 7.5 secs) |
| jekain314 | 0:7a527a9bedce | 78 | trig.attach(&setTrig, 7.5f); //set ticker interval to 7.5secs |
| jekain314 | 0:7a527a9bedce | 79 | |
| jekain314 | 0:7a527a9bedce | 80 | // start the program |
| jekain314 | 0:7a527a9bedce | 81 | while(1) |
| jekain314 | 0:7a527a9bedce | 82 | { |
| jekain314 | 0:7a527a9bedce | 83 | // if(pc.readable()) //used to trigger from a keyboard click |
| jekain314 | 0:7a527a9bedce | 84 | // { |
| jekain314 | 0:7a527a9bedce | 85 | // char ch = pc.getc(); //read the keyboard click |
| sam_grove | 2:ec6da58dab61 | 86 | |
| jekain314 | 0:7a527a9bedce | 87 | //below used for repeatedly triggering on a ticker |
| jekain314 | 0:7a527a9bedce | 88 | if(trigger) //is the ticker has fired the trigger, proceed ... |
| jekain314 | 0:7a527a9bedce | 89 | { |
| jekain314 | 0:7a527a9bedce | 90 | trigger = 0; //reset the trigger to zero |
| jekain314 | 0:7a527a9bedce | 91 | |
| jekain314 | 0:7a527a9bedce | 92 | // turn all leds off to start the counter |
| jekain314 | 0:7a527a9bedce | 93 | resetLed(); |
| jekain314 | 0:7a527a9bedce | 94 | |
| jekain314 | 0:7a527a9bedce | 95 | // pre-fire the trigger using the mid-body 2.5mm connection (T2i) |
| jekain314 | 0:7a527a9bedce | 96 | pre_fire = 0; |
| jekain314 | 0:7a527a9bedce | 97 | |
| jekain314 | 0:7a527a9bedce | 98 | wait(.25f); //wait for 0.25 secs |
| jekain314 | 0:7a527a9bedce | 99 | |
| jekain314 | 0:7a527a9bedce | 100 | fire = 0; //fire the trigger using the tip connection |
| jekain314 | 0:7a527a9bedce | 101 | |
| sam_grove | 2:ec6da58dab61 | 102 | wait_ms(WAIT_KNOWN_MS); // empirically known delay to get us to the range of the 4 timing LEDs |
| jekain314 | 0:7a527a9bedce | 103 | |
| jekain314 | 0:7a527a9bedce | 104 | // maybe we need more or later just use these... |
| jekain314 | 0:7a527a9bedce | 105 | //just count up to 16 diaplaying the results on the LEDs |
| jekain314 | 0:7a527a9bedce | 106 | for(int i=1; i<16; i++) |
| jekain314 | 0:7a527a9bedce | 107 | { |
| jekain314 | 0:7a527a9bedce | 108 | wait_ms(MS_INTERVAL); |
| jekain314 | 0:7a527a9bedce | 109 | int_led = i; //write to the BusOut to display the counter on 4 LEDs |
| jekain314 | 0:7a527a9bedce | 110 | } |
| jekain314 | 0:7a527a9bedce | 111 | |
| jekain314 | 0:7a527a9bedce | 112 | //reset for the next trigger |
| jekain314 | 0:7a527a9bedce | 113 | // release the trigger |
| jekain314 | 0:7a527a9bedce | 114 | fire = 1; |
| jekain314 | 0:7a527a9bedce | 115 | pre_fire = 1; |
| jekain314 | 0:7a527a9bedce | 116 | } |
| jekain314 | 0:7a527a9bedce | 117 | } |
| jekain314 | 0:7a527a9bedce | 118 | } |
