1 Attachment(s)
I think I made some mistakes...
...because with the code posted up, ISIS show me this results for "vol_up" like in picture attached ; it's something wrong ?! Thanks for your attention & cooperation !
Instead to party for my Birthday....
I spend time with this "killer" code. Now I discover another strange phenomenon : anything I do, can't generate "train" of pulse.
Instead generating for 4 times this sequence : high 2650 ,pause 2500, high 660, pause 100
I have just ONE sequence for about 42.25 mS !!!
WHY ?!?
Code:
main:
zecime CON 106 '// = ( 106 * 25uS) = 2650 uS burst
unu CON 24 '// = (24 * 25uS) = 0.60 mS burst
delay CON 104
i var byte
cycles var byte
acycles var byte
;============================
Main:
IF but1=0 then ; VOLUME UP
goto ir_send
endif
Goto Main
'=========================================
ir_send:
cycles=zecime
acycles=unu
for i=1 to 4
call Pulse
pauseus delay
call Pulser
next i
Pauseus 100
Goto main ' or Return, have no result !
Pulse: ' Generate "Cycles" number of 40kHz pulses
ASM
bsf gpio, 2 ; 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 gpio, 2 ; 1uS, LED=off
goto $+1 ; + 2uS = 3uS
goto $+1 ; + 2uS = 5uS
goto $+1 ; + 2uS = 7uS
goto $+1 ; + 2uS = 9uS
decfsz _Cycles,f ; + 1uS = 10S
goto _Pulse ; + 2uS = 12uS
return ; Add 2uS for return to caller
ENDASM
Pulser: ' Generate "Cycles" number of 40kHz pulses
ASM
bsf gpio, 2 ; 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 gpio, 2 ; 1uS, LED=off
goto $+1 ; + 2uS = 3uS
goto $+1 ; + 2uS = 5uS
goto $+1 ; + 2uS = 7uS
goto $+1 ; + 2uS = 9uS
decfsz _Acycles,f ; + 1uS = 10S
goto _Pulser ; + 2uS = 12uS
return ; Add 2uS for return to caller
ENDASM
Thanks again for attention !
1 Attachment(s)
Heeeeeelp, please ...:(....
I try different variant of PBP code; no result.
I find the example of Mr.Bruce :
Code:
' IR carrier generator routines. Freq.inc.
Cycles VAR BYTE ' Number of carrier cycles
GOTO OverFreq ' jump over pulse routines
' Generate "Cycles" number of 40kHz pulses
ASM
_Pulse40
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
decfsz _Cycles,f ; + 1uS = 10S
goto _Pulse40 ; + 2uS = 12uS
return ; Return to caller
ENDASM
' 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:
so I write my program, for the hardware like in schematic ( for now I test just Volume Up) :
Code:
@ DEVICE PIC12F675, intrc_osc, wdt_off, pwrt_off, mclr_off, bod_off
DEFINE OSC 4
DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1k -HELPS tuning the crystal for more accurate timing
@ #define IRTX GPIO ; Define port to use for IR out
@ #define PIN 1 ; Define port pin to use for IR out
INCLUDE "Freq.inc" '
but var gpio.5
GPIO.5=1
TRISIO.5=1
GPIO.1 = 1 ' IR LED off -----|<|----/\/\/\----+5
TRISIO.1 = 0 ' Output for IR signal
WPU = %00111101
CMCON = 7 ' Comparators disabled
ANSEL = 0 ' A/D disabled
Loops VAR BYTE
Main:
if but=0 then
FOR Loops = 1 TO 10
Cycles = 102 ' 102 * 26 = 2652 uS
CALL Pulse38
Pauseus 2580 ' accurate pause of 2580 uS ?!?
Cycles = 25 ' 25 * 26 = 650 uS ; maybe must EXACTLY 660 uS - how ?!?
CALL Pulse38
pauseus 50000
pauseus 50000
Next loops
endif
GOTO Main
END
but, OF COURSE ?!?, no results. Somebody, just one little help ? Please...
YES ! Finally I have results !
After thousands of re-writing this code, I've got finally results :
Code:
@ DEVICE PIC12F675, INTRC_OSC_NOCLKOUT, wdt_off, pwrt_off, mclr_off, bod_off
DEFINE OSC 4
CMCON = 7 ' Comparators disabled
ANSEL = 0 ' A/D disabled
@ #define IRTX GPIO ; Define port to use for IR out
@ #define PIN 1 ; Define port pin for IR out
Puls_a CON 112 ' 112 x 26uS = 2912 mS ( pulse with carrier ON)
InterPulse CON 2800 ' 2.80mS (delay between pulses with carrier OFF)
Puls_b CON 28 ' 28 x 26uS = 728 uS ( pulse with carrier ON)
X VAR BYTE ' Data bit loop counter & bit index pointer
Duration VAR BYTE ' Duration of button press
Loops VAR BYTE ' Loop count
Cycles VAR BYTE BANK0 SYSTEM' Number of carrier cycles to generate
trisio=%11111101
option_reg.7=0
wpu =%11111101
but var gpio.5
GOTO Main ' Jump over pulse routine to Main
Pulse: ' Generate "Cycles" number of 40kHz pulses
ASM ; Keep this routine in code page 1, and jump over to Main
BSF IRTX,PIN ; 1 MAKE IR HIGH 35% Duty cycle = 9 uS
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
BCF IRTX,PIN ; 1 MAKE IR LOW 17 uS
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
GOTO $+1
DECFSZ Cycles,F
GOTO _Pulse ; 2 26 uS
ENDASM
return ' Return to caller
Main:
Duration = 2 ' Send it twice
IF BUT=0 THEN
For Duration = 1 to 2
Cycles = Synch ' carrier on
Call Puls_a ' Send pulse
PAUSEUS InterPulse ' Pause (carrier off)
Cycles = Logic0 ' carrier on
Call Puls_b ' Send pulse
Pauseus 50000
Pauseus 50000
Next Duration
ENDIF
GOTO Main ' Return for more
END
This is command for Volume Up only ; instead 102 cycles * 26 uS = 2650 uS, I put 112 * 26 = 2912, etc. So, the lenght of one pulse is 23.5 uS ?! Maybe with this PIC... Anyway, it's good to see that working, after hard work... Thank You all for support; every advice it's further wellcome !
without carrier, poor efficiency
Hi fratello,
Quote:
Originally Posted by fratello
Using PIC 16F628A I build this remote-by-wire for my Blaupunkt...
Did you change your mind? No IR anymore?
If I'm wrong and you still want to go for wireless, then you can improve a few points.
Quote:
Originally Posted by eggman
You should modulate your signal on a carrier of about 38 kHz...
Ignoring the use of a carrier frequency will make you very frustrated because of the very poor efficiency of your remote.
You can simply use the PWM module and PORTB.3 to do this; nothing else is necessary (not even assembly). The trick using PWM is to switch ON (set a value) and OFF (set to zero) the duty-cycle for the time of the HIGH and LOW pulses ;)
OR have a look here if you want to make it another way (adding external components): http://www.rentron.com/Infrared_Communication.htm
According to you schema, you need to "switch ON" permanently your circuit to be able to use it. What if you forget to switch it OFF during a few days? You may need to add a "soft-switch". A soft-switch will combine your buttons as command and power-switch; a simple search will help you.