Here is version 2 of the PENTAX / NIKON IR remote, yes, I added Nikon support, needs to be tested with a Nikon camera as I don't have one.
Removed Darrel's Instant Interrupt elapsed timer because I was unable to make it work, also polished the code a little. As previous versions there is room for improvements, I hope someone else is interested in making it even better.
The device while sleeping uses only one microampere, so its suitable to be used with a button 3v 2032 battery.
You can add a second pushbutton but normally closed for power supply to briefly reset the remote to use it for timelapses again.[edit] or enable MCLR and use a normal pushbutton conecting pin 4 to GND and a 10k pull up resistor to VDD.
Attached is the HEX file for 12F683

Code:
'****************************************************************
'* Name : pentax.BAS *
'* Author : PEU based on examples from www.rentron.com *
'* Notice : Pablo E. Untroib (c) 2011 *
'* : No Rights Reserved on derived work *
'* : Free for personal use
'* Date : 11-ENE-11 *
'* Version : 2.10 *
'* Notes : pablou at gmail dot com *
'* : Consumption while sleeping is 1 microamper *
'****************************************************************
@ DEVICE PIC12F683,INTRC_OSC_NOCLKOUT,WDT_ON,MCLR_OFF,BOD_OFF,PWRT_OFF
@ #define IRTX GPIO ; Define port to use for IR out
@ #define PIN 2 ; IR LED output GND---/\/\/\---|<|--GPIO.2
define OSC 4 ' Defines oscilator frequency
'DEFINE DEBUG_REG GPIO ' used at debug time
'DEFINE DEBUG_BIT 4
'DEFINE DEBUG_BAUD 2400
GIE VAR INTCON.7 ' Global interrupt enable 1=ON, 0=OFF
GPIE VAR INTCON.3 ' Port change interrupt enable 1=ON, 0=OFF
GPIF VAR INTCON.0 ' Port Change Interrupt Flag bit
LED VAR GPIO.1 ' LED output GND---/\/\/\---|<|--GPIO.1
Cycles VAR BYTE ' Number of carrier cycles
ContaSec var word ' Seconds Counter
ContaMili var byte ' Miliseconds Counter
TLFlag var byte ' Timelapse counter programmed?
BOTON var GPIO.5 ' Key input (10K pull-UP w/switch to ground)
CMCON0 = 7 ' All digital
GPIO = 0 ' Clear port on boot
TRISIO = %00100000 ' GPIO.5 input, rest outputs
GIE = 0 ' Disable global ints
GOTO OverASM ' jump over ASM routines
' Generate "Cycles" number of ~38.4kHz pulses Bruce at www.rentron.com
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
OverASM: ' END of ASM routines
contasec = 0
ContaMili = 0
tlflag = 0
while boton = 0 ' Loops while the button is pressed
contamili = contamili + 1
pause 100
if contamili = 8 then ' I count 0 to 8 so I can flash the LED 100ms
contamili = 0
contasec=contasec + 1
high led
pause 100
low led
endif
tlflag=1 ' This flags lets me know if the timer was used
wend
' this is needed because the SLEEP takes about 2.3 seconds to react
' see SLEEP description in PBP manual
if contasec > 2 then
contasec = contasec - 2
endif
pause 1000 ' debounce pushbutton
'Loop del TimeLapse
if tlflag = 1 then ' if the timer was used continue
while boton = 1
sleep contasec ' sleep programmed time
gosub trigger ' trigger
high led ' red LED on
pause 50 ' little pause
low led ' red LED off
wend
WDTCON = 0 ' Disable WDT when not needed for power savings
' Timelapse ended because the button was pushed
for contasec = 1 to 5
high led ' flash red LED to let the user know timelapse ended
pause 100
low led
pause 100
next
endif
GPIE = 1 ' Enable port change int
IOC.5 = 1 ' Int-on-change for GPIO.5 enabled
' Main loop works as a normal remote,
' one push triggers, hold pushbutton triggers continuously
Main:
@ SLEEP ' SLEEP until Key is pressed
WHILE Boton = 0 ' Wait for Key release
gosub trigger
high led
pause 200
WEND
low led
GPIF = 0 ' Clear port change interrupt flag
GOTO Main
Trigger: ' PENTAX pulse train begins
Cycles = 255
CALL Pulse38
Cycles = 239
CALL Pulse38
pauseus 3000
cycles = 38
CALL Pulse38
pauseus 1000
cycles = 38
CALL Pulse38
pauseus 1000
cycles = 38
CALL Pulse38
pauseus 1000
cycles = 38
CALL Pulse38
pauseus 1000
cycles = 38
CALL Pulse38
pauseus 1000
cycles = 38
CALL Pulse38
pauseus 1000
cycles = 38
CALL Pulse38
pauseus 2000 ' end PENTAX pulse train with 2ms pause
Cycles = 76 ' NIKON pulse train begins
CALL Pulse38
pauseus 28000
cycles = 15
CALL Pulse38
pauseus 1580
cycles = 15
CALL Pulse38
pauseus 3580
cycles = 15
CALL Pulse38
pauseus 63200
Cycles = 76
CALL Pulse38
pauseus 28000
cycles = 15
CALL Pulse38
pauseus 1580
cycles = 15
CALL Pulse38
pauseus 3580
cycles = 15
CALL Pulse38
pauseus 2000 ' end NIKON pulse train with 2ms pause
return
END
Instructions:
to enable timelapse function press pushbutton while powering ON the remote, the red led will flash each second passed, once you release the pushbutton this will be the interval time.
to exit the timelapse mode, just press the pushbutton longer than the intervall, once out of the mode the red led will flash briefly.
After exiting timelapse mode, if you press the pushbutton momentarily it will trigger once, if you keep it pressed it will trigger continuously.
if you start the remote without the pushbutton pressed it will work like previous paragraph.
Bookmarks