'=============================================== ' RADIO CONTROLLED DIGITAL CAMERA I/FACE ' ' AUTHOR ' M. Shellim ' DATE ' 23/02/98 ' ' DESCRIPTION ' Monitors one channel of a Futaba receiver ' and controls Olympus C400L digital ' camera via i/o port configured for ' RS232 send/receive. ' ' COPYRIGHT Michael Shellim 1998 1999 ' For private/personal use only. ' This code is released on the understanding ' that it is not used or modified for ' commercial application without the ' author's prior consent. ' ' HISTORY ' v1.0 23/02/99 First version ' v1.1 10/12/99 MODS by Gary Thurmond ' Added RC fast fire_shutter loop. ' Calibrated await_with_timeout. ' Added pictime to misc. constants. ' RC mode dip switch sets repeat in 10 sec interval. As was. ' RC mode dip switch set to 00000(65535). NEW ' Repeat interval will be as short as the camera cycle time. ' D-340R, std. = 3.0 sec, HQ = 5.1 sec. ' Changes not yet subjected to rigorous testing. ' Seems to work but haven't tried hard to break it (Ditto - MS). ' ' Note that there are debug statements and maybe ' some rem's. Hope I cleaned out other edits I made ' that do not address the RC interval subject. ' This is not a final version, just an example ' of speeding up the interval in the RC mode. ' The subroutines that I have hacked at are - ' PUSH_SHUTTER, see comments there. ' AWAIT_WITH_TIMEOUT, see comments there. ' ' v1.2 11/03/00 ' Added SQ/HQ resolution selection. ' Joystick Up = SQ 640x480 ' Joystick Down = HQ or SHQ 1280x960 ' Routines affected - push_shutter & get_pulse ' Added hq to misc. constants ' '=============================================== ' ------------------------ ' Flashing LED parameters ' ------------------------ flash_len VAR WORD flash_num VAR BYTE flash_pin VAR BYTE ' --------- ' Baud rate ' --------- BAUD_MODE CON 16416 ' 19200 inverted ' ---------------------- ' I/O pin configuration ' ---------------------- ' Masks 111111 ' 5432109876543210 ' ---------------- TIMEOUT_MASK CON %0000000000111111 ' Pins 0-5 SEC10_OR_MIN CON %0000000001000000 ' Pin 6 MODE_MASK CON %0000000010000000 ' Pin 7 SERIN_PIN CON 10 SEROUT_PIN CON 11 RED_LED_PIN CON 13 RX_PIN CON 14 GREEN_LED_PIN CON 15 ' Pins - dev board 'RX_PIN CON 8 'SEROUT_PIN CON 11 'GREEN_LED_PIN CON 12 'RED_LED_PIN CON 15 'SERIN_PIN CON 14 ' -------------- ' Misc Constants ' -------------- pictime CON 43 ' D-340R in std Q mode (640x480) 'pictime CON 63 ' D-340R in HQ mode (1280x960) 'TIMEOUT_MULT CON 10 'SHUTTER_DURATION CON 1 ' --------- ' Misc vars ' --------- hq VAR BIT serData VAR BYTE prevPulse VAR BIT currPulse VAR BIT iloop VAR BYTE musecs VAR WORD timeout VAR WORD wMask VAR WORD ' ------------------------------------- ' P R O G R A M E N T R Y P O I N T ' ------------------------------------- '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gosub flash_roger if INS & MODE_MASK = 0 then main_rc if INS & MODE_MASK <> 0 then main_self_time '--------------------------- ' Subroutine main_self_time '--------------------------- main_self_time: ' Press shutter gosub push_shutter ' Wait for timeout. ' time-out period (secs) = 9.6 * timeout - 1.77 gosub read_timeout sleep timeout * 10 -2 ' Repeat goto main_self_time: '------------------------- ' Subroutine main_rc '------------------------- main_rc: currPulse = 1 ' To prevent initial triggering wait_for_toggle_on: ' Wait for the user to toggle shutter control off to on gosub rc_await_0_to_1 debug "0 to 1",cr press_shutter_and_wait: ' Press shutter, and wait till user resets Tx shutter button ' or timeout occurs gosub push_shutter gosub await_0_with_timeout ' If the shutter control was left ON (i.e. timed out), press ' shutter again and wait if currPulse = 1 then press_shutter_and_wait ' Otherwise, the shutter control was switched to off, so ' wait for it to be on. debug " ",cr debug "W T on",cr goto wait_for_toggle_on '--------------------------- ' Subroutine rc_await_0_to_1 '--------------------------- rc_await_0_to_1: PrevPulse = CurrPulse gosub get_pulse if PrevPulse = 1 or CurrPulse = 0 then rc_await_0_to_1 return '-------------------------------- ' Subroutine await_0_with_timeout '-------------------------------- await_0_with_timeout: intLoop var WORD ' Read timeout value from pins into "timeout" gosub read_timeout ' 100 Loops = ten seconds ' pictime is time from wakeup to pic finish for intLoop = 1 to (timeout * 100)- pictime gosub get_pulse if CurrPulse = 0 then await_0_end pause 85 next ' Timeout ! await_0_end return '------------------------- ' Subroutine PUSH_SHUTTER '------------------------- PUSH_SHUTTER: debug " ",cr debug "attn",cr ' ATTN ' Camera attn. takes ~0.82 sec, ~1.1 sec if it went to sleep, ' the Oly 180 sec. internal timeout. Serout SEROUT_PIN, BAUD_MODE, [$00] Serin SERIN_PIN, BAUD_MODE, 1300,serin_timeout,[WAIT ($15)] debug "baud 19200",cr ' Set baud = 19200 Serout SEROUT_PIN, BAUD_MODE, [$1B,$53,$06,$00,$00,$11,$02,$00,$00,$00,$13,$00] Serin SERIN_PIN, BAUD_MODE, 500,serin_timeout,[WAIT ($06)] debug "flash off",cr ' Force flash OFF Serout SEROUT_PIN, BAUD_MODE, [$1B,$43,$06,$00,$00,$07,$02,$00,$00,$00,$09,$00] Serin SERIN_PIN, BAUD_MODE, 500, serin_timeout,[WAIT ($06)] ' Default resolution is SQ, 640x480 66Kbyte .jpg if hq = 0 then fire_shutter debug "set resolution",cr ' Set resolution to HQ, 1280x960 225 Kbyte .jpg Serout SEROUT_PIN, BAUD_MODE, [$1B,$43,$06,$00,$00,$01,$02,$00,$00,$00,$03,$00] ' Set resolution to SHQ, 1280x960 450 Kbyte .jpg 'Serout SEROUT_PIN, BAUD_MODE, [$1B,$43,$06,$00,$00,$01,$03,$00,$00,$00,$04,$00] Serin SERIN_PIN, BAUD_MODE, 500, serin_timeout,[WAIT ($06)] fire_shutter: debug "fire",cr ' Fire shutter looks at dip switch and get_pulse after fist pic. ' If dip switch is zero (65535) and get_pulse is one then take ' another pic with all delays bypassed. ' Serout SEROUT_PIN, BAUD_MODE, [$1B,$43,$03,$00,$02,$02,$00,$04,$00] Serin SERIN_PIN, BAUD_MODE, 500,serin_timeout,[WAIT ($06)] debug "wait 06",cr Serin SERIN_PIN, BAUD_MODE, [WAIT ($05)] debug "wait 05",cr gosub read_timeout if timeout <> 65535 then baud_sleep gosub get_pulse if CurrPulse = 1 then fire_shutter baud_sleep: debug "reset resolution",cr Serout SEROUT_PIN, BAUD_MODE, [$1B,$43,$06,$00,$00,$01,$01,$00,$00,$00,$02,$00] Serin SERIN_PIN, BAUD_MODE, 500, serin_timeout,[WAIT ($06)] hq = 0 debug "baud 0",cr ' Set baud = 0 Serout SEROUT_PIN, BAUD_MODE, [$1B,$53,$06,$00,$00,$11,$00,$00,$00,$00,$11,$00] ' Reset resolution bit back to SQ gosub flash_roger done: return serin_timeout: debug "timeout",cr gosub flash_error goto done '-------------------------------------- ' Subroutine FLASH ' flashes a LED for a caller ' specified count and length of time. '-------------------------------------- FLASH: ' make flash_pin an output pin wMask = DCD flash_pin DIRS = DIRS | wMask ' Loop to output a 1 then 0. for iloop = 1 to flash_num ' Output a 1 OUTS = OUTS | wMask pause flash_len ' Output a 0 OUTS = OUTS & (~wMask) if iLoop = flash_num then flash_end pause flash_len next flash_end: return ' ------------------------------------- ' subroutine GET_PULSE ' ' Sets currPulse to 0 or 1 depending ' on the length of the receiver pulse ' being monitored on i/o pin 8. ' ' Joy Stick, PW, Treshold, musecs ' Down 1930 1850 925 ' Release 1650 825 ' Center 1500 750 ' Release 1350 675 ' Up 1040 1150 575 ' ----------------------------------- get_pulse: pulsin RX_PIN,1,musecs if musecs > 925 then pulse_hq '2x925=1850 mS. Joy Stick Down if musecs > 675 then pulse_off '2x575=1150 mS. Joy Stick Released if musecs < 575 then pulse_on '2x925=1850 mS. Joy Stick UP return pulse_hq hq = 1 pulse_on currPulse = 1 goto pulse_end pulse_off: currPulse = 0 pulse_end: return ' ------------------------------------- ' subroutine read_timeout ' variable "timeout" is assigned the ' number of 10 second periods to wait. ' (10 seconds is the smallest practical ' duration between shutter presses.) ' ------------------------------------- read_timeout: flMinutes VAR WORD ' Read i/o pins specifying timeout and units timeout = INS & TIMEOUT_MASK flMinutes = INS & SEC10_OR_MIN ' Treat zero timeout as max if timeout <> 0 then timeout_apply_mult timeout = 65535 goto timeout_end timeout_apply_mult: ' If minute units specified apply multiplier ' to convert to 10sec units. if flMinutes = 0 then timeout_end timeout = timeout * 6 timeout_end: return ' ----------------------- ' Subroutine FLASH_ERROR ' ------------------------ flash_error: flash_pin = RED_LED_PIN flash_num = 1 flash_len = 500 gosub flash return ' ----------------------- ' Subroutine FLASH_ROGER ' ------------------------ flash_roger: flash_pin = GREEN_LED_PIN flash_num = 3 flash_len = 100 gosub flash return