Searching \ for '[PIC]: Doing modulated IR with 16F628 internal clo' 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/microchip/ios.htm?key=ir
Search entire site for: 'Doing modulated IR with 16F628 internal clo'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Doing modulated IR with 16F628 internal clo'
2003\03\12@185918 by Alex Kilpatrick

flavicon
face
I wanted to hopefully caution someone against making the same mistake I
made.  In the interest of reducing part count, I have been working on
using a 16F628 to do modulated (38 Khz) IR.  I wanted to have everything
on one chip, instead of having to use multiple chips.  I did the
modulation and bit-banging myself, for 1200 baud IR communication.  I
was using the internal oscillator of the 16F628.  Basically, I could get
it working fine, and then I would come back the next morning, and it
would be slightly off, missing a few bits on certain values, while
working fine on others.  I messed with this for two days, trying to
tweak things to make them work correctly.  It was very frustrating.
And then i though about the temperature variations, and the internal
clock.  Arggh!  I added a ceramic resonator, and everything worked
flawlessly.
I though that the internal clock would have been accurate enough for
something as coarse as 1200 baud serial, but apparently it is not.
I've attached the source code for the IR function below, in case anyone
is interested.  I am using the CCS compiler, and a 4 MHz clock.  The
16/4 loop makes a 38 KHz pulse.   Alex
void IRWrite(byte b)
{
   disable_interrupts(INT_EXT);
   #use fast_io(b)

    // start bit
     for(i=0;i<27;i++)
     {
        output_low(PIN_B2);
        delay_us(16);
        output_high(PIN_B2);
        delay_us(4);
     }
   // serials
   for(j=0; j<8;j++)
  {
      if(!shift_right(&b,1,0))
     {
        // output a modulated zero
        for(i=0;i<27;i++)
        {
           output_low(PIN_B2);
           delay_us(16);
           output_high(PIN_B2);
           delay_us(4);
        }
      }
     else // output a one
     {
        output_high(PIN_B2);
        delay_us(760);
      }
   }
   // stop bit
  output_high(PIN_B2);
  delay_us(760);
  #use standard_io(b)
  enable_interrupts(INT_EXT);
}

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu>

2003\03\12@213028 by David Duffy

flavicon
face
Alex wrote:
>  I wanted to hopefully caution someone against making the same mistake I
>made.  In the interest of reducing part count, I have been working on
>using a 16F628 to do modulated (38 Khz) IR.  I wanted to have everything
>on one chip, instead of having to use multiple chips.  I did the
>modulation and bit-banging myself, for 1200 baud IR communication.  I
>was using the internal oscillator of the 16F628.  Basically, I could get
>it working fine, and then I would come back the next morning, and it
>would be slightly off, missing a few bits on certain values, while
>working fine on others.  I messed with this for two days, trying to
>tweak things to make them work correctly.  It was very frustrating.
>And then i though about the temperature variations, and the internal
>clock.  Arggh!  I added a ceramic resonator, and everything worked
>flawlessly.

As a matter of interest, what range of temperature was this over?

>I though that the internal clock would have been accurate enough for
>something as coarse as 1200 baud serial, but apparently it is not.

Just a note on the baud rate. The accuracy required is not related to
the baud rate. 5% at 1200 baud is still the same as 5% at 115200
baud as it's still relative to the chosen baud rate.
David...

___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu>

2003\03\12@214734 by Alex Kilpatrick

flavicon
face
[snip about change in clock over temperature]
>
> As a matter of interest, what range of temperature was this over?
>
Not much.  Maybe 70 low to 85 high.  Austin, TX.  No real winter here,
plus I have a bunch of computers.  :-)

> >I though that the internal clock would have been accurate enough for
> >something as coarse as 1200 baud serial, but apparently it is not.
>
> Just a note on the baud rate. The accuracy required is not
> related to the baud rate. 5% at 1200 baud is still the same
> as 5% at 115200 baud as it's still relative to the chosen
> baud rate. David...
>
>
Hmm.  I guess you are right.  I was getting confused with the receiver.
If the receiver clock is off, then it should be able to handle 1200 baud
easier than 115200.

Alex

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu>

2003\03\13@023602 by so-8859-1?Q?Ing_Igor_Pokorn=FD?=

flavicon
face
Strange. I did just the same application (transmitter only] a couple weeks
ago without any problem. I calibrated the oscilator by myself (used 12C508
with a window), the  speed I use is 2400 baud with 1%...

Regards

Igor

{Original Message removed}

2003\03\13@025925 by hael Rigby-Jones

picon face
> -----Original Message-----
> From: Alex Kilpatrick [SMTP:.....AlexKKILLspamspam.....HCITRAINING.COM]
> Sent: Wednesday, March 12, 2003 11:57 PM
> To:   EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
> Subject:      [PIC]: Doing modulated IR with 16F628 internal clock
>
>
> I've attached the source code for the IR function below, in case anyone
> is interested.  I am using the CCS compiler, and a 4 MHz clock.  The
> 16/4 loop makes a 38 KHz pulse.
>
> Alex
>
Out of interest why didn't you use the CCP module to generate the 38KHz
carrier with zero CPU overhead?

Regards

Mike



=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================
Any questions about Bookham's E-Mail service should be directed to postmasterspamspam_OUTbookham.com.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@042914 by Alan B. Pearce

face picon face
>Hmm.  I guess you are right.  I was getting confused with
>the receiver. If the receiver clock is off, then it should
>be able to handle 1200 baud easier than 115200.

I suspect your real problem was not the 1200 baud drift, but the 38KHz
carrier drift going outside the IR receiver passband.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@055112 by David Duffy

flavicon
face
>[snip about change in clock over temperature]
> >
> > As a matter of interest, what range of temperature was this over?

Alex:
>Not much.  Maybe 70 low to 85 high.  Austin, TX.  No real winter here,
>plus I have a bunch of computers.  :-)

That should be fine. I have a design that used a 12C509 (now a 12C672)
and runs quite happily at 9600 baud with the internal RC oscillator.

{Quote hidden}

No, it still doesn't matter. The percentage error is no different with the
different baud rates no matter how you look at it. You can probably
tolerate a couple of percent at each end of the link and still be ok.
Maybe like Alan said, the modulation is not really 38KHz although you
can usually be a little off and only suffer reduced range as you start to
get out of the receiver's pass band. See if you can get a look at the IR
or demodulator output on the CRO to check your timing. Heating the
board with a hair drier to see if it wanders.
David...


___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@063744 by Wouter van Ooijen

face picon face
> I though that the internal clock would have been accurate enough for
> something as coarse as 1200 baud serial, but apparently it is not.

Where did you get the idea that asynch is 'coarse'? It requires a clock
that is accurate at least to a few %, preferrably better than 1%. And
this requirement is the same regardless of the baudrate.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@074851 by Wouter van Ooijen

face picon face
> I suspect your real problem was not the 1200 baud drift, but the 38KHz
> carrier drift going outside the IR receiver passband.

Not likely, a 5% shift will kill asynchronous communication, but the
common IR receivers that I know [
http://www.vishay.com/docs/82030/82030.pdf ] a 5% shift will reduce the
sensitivity to 60%, hence the effective distance to 77%.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@074900 by Wouter van Ooijen

face picon face
> Strange. I did just the same application (transmitter only] a
> couple weeks
> ago without any problem. I calibrated the oscilator by myself
> (used 12C508
> with a window), the  speed I use is 2400 baud with 1%...

I guess YMMV depending on the PIC type, revision, maybe even the
production lot, the temperature, Vcc variations, the phase of the moon
and whether you have properly waved a dead fish.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@095000 by Jason Neudorf

flavicon
face
I've had success with 19531bps masquerading as 19200bps.  1.7% worked well
for me.

Has anyone had good luck with receive of IrDA SIR?  What sort of transducer
is needed?

Jason Neudorf
{Original Message removed}

2003\03\13@102050 by Nigel Orr

flavicon
face
pic microcontroller discussion list <> wrote on Thursday, March 13, 2003
2:10 PM:

> I've had success with 19531bps masquerading as 19200bps.
> 1.7% worked well

A typical UART looks for the rising edge of the start bit, then samples the
signal a couple of times around where the centre of each bit should be.
For example, it could look at 25%, 50% and 75% of the way through each bit.
That helps to get rid of glitches.

However it means that by the end of the byte (about 10 bit slots later),
the receivers guess of when the bit starts and stops has to be within 25%
of a bit period, so each bit can slip by 2.5% of a bit period.  For the
next byte, the UART will re-synchronise on the next start bit, so errors
aren't accumulated.

In other words, for the hypothetical UART described above, the clocks at
the receiver and transmitter have to be in agreement within 2.5%, so each
one needs to be within 1.25% of the correct value to make comms reliable.
Different UARTs use different sampling schemes, and could even
resynchronise during the byte (do any do this?), but assuming the clocks
have to be accurate to less than 1% is a good place to start.

If both clocks are 30ppm crystals, their maximum combined error at room
temperature is 0.06%, so you can get away with a bit rate error of 1.7%.
Add a significant temperature difference between the crystals (some of what
we do here has > 150 deg C between them!) and your 19531 might not work any
more :-)

