CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

My Sony ir Sender Source code

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Onur
Guest







My Sony ir Sender Source code
PostPosted: Sat Feb 28, 2004 2:24 pm     Reply with quote

#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







PostPosted: Sun Feb 29, 2004 7:08 am     Reply with quote

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
PostPosted: Sun Feb 29, 2004 1:35 pm     Reply with quote

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

View user's profile Send private message

Sony IR
PostPosted: Sun Feb 29, 2004 6:36 pm     Reply with quote

Try this site:

Analysis of data signals used by SONY remote controls

http://cgl.bu.edu/GC/shammi/ir/

This for the command reference:

http://www.undeadscientist.com/slink/ircommands.html
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

Re: ins
PostPosted: Mon Mar 01, 2004 10:39 am     Reply with quote

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







PostPosted: Thu Mar 04, 2004 2:30 am     Reply with quote

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







PostPosted: Thu Mar 11, 2004 3:44 am     Reply with quote

Thank you Bruce... this is working on my tv...

THANK YOUUUUU.. Laughing Laughing Laughing
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group