digital slave with 12f629


Closed Thread
Results 1 to 12 of 12
  1. #1
    ratsnest's Avatar
    ratsnest Guest

    Default digital slave with 12f629

    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

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    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?
    Code:
    ' // 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
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default Re: digital slave with 12f629

    deleted stuff... (Bruce had more useful info)
    Arch

    Last edited by Archilochus; - 23rd January 2005 at 18:58.

  4. #4
    ratsnest's Avatar
    ratsnest Guest


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    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.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    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

  7. #7
    ratsnest's Avatar
    ratsnest Guest


    Did you find this post helpful? Yes | No

    Default

    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.

  8. #8
    ratsnest's Avatar
    ratsnest Guest


    Did you find this post helpful? Yes | No

    Default

    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

  9. #9
    ratsnest's Avatar
    ratsnest Guest


    Did you find this post helpful? Yes | No

    Default

    TTT

  10. #10
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Hi ratsnest,
    Do you have any ideas on the timing of the pre-flashes -
    how long ON, and time between?

    Arch

  11. #11
    ratsnest's Avatar
    ratsnest Guest


    Did you find this post helpful? Yes | No

    Default

    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.

  12. #12
    Rolf's Avatar
    Rolf Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ratsnest
    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

Similar Threads

  1. Another I2C Slave Routine Problem
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 05:50
  2. Digital Out on an A/D pin safe ?
    By mr.sneezy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st January 2009, 22:48
  3. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  4. Replies: 4
    Last Post: - 24th January 2007, 22:20
  5. Digital IC Tester
    By precision in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th September 2006, 03:38

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts