Searching \ for 'IR to SERIAL Interface' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/io/irs.htm?key=ir
Search entire site for: 'IR to SERIAL Interface'.

Truncated match.
PICList Thread
'IR to SERIAL Interface'
1999\11\05@231958 by Jeremy Cowgar

flavicon
face
part 0 728 bytes
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META content='"MSHTML 4.72.3110.7"' name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>Hello,<BR><BR>I remember seeing on the web a project that connected a IR
reciever to a =<BR>PIC chip, and then sent the information to a computer system
for =<BR>recording via the serial port... Can anyone point me to this project? I
=<BR>have searched for the last hour trying to find it with no
luck.<BR><BR>Thanks!<BR><BR>Jeremy - <A
href="spam_OUTKB8LFATakeThisOuTspamqsl.net">.....KB8LFAKILLspamspam@spam@qsl.net</A><BR></DIV></BODY></HTML>

</x-html>

1999\11\06@015851 by J Nagy

flavicon
face
>     Hello,
>
>I remember seeing on the web a project that connected a IR  reciever to a =
>PIC chip, and then sent the information to a computer system  for =
>recording via the serial port... Can anyone point me to this project? I  =
>have searched for the last hour trying to find it with no  luck.
>
>Thanks!
>
>Jeremy - KB8LFAspamKILLspamqsl.net

Jeremy:
       We sell a preprogrammed '508 (the ELM622) that converts Sony IR to
ASCII at 9600 baud. The data sheet shows a typical circuit that may be
helpful:

http://www.elmelectronics.com/Products/Connect/Connect.htm#ELM622


       Jim Nagy
       Elm Electronics
 ICs for Experimenters
http://www.elmelectronics.com/

1999\11\06@025414 by W. Sierke

picon face
There are a number of projects on the web, you shouldn't have too much
trouble finding them.

You might be thinking of the Universal Infrared Receiver (UIR) at:

http://www.geocities.com/SiliconValley/Sector/3863/uir/index.html

Regards,

Wayne

{Original Message removed}

1999\11\06@071743 by Jose Souto

flavicon
face
part 0 38848 bytes
x-html> Hi Jeremy

We did that for Sony and the code for 16F84@4MHz written with CC5XFree
follows. see if u can figure it :-)
//=============cut--here=================================
/*
 * IR reception
 * 05/Sep/1999 JLS & CAE
 * jls@certi.ufsc.br
 * cae@certi.ufsc.br
 * CC5xFree v3.0E (www.bknd.com)
 */

/*
  Sony Data format: 12 bits

  Bit zero:

  400
  +--+   +...
  |  |   |
  +  +---+
      800

  Bit one:

  400
  +--+      +...
  |  |      |
  +  +------+
       1400

  Frame:
                400    400
  --+          +--+   +--+      +--+
    |        &nbs p; |  |   |  |      |  |
    +---2600---+  +---+  +------+  +...
                    800     1400

  Decoding algorithm:
  - Detect 2600us pulse,
  - measure next high pulse as P1 (400us)
  - measure next low  pulse as P2 (800/1400us)
  - store min(P1)
  - store max(P2)
  After all measurements:
  - calculate mean = (max-min)/2 + min
  - For all (P1,P2) measured:
    . Add P1+P2=P3
    . If P3< mean => bit is zero
    . If P3>=mean => bit is one

  Measures with Timer0 & Prescaler:16
    2600us = 162
    1400us = 87
     800us = 50
     400us = 25

     400+800  = 25+50 = 75
     400+1400 = 25+87 = 112
     mean ~= (112-75)/2+75 = 18+75 = 93
*/

#define         _16f84_
#include        <16f84.h>

#ifdef _12C508_
        bit     _TxOUT          @ GP0;
        bit     RxD_pin         @ GP1;
        bit     IR_input        @ GP2;
