Pentax IR Remote


Results 1 to 24 of 24

Threaded View

  1. #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

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