Pentax IR Remote


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    130

    Default Pentax IR Remote

    I want to make an infrared remote for the new pentax cameras for doing timelapses, as any timelapse shooter it involves triggering a IR sequence every X amount of time. The interval part is pretty straightforward, I want a little help regarding the IR sequence.

    Here is the required pulse train:



    What would be the best way to send this thru a pic 12F683 pin? First I tought about using PWM or HPWM but these are limited to 32Khz

    Thanks in advance!


    Pablo

  2. #2
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    This is what I got so far, I need to test it tomorrow with a camera, in simulation it looks OK, but I'm open to suggestions for improvement.

    I need to code the operator input side of the program where the user selects with a pot the interval, now it just triggers once a second

    Code:
    '****************************************************************
    '*  Name    : pentax.BAS                                        *
    '*  Author  : PEU based on examples from www.rentron.com        *
    '*  Notice  : Copyleft (c) 2011                                 *
    '*          : No Rights Reserved on derived work                *
    '*  Date    : 04-Jan-11                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '****************************************************************
    @ #define IRTX GPIO  ; Define port to use for IR out
    @ #define PIN 2      ; Define port pin to use for IR out
    @ device pic12f683,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off
    
    
    DEFINE OSC 4
      GPIO.2 = 1       ' IR LED off   -----|<|----/\/\/\----+5
      TRISIO.2 = 0     ' Output for IR signal
      CMCON0 = 7        ' Comparators disabled
      ANSEL = 0        ' A/D disabled
       
    ' IR carrier generator routines. Freq.inc.
    
      Cycles VAR BYTE    ' Number of carrier cycles
    
      PAUSE 100
      GOTO OverFreq  ' jump over pulse routines
      
    
    ' Generate "Cycles" number of ~38.4kHz pulses
    ASM
    _Pulse38
       bcf IRTX,PIN     ; 1uS, LED=on
       goto $+1         ; + 2uS = 3uS
       goto $+1         ; + 2uS = 5uS
       goto $+1         ; + 2uS = 7uS
       goto $+1         ; + 2uS = 9uS
       goto $+1         ; + 2uS = 11uS
       goto $+1         ; + 2uS = 13uS   
       bsf IRTX,PIN     ; 1uS, LED=on
       goto $+1         ; + 2uS = 3uS
       goto $+1         ; + 2uS = 5uS
       goto $+1         ; + 2uS = 7uS
       goto $+1         ; + 2uS = 9uS
       nop              ; + 1uS = 10uS
       decfsz _Cycles,f ; + 1uS = 11S    
       goto _Pulse38    ; + 2uS = 13uS
       return           ; Return to caller    
    ENDASM
    
    OverFreq:
           
      Main:
      
        sleep 1 'sleep one second
        gosub trigger 'send trigger pulse
           
      GOTO Main
      
    Trigger:            'generate pentax trigger pulse
      Cycles = 255      
      CALL Pulse38
      Cycles = 244      
      CALL Pulse38
      pauseus 3000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 5000        'end of stream
    return
      
      
      END

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    Or You can try something like this :
    Code:
    @ device  pic12F683, XT_OSC, wdt_off, pwrt_on, mclr_off, protect_off, bod_off
    DEFINE OSC 4
    INCLUDE "MODEDEFS.BAS" 
    
    GPIO      =       %00111011	
    TRISIO    =       %00111011  ' ATTENTION !!!
    CCP1CON   =       %00001100  ' Mode select = PWM
    T2CON     =       %00000100  ' Timer2 ON + 1:1 prescale 
    PR2       =       %00011001  ' Set PWM frequency to 39kHz
    ANSEL     =       %00000000
    CMCON0    =       %00000111
    
    but1 	var GPIO.0
    
    ; gpio.2 is CCPR1L
    CCPR1L = 0
    
    i	var byte
    '=========================================
    main:
     pause 100
    
    if but1=1 then  do_command
    
    
    do_command:
    	CCPR1L=8
            pauseus 1300
    	CCPR1L=0
            pauseus 300 
    for i=1 to 7     
    	CCPR1L=8
            pauseus 100
    	CCPR1L=0
    	pauseus 100
    next i
    
    PAUSE 500
    
    Goto Main

  4. #4
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    The code I posted had the duty cycle inverted, just modified the assembly routine (swapped BSF & BCF) and it works, just tested it with my pentax Kx. Im happy

    fratello: tested your code but it does not work, then I simulated it and the pulsetrain was very noisy maybe thats the cause.

    Here is the modified code:

    Code:
    '****************************************************************
    '*  Name    : pentax.BAS                                        *
    '*  Author  : PEU based on examples from www.rentron.com        *
    '*  Notice  : Copyleft (c) 2011                                 *
    '*          : No Rights Reserved on derived work                *
    '*  Date    : 04-Jan-11                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : pablou at gmail dot com                           *
    '****************************************************************
    @ #define IRTX GPIO  ; Define port to use for IR out
    @ #define PIN 2      ; Define port pin to use for IR out
    @ device pic12f683,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off
    
    
    DEFINE OSC 4
      GPIO.2 = 1       ' IR LED off   -----|<|----/\/\/\----+5
      TRISIO.2 = 0     ' Output for IR signal
      CMCON0 = 7        ' Comparators disabled
      ANSEL = 0        ' A/D disabled
       
    ' IR carrier generator routines. Freq.inc.
    
      Cycles VAR BYTE    ' Number of carrier cycles
    
      PAUSE 100
      GOTO OverFreq  ' jump over pulse routines
      
    
    ' Generate "Cycles" number of ~38.4kHz pulses
    ASM
    _Pulse38
       bsf IRTX,PIN     ; 1uS, LED=on
       goto $+1         ; + 2uS = 3uS
       goto $+1         ; + 2uS = 5uS
       goto $+1         ; + 2uS = 7uS
       goto $+1         ; + 2uS = 9uS
       goto $+1         ; + 2uS = 11uS
       goto $+1         ; + 2uS = 13uS   
       bcf IRTX,PIN     ; 1uS, LED=on
       goto $+1         ; + 2uS = 3uS
       goto $+1         ; + 2uS = 5uS
       goto $+1         ; + 2uS = 7uS
       goto $+1         ; + 2uS = 9uS
       nop              ; + 1uS = 10uS
       decfsz _Cycles,f ; + 1uS = 11S    
       goto _Pulse38    ; + 2uS = 13uS
       return           ; Return to caller    
    ENDASM
    
    OverFreq:
           
      Main:
      
        sleep 1 'sleep one second
        gosub trigger 'send trigger pulse
           
      GOTO Main
      
    Trigger:            'generate pentax trigger pulse
      Cycles = 255      
      CALL Pulse38
      Cycles = 244      
      CALL Pulse38
      pauseus 3000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 1000
      cycles = 37
      CALL Pulse38
      pauseus 5000        'end of stream
    return
      
      
      END
    Last edited by peu; - 5th January 2011 at 17:05. Reason: typo

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


    Did you find this post helpful? Yes | No

    Default

    Actually - it should work either way, but your last version will be leaving the IR LED ON if the cathode is connected to GPIO.2.
    Regards,

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

  6. #6
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Actually - it should work either way, but your last version will be leaving the IR LED ON if the cathode is connected to GPIO.2.
    You are right, I left it again the way you coded it and it works the same

    Thanks for the example BTW, without it I would be lost.
    I finished the full timelapse+remote code but Im keeping it to myself at this moment, the code I posted and a little thinking will serve as the foundation to do any remote trigger operation with Pentax cameras.

    Happy 2011

  7. #7


    Did you find this post helpful? Yes | No

    Default Double clock and use HPWM

    I did a similar camera control several years back. I used HPWM which will go to 38+KHz if you define the oscillator as one value then load a crystal of twice that value.

    For example
    DEFINE OSC 10 but in practice load a 20 MHz crystal.
    HPWM 1, 127, 19400

    That shags all your other timings so it can get tricky with other delays and serial in/out but it works for me.

    HTH
    BrianT

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