PDA

View Full Version : digital slave with 12f629



ratsnest
- 23rd January 2005, 15:42
I trying to build a slave flash trigger for a digital camera.
with a programmed 12f629.
need a little help with the code.
digital cameras have 1 or 2 preflashes before the main flash.
using a photodiode to trigger a input to GPIO.2 I'm thinking if I can program it to ignore the first 2 flashes and give a output on GPIO.4 to fire the slave flash on the 3rd. it mite work.
what little programming I can do is with PBP and CDlite.
can anybody give me A jump start. Thanks

Bruce
- 23rd January 2005, 18:50
There are probably a gozillion various ways to do this, but since you're already using GP2, and this pin is the Timer0 clock input, maybe something like this?


' // Internal RC OSC, WDT OFF, /MCLR reset function OFF
@ DEVICE INTRC_OSC_NOCLKOUT,WDT_OFF,MCLR_OFF

DEFINE OSCCAL_1K 1 ' Calibrate internal oscillator
GPIO = 0 ' All outputs to 0
TRISIO = %00000100 ' GPIO.2/T0CKI = input, rest outputs
CMCON = 7 ' Comparators OFF, all digital

' // Pull-ups on, TMR0 clock source = GP2/T0CKI input
' // Increment TMR0 on high-to-low transitions on GP2/T0CKI
' // Assign prescaler to WDT for 1:1 clocks on GP2/T0CKI
OPTION_REG = %00111000

' // Pre-load timer0 to over-flow on 3rd pulse on GP2/T0CKI
TMR0 = 253 ' 1st clk = 254, 2nd = 255, 3rd = over-flow & int

' // Enable global, peripheral & timer0 interrupts
INTCON = %11100000

On Interrupt Goto FireFlash

Main:
@ NOP
GOTO Main

DISABLE
FireFlash:
HIGH GPIO.4 ' Fire flash
PAUSEUS 500 ' Adjust for time you need to fire flash here
LOW GPIO.4
TMR0 = 253 ' Reload for 3rd pulse to trigger int
INTCON.2 = 0' Reset TMR0 int flag before leaving
RESUME ' Re-enable interrupts & return
ENABLE

END

Archilochus
- 23rd January 2005, 18:56
deleted stuff... (Bruce had more useful info)
Arch

ratsnest
- 23rd January 2005, 19:57
Thanks Bruce I will try it tomorrow.
I don't have to use GPIO.2 I just put that because That is what I normally use if it would be better to us another. I can and really if would be better for the whole operation If I did.

Bruce
- 23rd January 2005, 21:33
You can use whatever pins you might prefer if you're not using timer0 in counter mode as the pulse counter.

You also have timer1 that can function as a counter with the clock input on GP5 - or you could opt to count pulses in software.

I just showed "1" simple way out of many options.

Archilochus
- 24th January 2005, 01:12
I'm thinking that you'd probably want the processor to be asleep most of the time to save power.

If it was 'asleep' - could it wake up with an interrupt on the first pre-flash and be ready in time for the real flash? Don't know anything about the timing of the pre-flashes and such (or how long it takes the average PIC to wake-up from sleep) - but the 'real' flash will have to be in close sync with the cameras flash/shutter.

Arch

ratsnest
- 24th January 2005, 18:54
thank both of you
And Arch that what I had forgot Iam using the sleep and refesh to turn on the slave and to refesh the batteries. A interrupt on GPIO.2
wakes it up and turns the slave on (same time as camera).
which other pin is the best to trigger the flash using a counter overflow.
sorry I mixed thinks up. I need to show the whole project
I will post my code I wrote to do the power managment of the slave and then If yall will still help me. I can get it right.
codes at work will post later.

ratsnest
- 24th January 2005, 23:10
ok heres my code NO laughing
if I can use GPIO.4 input from the photodiode
and GPIO.1 as output to fire the flash that would work on the test board I have set up.
thanks

@ DEVICE pic12F629
@ DEVICE pic12F629, INTRC_OSC_NOCLKOUT
@ DEVICE pic12F629, WDT_ON
@ DEVICE pic12F629, MCLR_OFF
@ DEVICE pic12F629, CPD_OFF
@ DEVICE pic12F629, BOD_OFF
@ DEVICE pic12F629, PWRT_ON
@ DEVICE pic12F629, PROTECT_OFF

DEFINE OSC 4
Pause 20000 ' Allow pic to Stabilize
TRISIO = %00010100 ' make gpio 2 / 4 inputs
OPTION_REG.7 = 0 ' gpio 0 - 2 digital
WPU = 255 ' week pull ups on all pins
CMCON = 7 ' turn week pull ups on


SYMBOL SP = GPIO.0 'SLAVE POWER PIN 7
SYMBOL FLASH = GPIO.1 'FIRE FLASH PIN 6
SYMBOL GETREADY = GPIO.2 'GETREADY INPUT FROM CAMERA CONTROLLER PIN 5 SYMBOL TRIG =GPIO.4 'INPUT FROM PHOTODIODE TO TRIGGER FLASH PIN 3
SYMBOL LED = GPIO.5 'POWER OK PIN 2

SP= 0
FLASH =0
GETREADY=0
LED = 0

LED=1 'power up ok
Pause 4000
LED= 0
Pause 2000
SP =1 'turn slave on to charge cap.
Pause 8000
SP=0

MAIN
OPTION_REG=$0

ON INTERRUPT GoTo READY 'input from cam troller to get ready
INTCON=$90

REFRESH:
Sleep 14400 'give refresh charge to cap every 4hr. from interrupt
SP=1
Pause 10000
SP =0
GoTo REFRESH
Disable
READY:
SP =1
Pause 15000 'turns slave power on
SP=0
INTCON.1=0

Disable

GoTo MAIN
Enable

ratsnest
- 27th January 2005, 16:56
TTT

Archilochus
- 27th January 2005, 23:49
Hi ratsnest,
Do you have any ideas on the timing of the pre-flashes -
how long ON, and time between?

Arch

ratsnest
- 28th January 2005, 02:54
arch I'm clueless. should I use a learning mode like the store bought boards.( and no I do not know how to program that eather) I sent you a e-mail 1st. of the week did you get it.
any help on how I should handle this.

Rolf
- 14th August 2006, 03:06
arch I'm clueless. should I use a learning mode like the store bought boards.( and no I do not know how to program that eather) I sent you a e-mail 1st. of the week did you get it.
any help on how I should handle this.

Here is the timing I used on an analog Digital flash trigger:
http://www.pbase.com/sinoline/digital_slave_trigger