Searching \ for 'Why doesn't 1+1=2?' 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/index.htm?key=why+doesnt+112
Search entire site for: 'Why doesn't 1+1=2?'.

Truncated match.
PICList Thread
'Why doesn't 1+1=2?'
2000\03\09@004335 by Dean Biddle

flavicon
picon face
Hi,

The timing of the code (infamed by Myke Predko?) at the end of this mail
simulates to the nearest µsecond using MPLAB.  However, when executed on a
P16F84 using a 4 MHz 3 pin resonator marked
[4.00 (M x], I loose about 1 second every 10 minutes.  Same occurs at
different supply voltages between 3.5 and 6V.

Presumably this is because of the +/-0.5% error (or greater) in the crystal
and my too frequent reliance on 1 microsecond being accurate?

If this magnitude of error is expected for this type of delay code, could
someone please point me to another technique (e.g. TMR0 + prescaler) with
accurate equations which allow accurate pre-calculation of the interval.  

I'm using RA5 hence can't use a 32k crystal for timing.  Is there any other
external timing techniques (sleep or not) for a P16F84?

Is the life of a microcomputer reduced if it is allowed to continuously loop
compared to a sleeping chip?

;
; Delay rountine for P16F84 using 4 MHz crystal.  Sum individual expressions
for total and add
; extra cycles where required
;
MOVLW   0X00?        
MOVWF   COUNT1        
MOVLW   0X00?        
MOVWF   COUNT2        
MOVLW   0X00?        
MOVWF   COUNT3        
MOVLW   0X00?        
MOVWF   COUNT4        
DECFSZ  COUNT4,F  ;2+(3*1)*(COUNT4-1)
GOTO    $-1        
DECFSZ  COUNT3,F  ;2+(3*255+3+2)*(COUNT3-1)
GOTO    $-3        
DECFSZ  COUNT2,F  ;2+(3*255*256+5*255+3+2+2)*(COUNT2-1)
GOTO    $-5        
DECFSZ  COUNT1,F  ;2+(3*255*256*256+5*255*256+7*255+3+2+2+2)*(COUNT1-1)
GOTO    $-7        

2000\03\09@021313 by Roland Andrag

flavicon
face
Dean, 1 second in 10 minutes = 1/600 = 0.16667 %...

I don't have an answer to your question as to how to fix it though...

Cheers
Roland


{Original Message removed}

2000\03\09@023039 by McMeikan, Andrew

flavicon
face
You will probably find that you are not accounting for the execution time of
the rest of your code, hence it runs slow.

I have run RTC code using the timer and a 3.568Mhz  xtal and got no drift
over many days.

unless your code is very simple/plain path then you need a regular interrupt
to keep track of time properly.

       cya,    Andrew...

> {Original Message removed}

2000\03\09@023418 by Jason Harper

picon face
> The timing of the code (infamed by Myke Predko?) at the end of this mail
> simulates to the nearest µsecond using MPLAB.  However, when executed on
a
> P16F84 using a 4 MHz 3 pin resonator marked
> [4.00 (M x], I loose about 1 second every 10 minutes.  Same occurs at
> different supply voltages between 3.5 and 6V.
>
> Presumably this is because of the +/-0.5% error (or greater) in the
crystal
> and my too frequent reliance on 1 microsecond being accurate?

Losing 1 second out of 10 minutes is an error of only 0.17%, which is well
within the accuracy rating of the typical ceramic resonator.  The obvious
solution would be to use a crystal, which is about 100 times more accurate
than a resonator.
       Jason Harper

2000\03\09@072327 by Andrew Kunz
flavicon
face
I have worked on several clocks (in set-top boxes).  A crystal with an
adjustable cap (to trim) is absolutely the only way to get what you want.  A
couple seconds max per month is easy then.

Andy

2000\03\09@073156 by Roland Andrag

flavicon
face
Andy, how do you trim it - i.e. what reference do you use to see when you
have the frequency accurate?

----- Original Message -----
From: Andrew Kunz <spam_OUTakunzTakeThisOuTspamTDIPOWER.COM>
To: <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU>
Sent: Thursday, March 09, 2000 2:21 PM
Subject: Re: Why doesn't 1+1=2?


> I have worked on several clocks (in set-top boxes).  A crystal with an
> adjustable cap (to trim) is absolutely the only way to get what you want.
A
> couple seconds max per month is easy then.
>
> Andy
>

2000\03\09@094432 by Andrew Kunz

flavicon
face
Trim with a frequency counter.  I good one will get you very precise resuts.

Andy

2000\03\09@112119 by Don Hyde

flavicon
face
1 second in 10 minutes = 1 second in 600 = .16% error, better than is to be
expected from a .5% precision timebase.  So your code is probably just fine.
If you want more accurate timing, you're going to have to start with a more
accurate timebase, such as a 20ppm crystal which should give more like .012
second error in 10 minutes.

Now, you must also understand that to get the 20ppm from your crystal, you
will have to, at least once, fiddle with the crystal loading caps and a
high-quality counter to adjust for the stray capacitance on your board.
Once you have found the right cap values, they will be pretty consistent for
a production run, but you still may need a tweaker on the crystal to get it
right on.

> {Original Message removed}

2000\03\09@132816 by Thomas McGahee

flavicon
face
If you do not have a high precision frequency counter, you can
still adjust the crystal quite accurately if you have another
time base that is very accurate and a decent oscilloscope.

Connect the output of the precision frequency source (such as
a can type 4.000000 MHz oscillator) and the OUTPUT of the
PIC oscillator to a pair of series connected 100k resistors.
Connect ground to the scope ground, and connect the scope probe
to the junction of the two resistors.

Trim the PIC XTAL until the observed waveform "settles down".
At that point both oscillators are at the same frequency
or locked to a multiple or submultiple of one another.

                   100k         100k
PIC OSC OUT >------/\/\/\---*---/\/\/\-------< REFERENCE FREQ.
                           |
                           +---------> TO SCOPE

Fr. Tom McGahee


{Original Message removed}

2000\03\09@192415 by John Mullan

picon face
I always thought  1 + 1 = 10 ????

(hehehe)

John

2000\03\09@194322 by Joe Dudas

picon face
Actually, its eleven (11)...

Sorry, takes a while for the brain to realize that's not funny
----- Original Message -----
From: "John Mullan" <jmullanspamKILLspamHOME.COM>
To: <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU>
Sent: Thursday, March 09, 2000 4:21 PM
Subject: Re: Why doesn't 1+1=2?


> I always thought  1 + 1 = 10 ????
>
> (hehehe)
>
> John

2000\03\10@014725 by Michael Wieser

flavicon
face
AFAIK the horizontal linefrequency of tv in PAL(15.625Hz) systems is based
on a second order  frequency-standards (I don`t remember exactly which
system, resolution was around 1*10-9Hz or better)

I don`t know how if this correct now for private tv-broadcasts, but the
public ones still stay on this standard.
it`s an easy task to build a PLL for 15625Hz-1MHz as a reference for your
counter, based on a secondary standard......

hth


>If you do not have a high precision frequency counter, you can
>still adjust the crystal quite accurately if you have another
>time base that is very accurate and a decent oscilloscope.



Michael Wieser
EraseMEm.k.wspam_OUTspamTakeThisOuTnextra.at

Service and Audiodesign

2000\03\10@044855 by Alan Pearce

face picon face
>AFAIK the horizontal linefrequency of tv in PAL(15.625Hz) systems is based
>on a second order  frequency-standards (I don`t remember exactly which
>system, resolution was around 1*10-9Hz or better)

As I understand it the TV stations use a Rubidium frequency standard for their
internal frequency reference. These are not quite as stable as a caesium
standard, but heaps better than an ovened crystal. They need this sort of
stability to get good colour sub carrier frequency stability as well as
maintaining the relationship between colour subcarrier and scan rates. I have
heard of people tapping into TV sets to get the colour subcarrier signal out to
use as a frequency standard for this reason. The only catch to doing this is it
must be receiving a suitable colour signal for the internal oscillator to lock
onto of course.

2000\03\10@071222 by Andrew Kunz

flavicon
face
When my first son turned 11 I have him two dollars - a dollar for each one.

Andy










Joe Dudas <joey6spamspam_OUTHOME.COM> on 03/09/2000 07:48:13 PM

Please respond to pic microcontroller discussion list <@spam@PICLISTKILLspamspamMITVMA.MIT.EDU>








To:      KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU

cc:      (bcc: Andrew Kunz/TDI_NOTES)



Subject: Re: Why doesn't 1+1=2?








Actually, its eleven (11)...

Sorry, takes a while for the brain to realize that's not funny
----- Original Message -----
From: "John Mullan" <RemoveMEjmullanTakeThisOuTspamHOME.COM>
To: <spamBeGonePICLISTspamBeGonespamMITVMA.MIT.EDU>
Sent: Thursday, March 09, 2000 4:21 PM
Subject: Re: Why doesn't 1+1=2?


> I always thought  1 + 1 = 10 ????
>
> (hehehe)
>
> John

2000\03\10@082255 by jkitchen

picon face
And Make sure the frequency counter is accurate!  Lots of them are not...

Andrew Kunz wrote:

> Trim with a frequency counter.  I good one will get you very precise resuts.
>
> Andy

2000\03\10@100645 by Jim Hartmann

flavicon
face
Instead of tweaking capacitors you could also try this-
204.210.50.240/techref/default.asp?from=/techref/&url=method/realtime.htm
Tweak the fraction constant : bigger = faster, about 5ppm per count in the
example.
:-Jim

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