Nigel
--
Nigel Orr, Design Engineer                 @spam@nigelKILLspamspamaxoninstruments.co.uk
Axon Instruments Ltd., Wardes Road,Inverurie,Aberdeenshire,UK,AB51 3TT
              Tel:+44 1467 622332 Fax:+44 1467 625235
                  http://www.axoninstruments.co.uk

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@104934 by Alex Kilpatrick

flavicon
face
>
>
> > Strange. I did just the same application (transmitter only]
> a couple
> > weeks ago without any problem. I calibrated the oscilator by myself
> > (used 12C508
> > with a window), the  speed I use is 2400 baud with 1%...
>
> I guess YMMV depending on the PIC type, revision, maybe even
> the production lot, the temperature, Vcc variations, the
> phase of the moon and whether you have properly waved a dead fish.
>
Right.  And the problem is multiplied if you are doing PIC to PIC
communication, because the variations in clocks may add.

I do think the internal clock on the 16F628 is great for non-critical
timing applications, though.

Alex

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@105137 by Alex Kilpatrick

flavicon
face
> -----Original Message-----
> From: Wouter van Ooijen [KILLspamwouterKILLspamspamVOTI.NL]
> Sent: Thursday, March 13, 2003 6:48 AM
> To: RemoveMEPICLISTTakeThisOuTspamMITVMA.MIT.EDU
> Subject: Re: [PIC]: Doing modulated IR with 16F628 internal clock
>
>
> > I suspect your real problem was not the 1200 baud drift,
> but the 38KHz
> > carrier drift going outside the IR receiver passband.
>
> Not likely, a 5% shift will kill asynchronous communication,
> but the common IR receivers that I know [
> http://www.vishay.com/docs/82030/82030.pdf ] a > 5% shift will
> reduce the sensitivity to 60%, hence the effective distance to 77%.
>
Right.  I was checking the signal on the decoder, and all the bits were
there, it was just variations in the bit times messing up the receiver's
ability to interpret the serial stream.

Alex

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@105547 by Alex Kilpatrick

flavicon
face
> -----Original Message-----
> From: Michael Rigby-Jones [spamBeGoneMichael.Rigby-JonesspamBeGonespamBOOKHAM.COM]
> Sent: Thursday, March 13, 2003 1:57 AM
> To: TakeThisOuTPICLISTEraseMEspamspam_OUTMITVMA.MIT.EDU
> Subject: Re: [PIC]: Doing modulated IR with 16F628 internal clock
> >
> > I've attached the source code for the IR function below, in case
> > anyone is interested.  I am using the CCS compiler, and a 4
> MHz clock.  
> > The 16/4 loop makes a 38 KHz pulse.
> >
> > Alex
> >
> Out of interest why didn't you use the CCP module to generate
> the 38KHz carrier with zero CPU overhead?
>
Umm, I wanted to build character?  :-) I guess I will have to learn what
the CCP module is now.  I just never looked at it before, coming from
the 16F84 world.

Alex

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@105758 by Alex Kilpatrick

flavicon
face
{Quote hidden}

I did check the output of the decoder on a logic analyzer. All the bits
were there.  But I was getting glitches on the receiver.  (f -> e, 1 ->
8, etc.)  Here were the symptoms:

1)  Tweak the timing.  Everything works.  Get up the next morning,
nothing changed, but now I get glitches.
2)  Got glitches.  Didn't change code  Replaced the internal oscillator
with a ceramic resonator.  Everything works perfectly.

That certainly seems like a internal clock problem to me.

ALex

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@133714 by Jason Neudorf

flavicon
face
Neat.  I'll be sure to avoid using my Palm IIIxe at 150C.  :)

My purpose was debugging and troubleshooting a hard real-time device the
company is developing for a customer.  Just an extra trace to the ICSP
connector, and I can hook in an LED and see which fail-safe has kept the
device from smoking.  I was already updating a DAC at 19531, so bit-banging
the IR at that rate was no problem;  getting it exact would have caused no
end of troubles.

How hard would it be to bit-bang the receive, with absolutely minimal
hardware?

Jason Neudorf

{Original Message removed}

2003\03\13@135804 by Wouter van Ooijen

face picon face
> of a bit period, so each bit can slip by 2.5% of a bit

