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 support@ccsinfo.com

IR cloner

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







IR cloner
PostPosted: Tue Feb 24, 2009 9:53 am     Reply with quote

Hi: I want to build a universal Ir remote controller cloner.
I want to record the original signal first, and later riproduce the code.
I think that I need only a few components: ie. a TSOP sensor, one pic16f628 and i IR trasmitter.
Someone Has a similar project o code???
Someone want to help me?
Thank 's at all.
Ln_mark7930
Guest







my code
PostPosted: Fri Feb 27, 2009 10:42 am     Reply with quote

I write this code but don't work perfectly. I can play perfectly the recorded input signal, but there are some little difference about the times.
I think that I must use a timer to measure the time witch signal stay low and high.
When i have the timer value, program record all cheange of signal into a buffer. When i want to reproduce the signal, I must reload a timer with the same value of the buffer.

If someone have some different idea please reply my post. Thank's at all.
Here my code:

Code:
/****************************************************
*            Registratore IR
*
*
* Acquisisce,memorizza e riproduce il codice ricevuto da
* un sensore tsop1730
******************************************************/


//#define DEBUG

#DEFINE 18F2520
#include <18F2520.h>

#ifdef DEBUG
  //#device *=16
   #device   ICD=TRUE
  #fuses HS,NOWDT,NOPUT,BROWNOUT,NOPROTECT,NOLVP,NOCPD
#else
  //#device *=16
   #device   ICD=TRUE
  #fuses HS,NOWDT,NOPUT,NOBROWNOUT,NOLVP,NOCPD
#endif

#use delay(clock=8000000)



/***************************************************
*                                          *
*     dichiarazione della variabili                *
*                     *   
***************************************************/

#define TSOP        PIN_C0   // Input
#define LEDSTATO     PIN_C1   // 0utput
#define IRout       PIN_C2   // 0utput
#define PLAY        PIN_C3   // Input
#define REC         PIN_C4   // Input
#define LEDPLAY     PIN_C5   // Output
#define LEDREC      PIN_C6   // Output
#define ERASE        PIN_C7   // Input

#use fast_io(c)

#define BUFFER_SIZE 400         // READ / WRITE Buffer

int8 dimensione2=BUFFER_SIZE/2;
int8 dimensione=BUFFER_SIZE;
int16 buffer[BUFFER_SIZE];


/************************************
*
*      Cancella Buffer Ingresso
*
************************************/

void Cancella(void)
{

int8 i=0,m=0;   
output_low(LEDREC);            // output low
output_low(LEDPLAY);
output_low(LEDSTATO);

for (i=0;i<dimensione;i++)      // ciclo per cancellare buffer
   {
   output_TOGGLE(LEDREC);
   output_TOGGLE(LEDPLAY);
   output_TOGGLE(LEDSTATO);
   buffer[i]=0x00;
   delay_ms(50);
   }

   for (m=0;m<255;m++)         // ciclo per cancellare memoria eeprom
   {
   output_TOGGLE(LEDREC);
   output_TOGGLE(LEDPLAY);
   output_TOGGLE(LEDSTATO);
   write_eeprom(m,0x00);
   delay_ms(10);
   }

output_low(LEDREC);
output_low(LEDPLAY);

}

/*******************************************
*
*         Riproduzione
*
********************************************/
void PlayIR(void)
{   
   int8 j=0,c=0,p=0;
   int8 timehigh_zero=0,timelow_zero=0, timehigh_one=0, timelow_one=0;
   int16 counter0,counter1;

//for(j=0;j<=200;j++)
//   {
//   timehigh_zero=read_eeprom ((0x00 + (j*2)));
//   timelow_zero=read_eeprom ((0x00 + (j*2)+1));
//
//   buffer[j]=make16 (timehigh_zero,timelow_zero);
//
//   timehigh_one=read_eeprom ((0x02 + (j*2)));
//   timelow_one=read_eeprom ((0x02 + (j*2)+1));
//   buffer[j+1]=make16 (timehigh_one,timelow_one);
//   }
 
counter1=0;   
counter0=0;

output_high(IRout);
delay_ms(20);
output_low(IRout);
delay_ms(20);

for(p=0;p<=200;p=p+2)      // ricostruisco il segnale registrato riproducendo il buffer
   {
   counter0=buffer[p];      // carico il contatore con il primo dato sul buffer
   output_low(IRout);      // prima riproduco il tempo in cui il segnale sta a zero
      for(c=0;c<5;c++)      // 5 è una costante di tempo
         {
            while(counter0!=0)      // finchè il contatore non arriva a zero
            {
            counter0--;            // decremento contatore
            delay_us(1);         // e aspetto 1 us
            }
         }

   counter1=buffer[p+1];      // carico il contatore con il primo dato + 1 sul buffer
   output_high(IRout);         // dopo riproduco il tempo in cui il segnale sta a uno
      for(c=0;c<5;c++)      // 5 è una costante di tempo
         {
            while(counter1!=0)      // finchè il contatore non arriva a zero
            {
            counter1--;         // decremento contatore
            delay_us(1);      // e aspetto 1 us
            }
         }
}
output_low(IRout);
}