#else
        #define RP0              STATUS.5
        #pragma update_RP 0 &nbs p; /* OFF */
        #define DEF_TRISA        0
        #define DEF_TRISB        6
        bit     Rele            @ PORTA.1;

        bit     IR_input        @ PORTB.1;
        bit     RxD_pin         @ PORTB.2;
        bit     _TxOUT          @ PORTB.3;
        bit     LED             @ PORTB.4;
#endif

unsigned char size,x,y,med,min,max,rxBuf;

unsigned char r[4];
unsigned char buff[32];

void TxSerial (unsigned char txBuf);

/*----------------------------------------------------------------------- ---*/
void TxEnter (void) {
/*---------------------------------------------------------------------- ----*/
        TxSerial(0xD);
        TxSerial(0xA);
}

/*----------------------------------------------------------------------- ---*/
void TxHexAscii (unsigned char in) {
/*---------------------------------------------------------------------- ----*/
        unsigned char Hex;

        Hex = swap(in);  &nb sp;              ; // upper nibble
        Hex &= 0x0F;
        if (Hex<10) Hex += 0x30;
        else Hex += 0x37;
        TxSerial(Hex);
        Hex = in & 0x0F;
        if (Hex<0x0A) Hex += 0x30;
        else Hex += 0x37;
        TxSerial(Hex);
}

/*----------------------------------------------------------------------- ---*/
void Delay_uSeg (unsigned char timeout) {
/*---------------------------------------------------------------------- ----*/
        // delay = 3*timeout + 7uS (including call and return)

        while (1) {
                 timeout--;
                 if (timeout==0) {
                         nop();
                         nop();
                         return;
                 }
        }
}

/*----------------------------------------------------------------------- ---*/
void TxSerial (unsigned char txBuf) {
/*---------------------------------------------------------------------- ----*/

/*
 ;----------------------------------------------------------------- ----------*
 ; Transmit 1 start bit Lo, 8 data bits and 1 stop bit Hi at 9600 bps
 ; No Parity
 ; Byte time = 1.040 mS
 ; Bit  time = 104 uS (0.16% erro w/4.00 Mhz Internal RC)
 ; Input : W = byte to be transmitted
 ; Output: byte transmitted by serial pin
 ;----------------------------------------------------------------- ----------*
*/

    char idx;

        while (1)
        {
                 Carry = 0;           &nbs p;          // start bit
                 for (idx=10; idx; idx--)        // 3us
                 {
                         _TxOUT = Carry;         // 4us
                         Delay_uSeg(28);         // 91us (28*3+7)
                         Carry  = 1;          &nbs p;  // 1us
                         txBuf  = rr(txBuf);     // 1us
                         nop();            &n bsp;     // 1us
                 }             & nbsp;            &nb sp;    // 3us
                 return;
        }
}

/*----------------------------------------------------------------------- ---*/
void RxSerial (void) {
/*---------------------------------------------------------------------- ----*/

/*
 ;----------------------------------------------------------------- ----------*
 ; Receives 1 start bit Lo, 8 data bits and 1 stop bit Hi at 9600 bps
 ; No Parity
 ; Byte time = 1.040 mS
 ; Bit  time = 104 uS (0.16% erro w/4.00 Mhz Internal RC)
 ;
 ; False start bit check
 ;
 ; Start bit hunting timeout = 4*1.283ms
 ;
 ; Input  : none
 ; Output : Carry = 1 => success
 ;          rxBuf = input byte
 ;          Carry = 0 => error (timeout or stop bit=0)
 ;----------------------------------------------------------------- ----------*
*/
        char idx;

        rxBuf = 4;   &n bsp;            &nbs p;             // 5.135 ms timeout
        idx   = 0;

        while (1)
        {
                 while (RxD_pin)            ;      // input "high"
                 {
                         if ((-- idx)==0)
                         {
                          &n bsp;      if ((-- rxBuf)==0)
                          &n bsp;      {
                          &n bsp;            &nbs p; Carry = 0;
                          &n bsp;            &nbs p; return;
                          &n bsp;      }
                         }
                 }

            & nbsp;   Delay_uSeg(14);            ;      // 1/2 bit delay (14*3+7)
                 if (RxD_pin)
                         continue;             ;   // false start bit detection

            & nbsp;   rxBuf = 0x80;           & nbsp;       // 8 bits counter and reception buffer
                 nop();
                 nop();            &n bsp;             // timming adjustment

            & nbsp;   do
                 {
                         Delay_uSeg(30);         // (30*3+7)us
                         Carry = RxD_pin;        // bit read
                         rxBuf = rr(rxBuf);      // store and count
                 }
                 while (Carry==0);
                 Delay_uSeg(30);            ;      // 1 bit delay
                 nop();            &n bsp;             // timming adjustment
                 Carry = RxD_pin;          &nbs p;     // stop bit read
                 return;            & nbsp;            // 100 us availiable
        }
}
 