But you might also need to take into account that
- the uart might only sample the input at for instance 4 times the
baudrate, which might cause an additional error of 1/4 baud
- the electrical part of the communication might add timing errors

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@140419 by Alex Kilpatrick

flavicon
face
>
>
> > of a bit period, so each bit can slip by 2.5% of a bit
>
> But you might also need to take into account that
> - the uart might only sample the input at for instance 4
> times the baudrate, which might cause an additional error of 1/4 baud
> - the electrical part of the communication might add timing errors
>
> Wouter van Ooijen
>
I'm using the CCS compiler, which has a 'getc()' function.  I'm not
using the built-in UART, because I need to invert the signal.

The CCS docs seem to imply that each bit is only sampled once, but that
may be a simplification of the real process.


Alex

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@140832 by Stef

flavicon
face
Jason Neudorf wrote:

>Neat.  I'll be sure to avoid using my Palm IIIxe at 150C.  :)
>
>My purpose was debugging and troubleshooting a hard real-time device the
>company is developing for a customer.  Just an extra trace to the ICSP
>connector, and I can hook in an LED and see which fail-safe has kept the
>device from smoking.  I was already updating a DAC at 19531, so bit-banging
>the IR at that rate was no problem;  getting it exact would have caused no
>end of troubles.
>
>How hard would it be to bit-bang the receive, with absolutely minimal
>hardware?
>
You could use the PWM output for this.
Stef Mientki

>
>Jason Neudorf
>
>{Original Message removed}

2003\03\13@145105 by Igor Pokorny

flavicon
face
I appologize not reading all messages if I repeat someone notice.
I would like to stress that Vishay's receivers don't like any discontinuity
of a modulation.... The only way how to obtain a reliable communication is
to modulate a transmitter by a way the time of modulation pulses multiply by
a constant gives you a bps.... Using PWM is a little confusing by my meaning
but useable.

Igor



{Original Message removed}

2003\03\13@145508 by Jason Neudorf
flavicon
face
> >How hard would it be to bit-bang the receive, with absolutely minimal
> >hardware?
> >
> You could use the PWM output for this.
> Stef Mientki

Um, you're thinking sending TV-remote style IR.  It has a ~38kHz (or so)
carrier frequency.   I was asking about receiving the SIR IrDA stuff that
you might get from a PalmOS device or laptop.

Anyone have any ideas? Can I hook up a 1 or 2 component detector, with
filtering in software, or do I need to use some expensive transducer?

Jason Neudorf

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\13@183200 by Stef

flavicon
face
Jason Neudorf wrote:

>>>How hard would it be to bit-bang the receive, with absolutely minimal
>>>hardware?
>>>
>>>
>>>
>>You could use the PWM output for this.
>>Stef Mientki
>>
>>
>
>Um, you're thinking sending TV-remote style IR.  It has a ~38kHz (or so)
>carrier frequency.   I was asking about receiving the SIR IrDA stuff that
>you might get from a PalmOS device or laptop.
>
>Anyone have any ideas? Can I hook up a 1 or 2 component detector, with
>filtering in software, or do I need to use some expensive transducer?
>
TSOP1138 around $2 expensive  ?
Did you take a look into the functional circuit of such a device ?
If you've seen that, I think the $2 isn't even worth of even trying to
find a solution of your own.
Just a $0.02 opinion ;-)

Stef Mientki

>
>Jason Neudorf
>
>--
>http://www.piclist.com hint: PICList Posts must start with ONE topic:
>[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads
>
>
>

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\14@112242 by Jason Neudorf

flavicon
face
{Quote hidden}

Not useful for SIR IrDa  (I sense blank looks).  The infrared sent by a
laptop or PDA is not modulated by 38kHz; rather, it consists of single, high
intensity pulses, LSB first, one per bit.  A "0" bit consists of a pulse,
and a "1" bit has no pulses.  It's very much like RS-232, but with short
high-intensity pulses instead of continous high values.

A quick look at digikey mentions TI's TIR1000PSR, at $CDN 4.11 quantity 1.
This thing requires an external clock, but STILL doesn't mention what you
receive with.  It looks like it's functionality could be emulated in
software.

The question is what sort of IR detector can be used, and what sort of noise
rejection to put into software/hardware.

(the TSOP1138 does look useful for TV-remote type stuff).

Jason

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\03\14@114254 by Alan B. Pearce

face picon face
>The question is what sort of IR detector can be used, and
>what sort of noise rejection to put into software/hardware.

Well I would expect any IrDA detector to be usable for what you want.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

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