/*******************************************
*
*         Salvataggio dati ricevuti
*
********************************************/
void RecIR(void)
{

int8 high0=0,low0=0,high1=0,low1=0;
int8 k,n;
int16 tempo_zero=0,tempo_one=0;

BYTE next_in = 0;
 
   while (input(TSOP)==1) {};         // Aspetto finchè il TSOP non va a zero ( significa che sta ricevendo qualche segnale IR)

for (k=0;k<=100;k++)               // campiono 100 volte= significa 100 salite e 100 discese
         {
         tempo_zero=0;            // resetto contatore
         while (input(TSOP)==0)      // finche il segnale è basso   
            {
            delay_us(1);         // ritardo di 1 us
            tempo_zero++;         // incremento tempo_zero
            }

         tempo_one=0;            // resetto contatore
         while (input(TSOP)==1)      // finche il segnale è basso
            {
            delay_us(1);         // ritardo di 1 us
            tempo_one++;         // incremento tempo_one
               if (tempo_one>2000)   // se tempo che sta a livello logico 1 è maggiore di 2 ms,interrompo il ciclo e proseguo
                  {
                  //tempo1=0;
                  break;
                  }
            }

         buffer[next_in]=tempo_zero;      // memorizzo nel buffer il contatore tempo_zero
         next_in++;                  // incremento posizione del buffer

         buffer[next_in]=tempo_one;      // memorizzo nel buffer il contatore tempo_one
         next_in++;                  // incremento posizione del buffer

                                 // e ricomincio il ciclo
         }   

//for(n=0;n<=100;++n)
//   {
//   tempo0= buffer[n];
//
//   high0 = make8(tempo0,1);
//   low0 = make8(tempo0,0);
//   write_eeprom ((0x00 + (n*2)),high0);
//   delay_ms(5);
//   write_eeprom ((0x00 + (n*2)+1),low0);
//
//   tempo1= buffer[n+1];
//
//   high1 = make8(tempo1,1);
//   low1 = make8(tempo1,0);
//   write_eeprom ((0x02 + (n*2)),high1);
//   delay_ms(5);
//   write_eeprom ((0x02 + (n*2)+1),low1);   
//   }
//
}

/*******************************************
*
*               MAIN
*
********************************************/



void Main()
{

int8 letto;


      SET_TRIS_C(0b10011001);     //   impostazioni di ingresso/uscita port_C
     output_low(LEDREC);         //    abbasso tutte le uscite   
   output_low(LEDPLAY);      //
   output_low(LEDSTATO);      //   
   output_low(IRout);         //


      while (1)                     // ciclco infinito
        {
         delay_ms(500);            // lampeggio e controllo dei tasti ogni 500 millisecondi
            output_toggle(LEDSTATO);   
       
         if (input(REC)==1)            // se premuto tasto REC
            {
         while (input(REC)){};      // attendo che venga rilasciato
         output_high(LEDREC);      // accendo led registrazione
         //DELAY_MS(1000);
         RecIR();               // chiamo routine per la registrazione
         output_low(LEDREC);         // dopo aver registrato spengo il led
         }   

         if (input(PLAY)==1)         // se premuto tasto PLAY
            {
         while (input(play)){};      // attendo che venga rilasciato
         output_high(LEDPLAY);      // accendo led registrazione
         DELAY_MS(1000);            // ritardo di un secondo
            PlayIR();               // chiamo routine per la riproduzione
         output_low(LEDPLAY);      // dopo aver letto ed inviato il segnale spengo il led
         }

      if (input(ERASE)==1)         // se premuto ERASE
            {
         while (input(ERASE)){};      // aspetto che venga rilasciato il tasto
         Cancella();               // cancello buffer e memoria eeprom
         }

      }
}
ln_mark7930
Guest







help!!
PostPosted: Thu Mar 05, 2009 5:01 am     Reply with quote

Nobody want / can help me?
yerpa



Joined: 19 Feb 2004
Posts: 58
Location: Wisconsin

View user's profile Send private message Visit poster's website

PostPosted: Thu Mar 05, 2009 3:03 pm     Reply with quote

I remember using a microprocessor to read an IR remote control. The IR signal from most remote controllers is modulated at a fairly high rate, something like 48 KHz. There are modules available that combine the IR detector with a demodulator and produce a logic level output. If you use one of these you might be able to run a timer interupt at high enough speed to generate time stamps for the demodulated logic signals. You will have to modulate the IR output at the same rate as the original remote. There are a couple of different standard modulation frequencies out there.

Digi-Key lists seven different frequencies ranging from 36.0 KHz to 56.9 KHz. If you don't match frequencies between sender and receiver, it won't work.
ivan



Joined: 03 Apr 2008
Posts: 8
Location: Italy Rome

View user's profile Send private message

Re: help!!
PostPosted: Thu Mar 05, 2009 5:27 pm     Reply with quote

ln_mark7930 wrote:
Nobody want / can help me?

how i see in comment you should be italian I have done a "cloner"
I don't have code here but I used a mix of capture compare work perfect
if you contact me I say you about
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