/*----------------------------------------------------------------------- ---*/
void main (void) {
/*---------------------------------------------------------------------- ----*/

#ifdef _12C508_
//      OSCCAL  = W;   &nbs p;                           &n bsp;     // OscCal Value - OTP part
        OSCCAL  = 0xB0; &nb sp;              ;             & nbsp;    // OscCal Value - Windowed part
        GPIO    = 0x00;
        TRIS    = 0x08;            & nbsp;            &nb sp;       // GP3 input
        OPTION  = 0b11000011;&nb sp;              ;             // Prescaler Timer0 1:16
#else
        INTCON  = 0;                &n bsp;            &nbs p;       // no interrupts
        PCLATH  = 0;                &n bsp;            &nbs p;       // bank 0
        PORTA   = 0;
        PORTB   = 0;
        RP0     = 1;            &nbs p;                        // RAM bank 1
        TRISA   = DEF_TRISA;
        TRISB   = DEF_TRISB;
        OPTION  = 0b11000011;&nb sp;              ;             // Prescaler Timer0 1:16
        RP0     = 0;            &nbs p;                        // RAM bank 0
#endif

        while (1)
        {
                 /* set vars to start */

            & nbsp;   FSR  = buff;          &nb sp;              ;    // pointer to buffer
                 x    = 12;         & nbsp;            &nb sp;       // only 12 bits
                 size = 0;             ;             & nbsp;     // word size in bits
                 min  = 255;          &nbs p;                   // min period
                 max  = 0;                         &n bsp;      // max period

            & nbsp;   /* start bit management */

            & nbsp;   while (IR_input==1);                     // wait for 0
                 /* 2600us start bit */
                 while (IR_input==0);                     // wait for 1

            & nbsp;   TMR0 = 0;             ;             & nbsp;     // start counter
                 do
                 {
                         /* measure high pulse */

            & nbsp;           INDF = 0;             ;           // period: default to zero
                         while (TMR0==0);          &nbs p;     // wait TMR0 advance
                         while (IR_input==1)          & nbsp;  // wait for 0
                         {
                          &n bsp;      if (TMR0==0)            // timer overflow (4096us) ?
                          &n bsp;            &nbs p; goto frame_end; // yes, exit
                         }
                         INDF = TMR0;           &n bsp;        // store period
                         TMR0 = 0;             ;           // start counter
                         med = INDF;           &nb sp;         // save high period
                         FSR++;            &n bsp;             // bump pointer
                         INDF = 0;             ;           // period: default to zero
                         size++;            & nbsp;            // inc bit counter

            & nbsp;           /* measure low pulse */

            & nbsp;           while (TMR0==0);          &nbs p;     // wait TMR0 advance
                         while (IR_input==0);             // wait for 1
                         INDF = TMR0;           &n bsp;        // store period
                         TMR0 = 0;             ;           // start counter
                         med += INDF;           &n bsp;        // total period
                         if (med>=max) max = med;        // find max
                         if (med<min)  min = med;        // find min
                         FSR++;            &n bsp;             // bump pointer
                         size++;            & nbsp;            // inc period counter
                         x--;            &nbs p;                // dec max bits
                 }
                 while (x);
frame_end:
                 LED = 1;
                 med  = max - min;
                 med /= 2;
                 med += min;

            & nbsp;   r[0] = 0;
                 r[1] = 0;
                 r[2] = 0;
                 r[3] = 0;

            & nbsp;   FSR  = buff;
                 FSR += size;
                 x = size/2;
                 do
                 {
                         Carry = 0;
                         r[3] = rl(r[3]);
                         r[2] = rl(r[2]);
                         r[1] = rl(r[1]);
                         r[0] = rl(r[0]);
                         FSR--;
                         max = INDF;
                         FSR--;
                         max += INDF;
                         if (max>=med) r[3]++;
                 } while (--x);

            & nbsp;   /* now r[0],r[1],r[2], r[3] has the frame */
                 /* Tx the periods and the encoded word */

            & nbsp;   TxHexAscii(size);
                 TxSerial(0x20);
                 TxHexAscii(med);
                 TxEnter();

            & nbsp;   for(x=0;x<size; x++)
                 {
                         TxHexAscii(buff[x]);
                         TxSerial(0x20);
                 }
                 TxEnter();

            & nbsp;   TxHexAscii(r[0]);
                 TxHexAscii(r[1]);
                 TxHexAscii(r[2]);
                 TxHexAscii(r[3]);

            & nbsp;   TxEnter();
                 LED = 0;
        }
}
 
 

