Camera Flash Trigger showing assembly Interrupts within PBP


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Location
    UK-Midlands
    Posts
    84

    Default Camera Flash Trigger showing assembly Interrupts within PBP

    Hello All,

    This is a program to control a camera slave flash.
    Triggered from the cameras own inbuilt flash.

    The program is very small demonstrating the use of assembly interrupts in PicBasic Pro.
    This program uses Interrupt On Change on a single bit of the GPIO port.

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : Bob Simpson                                       *
    '*  Notice  : Copyright (c) 2009 Bob Simpson                    *
    '*          : All Rights Reserved                               *
    '*  Date    : 07/02/2009                                        *
    '*  Version : 1.03                                              *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    
    '
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '  PIC Defines
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '
    @ DEVICE pic12F683, INTRC_OSC_NOCLKOUT
            ' System Clock Options
    @ DEVICE pic12F683, WDT_Off
            ' Watchdog Timer
    @ DEVICE pic12F683, PWRT_ON
            ' Power-On Timer
    @ DEVICE pic12F683, BOD_OFF
            ' Brown-Out Detect
    @ DEVICE pic12F683, MCLR_OFF
            ' MCLR external ON for enabled
    @ DEVICE pic12F683, IESO_ON
            ' Internal osc start-up 
    @ DEVICE pic12F683, FCMEN_OFF
            ' OSC fail detect Detect
    @ DEVICE pic12F683, CPD_OFF
            ' Data Memory Code Protect
    @ DEVICE pic12F683, PROTECT_OFF
            ' Program Code Protection
    
    DEFINE OSC 8                ' PIC will run at 8Mhz so tell PBP
    DEFINE  INTHAND intcamera   ' Tell PBP that there is an interrupt routine
    
    '
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '  Port Setup
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '
    INTCON = 0          ' Disable the global interrupt
    OSCCON=%01110001    ' Internal 8 Mhz clock
    ANSEL=0             ' All Port A is Digital
    CMCON0=%0000111     ' Comparators off
    VRCON.7=0           ' Power down comparators
    CMCON0=7            ' Power down voltage Ref  
    TRISIO=%111000      ' GPIO bit 0,1 and 2 are outputs rest inputs
    WPU=%010000         ' Pull-up for GPIO.4 selected
    OPTION_REG.7=0      ' Enable internal pull-ups
    IOC =%010000        ' Interrupt on change selected for GPIO.4
    
    '
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '  Variables and Names Setup
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '
        wsave   VAR	BYTE bank0 system	' Saves W
        ssave   VAR	BYTE bank0 system	' Saves STATUS
        psave   VAR BYTE bank0 system 
        TRIG    VAR	BYTE bank0          ' Not used yet 
        B1      var BYTE                ' Temp store
        FTrig   VAR GPIO.4              ' Input from LED 
        LCAMERA VAR GPIO.1              ' Output to low voltage trigger
        HCAMERA VAR GPIO.0              ' Output to High voltage trigger
    
        CLEAR                   ' Clear all variables	
        GoTo mainloop           ' jump over the interrupt handler 
    
    '
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '  Interrupt Routine
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '
    Asm
    intcamera 
    ; Save W, STATUS and PCLATH registers
        movwf wsave
        swapf STATUS,W
        clrf STATUS
        movwf ssave
        movf PCLATH,W
        movwf psave
    
    ; Trigger Camera output on flash ip
        bsf     _LCAMERA        ; Set output to 1
        bsf     _HCAMERA        ; Set output to 1
        clrf    _TRIG           ; Clear tick store (For future changes. Not used yet)
        MOVF    GPIO,W          ; Read Port to clear IOC flag
        bcf     INTCON, GIE     ; Clear Global interrupt flag in INTCON register  
        bcf     INTCON, GPIE    ; Clear port change interrupt enable flag in INTCON register  
        bcf     INTCON, GPIF    ; Clear interrupt flag in INTCON register  
    
    endint
    ; Restore PCLATH, STATUS and W registers
        movf psave,W
        movwf PCLATH
        swapf ssave,W
        movwf STATUS
        swapf wsave,F
        swapf wsave,W
        retfie
     
    EndAsm
     
    '
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '  Main Program Starts Here
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '
    MainLoop:
        INTCON=0                ' Disable all interrupts and PortA IOC
        LCAMERA=0
        HCAMERA=0
        B1=GPIO                 ' Read port to ensure no setting of IOC flag
        INTCON =%10001000       ' Enable the RA port change interrupt
        NAP 5                   ' Sleep till portA change. Watchdog switched off 
        PAUSEUS 4               ' Give everything time to settle down
    
    FlashTriggered:
        INTCON =0               ' Disable interrupts. 
        pause 500               ' Wait 1/2 second with outputs switched on. Remember outputs have been switched on in the assembler interrupt routine
        LCAMERA=0
        HCAMERA=0               ' Now switch both outputs off
        GOTO MainLoop
    
    END
    I am no PicBasic Pro Guru, that mantel is firmly in the hands of others.
    But the program is very small with frequent comments and hopefully there are no major mistakes?
    Also attached is a zip file contains the information to make a Slave Flash Trigger.

    The flash unit has performed over the past 2 weeks with no problems.

    Regards,
    Bob
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Very nice Bob! I've got a few 'peanut' slaves in my bag and they are handy, but I think I'll have to build one of yours to play with. I like the idea of being able to trip two flashes simultaneously, without needing two slaves.
    If you want to see pricey accessories, check out the Pocket Wizards. They are professional level radio slaves, and will take a big bite out of your wallet.

    Thanks for sharing this,

    Jerry.
    If your oscilloscope costs more than your car...

  3. #3
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90


    Did you find this post helpful? Yes | No

    Thumbs up

    nice job BobP
    I built some of these back a few years ago for my game camera
    lot cheaper that store bought stuff
    thanks for sharing
    cheers
    " be nice it's people like me that make people like you look smart"
    yes I read the datasheet, of the 300 pages I understood 10

Similar Threads

  1. camera delays
    By MOUNTAIN747 in forum General
    Replies: 4
    Last Post: - 27th January 2010, 06:16
  2. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10
  3. Passing arrays PBP <-> Assembly
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th April 2006, 01:01
  4. Assembly Language + PBP
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th January 2006, 13:54
  5. Compact Flash with PBP
    By MORAND in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th May 2004, 22:32

Members who have read this thread : 1

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