...and I say in previous post :
Suggestions ? Thank You for attention !Code: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 ?!?
...and I say in previous post :
Suggestions ? Thank You for attention !Code: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 ?!?
You may very well declare a 1234usec delay but this depends on the accuracy of the System Clock (Crystal resonator or what ever).
So you may have to trim a little the value of the pauseus to get exactly the time you want.
In general IR systems I eel are able to tolerate such skews...
Ioannis
After thousands of re-writing this code, I've got finally results :
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 !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
It seems that the internal RC oscilator is not precise at least for the receiver you use.
It cannot tolerate small differencies of the transmission pulse width.
Either use a crystal oscillator or trim your delays so that they get precisely the value needed.
Ioannis
Using PIC 16F628A I build this remote-by-wire for my Blaupunkt Radio-SD Card. Work verry fine... even it's simple and can be improved.
Code:; ; Simple Remote-by-wire for Blaupunkt ; use RC10 protocol ; @ DEVICE pic16F628A, XT_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON, LVP_OFF, CPD_OFF, PROTECT_OFF DEFINE OSC 4 ; USE 4 MHz crystal TRISA= %00000000 TRISB= %00011111 CMCON=7 TO_BLAU VAR PORTA.0 TO_BLAU = 1 PULSA VAR WORD PULSB VAR WORD I VAR BYTE DELAYS CON 660 MAIN : PAUSE 500 IF PORTB.0 = 0 THEN 'volume + PULSA=2650 PULSB=2580 GOSUB PULSE ENDIF IF PORTB.1 = 0 THEN 'volume - PULSA = 3250 PULSB = 3200 GOSUB PULSE ENDIF IF PORTB.2 = 0 THEN 'mute PULSA = 5050 PULSB = 5000 GOSUB PULSE ENDIF IF PORTB.3 = 0 THEN 'SRC aka Source PULSA = 6875 PULSB = 6850 GOSUB PULSE ENDIF IF PORTB.4 = 0 THEN 'Next aka Right PULSA = 5660 PULSB = 5630 GOSUB PULSE ENDIF GOTO MAIN ;SUBROUTINE PULSE: FOR I = 1 TO 10 LOW TO_BLAU PAUSEUS PULSA HIGH TO_BLAU PAUSEUS PULSB LOW TO_BLAU PAUSEUS DELAYS HIGH TO_BLAU PAUSEUS 50000 PAUSEUS 50000 NEXT I RETURN END
Bookmarks