1999\11\06@073651 by - KITS EDUCACIONAIS NACIONAIS

flavicon
face
Jose Souto wrote:
>
> Hi Jeremy
>
> We did that for Sony and the code for 16F84@4MHz written with CC5XFree
> follows. see if u can figure it :-)
> //=============cut--here=================================
> /*
>  * IR reception
>  * 05/Sep/1999 JLS & CAE
>  * .....jlsKILLspamspam.....certi.ufsc.br
>  * EraseMEcaespam_OUTspamTakeThisOuTcerti.ufsc.br
>  * CC5xFree v3.0E (http://www.bknd.com)
>  */
>
> /*

Please, e-mail private!

1999\11\06@083337 by Jose Souto

flavicon
face
Sorry

WF AUTOMACAO - KITS EDUCACIONAIS NACIONAIS wrote:

{Quote hidden}

1999\11\06@113958 by Tom Messenger

flavicon
face
Jose Souto,

I really enjoyed reading your "IR to SERIAL Interface" posting.  What I
liked was the excellent, clear description of the algorithm you used.  It
is often very time consuming to read through someones code and try to
figure out the algorithm; your concise explanation made it clear to me.

In general, my tastes very much prefer postings of algoritms rather than
code.  Any idiot can write code (me for example). The real problem is what
to write - ie., the algorithm.

Thanks!

Tom Messenger

1999\11\06@123510 by Mark Willis

flavicon
face
I'll agree here, the summary was nice!  Best though to either post
private or sometimes better, upload the code to a web page & post a URL
so other curious people can take a look at your code  (CC5XFree looks
pretty fair <G>)  The real killer size-wise in your post was that the
post was in HTML, the code itself isn't huge, all those HTML tags devour
space like it was going out of style though <G>

 Mark

Tom Messenger wrote:
{Quote hidden}

--
I do small package shipping for small businesses, world-wide.

1999\11\06@145227 by Nick Taylor

picon face
CC5XFree does look pretty good.  I cut and pasted Joe's code, cleaned
up the long line wraps, downloadedCC5XFree, installed it, and then
assembled it so that I could look at the assembler source ... and it
all took less than 30 minutes!  Thanks Jose!

- Nick -

Mark Willis wrote:
{Quote hidden}

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...