View previous topic :: View next topic |
Author |
Message |
Onur Guest
|
My Sony ir Sender Source code |
Posted: Sat Feb 28, 2004 2:24 pm |
|
|
#include <16F628.h>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOPUT,NOLVP,NOMCLR
#use delay(clock=8000000)
int i;
int q;
int k;
/////////////////////////byte a;
void Send(int x){
for(i=0;i<x;i++){
output_High(pin_b3);
delay_cycles(40);// 0.5 X 40 =5us or use 0.5x25=12.5
output_Low(pin_b3);
delay_cycles(10);// 0.5 X 10 =20us or use 0.5x25=12.5
// duty cycle 1/4
}
i=0;
x=0;
Delay_us(600);
}
//40khz=1/t
//t=25us
//for 0 send 0,6 ms square wave
//for 1 send 1.2 ms square wave
//you must wait every pulse later 0,6 ms
//96 X (12.5x2)=2400us
//24 X (12.5x2)=600us
//44 X (12.5x2)=1200us
main() {
output_Low(pin_b3);
while (true){
send(96); heder pulse
//command = 19 (volume up)
send(48);//1
send(48);//1
send(24);//0
send(24);//0
send(48);//1
send(24);//0
send(24);//0
//device code = 1 (for tv)
send(48);//1
send(24);//0
send(24);//0
send(24);//0
send(24);//0
delay_ms(45);
delay_ms(100);
}
}
This is my Sirc (Sony infrared ...)project
this code working on universal ir receiver.
but my sony tv cant understand this code...
every thing is ok but my tv cant understand..
if I used my sony tv remote on uni.ir.rec.
I see the some cod.
my remote program and sony code same..
but my remote code not work in my tv..
sony remote is RM-836
Have you got any idea about this? |
|
|
Ttelmah Guest
|
|
Posted: Sun Feb 29, 2004 7:08 am |
|
|
The obvious comment is that you are probably too far off frequency.
The output_low, and output_high instructions, themselves take time, as does the loop counter itself (one cycle each for the former, and probably between five and ten cycles for the latter- you would need to count cycle times in the assembler to work out the real error). Hence you loop time is probably more like 35KHz, than 40KHz.
I'm also not usre about your bit time defintions. My memory was that they used something like 1.6mSec, and 1.1mSec for 1/0 (a 3:2 ratio), not 1:1. You need to check this.
Also normally on remotes, the 'on' time is kept short to keep the battery consumption low (and often to recharge a capacitor between each pulse). I'm therefore suprised at the 4:1 'on' time, unless the LED is wired to be 'on' then the output is low.
Best Wishes |
|
|
Onur Guest
|
ins |
Posted: Sun Feb 29, 2004 1:35 pm |
|
|
Thank you for your reply. I understand you.
where can I find all instraction how long time?
I know asm code how long take time. but I dont know C code.
Thank you again. |
|
|
sar
Joined: 08 Sep 2003 Posts: 36
|
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
Re: ins |
Posted: Mon Mar 01, 2004 10:39 am |
|
|
Onur wrote: | Thank you for your reply. I understand you.
where can I find all instraction how long time?
I know asm code how long take time. but I dont know C code.
Thank you again. |
Look at the .lst file. You can quickly count the asm instructions for each C line. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Bruce Guest
|
|
Posted: Thu Mar 04, 2004 2:30 am |
|
|
You need ~500uS delay between each individual data bit (40kHz burst), and ~25mS between each data packet.
Adjust your send routine to compensate for the loop time. This example
running at 20MHz works really well. It looks just like the signal from my Sony transmitter on my scope.
// Start pulse = 2.5mS
// Binary 1 = 1.2mS
// Binary 0 = 0.6mS
// 20-30mS pause between each transmission (packet)
void Send(int x){
int i;
for(i=0; i<x; i++)
{
output_high(PIN_B1);
delay_cycles(54); // ~10.8uS high @ 20MHz
output_low(PIN_B1);
delay_cycles(55); // ~11.0uS low. 21.8uS @ 20MHz
} // + ~3.2uS overhead = 25uS = 40kHz
{
delay_us(500); // 500uS delay between each data bit (40kHz burst)
}
}
void main() {
while (1){ // Modulate IR LED
//command = 19 (volume up)
send(96);// Header
send(48);//1
send(48);//1
send(24);//0
send(24);//0
send(48);//1
send(24);//0
send(24);//0
//device code = 1 (for tv)
send(48);//1
send(24);//0
send(24);//0
send(24);//0
send(24);//0
delay_ms(25); // 25mS delay between data packets
}
} |
|
|
Onur Guest
|
|
Posted: Thu Mar 11, 2004 3:44 am |
|
|
Thank you Bruce... this is working on my tv...
THANK YOUUUUU.. |
|
|
|