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

[SOLVED] Internal Oscillator vs External Crystal

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



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

[SOLVED] Internal Oscillator vs External Crystal
PostPosted: Sat Aug 10, 2013 6:58 am     Reply with quote

Not really a ccs question, i apologize in advance.
Pic micro-controller (18LF46k22) is to be used in harsh climate of canada.
Used outdoors,lots of serial communication involved, temp ranges from -30 C to +30 C.

Is internal oscillator suitable?
Can 64 Mhz external crystal be used?


Last edited by haxan7 on Tue Aug 13, 2013 2:00 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19475

View user's profile Send private message

PostPosted: Sat Aug 10, 2013 7:37 am     Reply with quote

No, you can't use a 64MHz external crystal.
You can use an external 64MHz _oscillator_, or a 16Mhz crystal, and the PLL. Look at table 27-6 in the data sheet. The highest speed the HS oscillator (the internal oscillator to use a crystal), is rated to run, is 20MHz.

Now whether you can use the internal oscillator, is something only you can really answer. The point is that 'serial' covers a lot of ground. You could (for instance), go to a synchronous 'serial' link, which then means that the data clock rate is controlled by the master device, so then the frequency of the clock in the slave wouldn't matter. However assuming you are talking about async serial as used over RS232/485 links, then probably not. Generally the total timing error aimed for, should be kept below perhaps 3% maximum. Now there will be some timing error in the baud rate selection itself (depending what this is), so (for instance), you want 115200bps, then the BRG from a 64Mhz clock will give a -0.79% error. - generally high baud rates will have the biggest errors. Now the internal oscillator is specified to give +/-2% accuracy over 0 to 70C, so would 'just' stay inside this area. However if your temperature range goes out to -40C to +125C, with the extended version chips, then the basic accuracy degrades to +/-5%.

It is possible to use the internal oscillator over the extended temperature range by correcting for this. The drift is quite predictable with temperature, and you can tweak the oscillator using the OSCTUNE register. So what you do is have the chip gently adjust the internal oscillator, to correct for the temperature. It means extra code, with you reading the temperature every few minutes, and then just making the adjustment, but it is possible to get the internal oscillator to give better than +/-1% this way.

You can also do this using the serial itself.
I've in the past had systems send 0xAA repeatedly for a few bytes every few minutes, after a long 'break'. The code in the slave device looks for the break, and then times the interval between the edges, and tweaks it's clock then to correct for the error in this timing. Has the advantage that the chip corrects both for it's timing errors, and the ones in the other device as well...

So if by 'serial communication', you mean async serial, then you have the choices of either working out a way of adjusting the clock, or using a more stable clock source.

Best Wishes
temtronic



Joined: 01 Jul 2010
Posts: 9211
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Aug 10, 2013 8:37 am     Reply with quote

hmm..."harsh climate of canada", eh ? LOL, Yeah, I'm Canadian.

Ok, if you haven't already done so, buy a small freezer and build 'an environmental test chamber'.You might need some extra insulation outside to get down to -30*C though.
I did that back in '85 to test my remote energy control systems BEFORE doing real field tests. Paid for itself the first week! Made it real easy to test from the comfort of my basement, in July, easy to test all sorts of combinations of hardware and software.

ps.I've always used real crystals,far more stabil and reliable than RC circuits.
hth
jay
haxan7



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

PostPosted: Sat Aug 10, 2013 8:53 am     Reply with quote

Thanks for the detailed reply, i really appreciate it.

Ttelmah wrote:
So if by 'serial communication', you mean async serials

I meant async rs232 serial.

I don't have any experience with pll. How does 16 Mhz upscaled to 64 Mhz with pll compares to actual 64 Mhz clock?
If i can make do with 16 Mhz, should i pll to 64 Mhz anyway just to get interrupts processed faster and serial communication perform better.

I don't want to get into calibration of internal oscillator just yet. Will a crystal oscillator be stable enough for the job.
haxan7



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

PostPosted: Sat Aug 10, 2013 9:11 am     Reply with quote

temtronic wrote:
Ok, if you haven't already done so, buy a small freezer and build 'an environmental test chamber'.


Thanks will take that under advisement.

Quote:
ps.I've always used real crystals,far more stabil and reliable than RC circuits


I think i am going to go with crystals myself.
haxan7



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

PostPosted: Mon Aug 12, 2013 8:22 am     Reply with quote

Common help a brother out
Ttelmah



Joined: 11 Mar 2010
Posts: 19475

View user's profile Send private message

PostPosted: Mon Aug 12, 2013 8:40 am     Reply with quote

With what?.
haxan7



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

PostPosted: Mon Aug 12, 2013 9:06 am     Reply with quote

Ttelmah wrote:
With what?.

I don't have any experience with pll. How does 16 Mhz upscaled to 64 Mhz with pll compares to actual 64 Mhz clock?
If i can make do with 16 Mhz, should i pll to 64 Mhz anyway just to get interrupts processed faster and serial communication perform better
Ttelmah



Joined: 11 Mar 2010
Posts: 19475

View user's profile Send private message

PostPosted: Mon Aug 12, 2013 9:15 am     Reply with quote

Seriously, one second searching would find the answer to that. It is basic electronics, which is not what this forum is meant to be about....

Downsides slightly slower start up.
Plus sides, less RFI. Less power needed for the oscillator.
PLL's are used in everything today. Your PC clock will be PLL based, Your cellphone, TV etc..
The highest available fundamental crystal is somewhere just over 60Mhz. Think about chips like the DsPIC's running at 120MHz+. Not even possible without the PLL.
haxan7



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

PostPosted: Mon Aug 12, 2013 9:25 am     Reply with quote

Ttelmah wrote:
Seriously, one second searching would find the answer to that. It is basic electronics, which is not what this forum is meant to be about....

Downsides slightly slower start up.
Plus sides, less RFI. Less power needed for the oscillator.
PLL's are used in everything today. Your PC clock will be PLL based, Your cellphone, TV etc..
The highest available fundamental crystal is somewhere just over 60Mhz. Think about chips like the DsPIC's running at 120MHz+. Not even possible without the PLL.


Thanks, i did try searching and looking into datasheet but i needed answer from someone with experience.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Aug 12, 2013 1:29 pm     Reply with quote

haxan7 wrote:


Thanks, i did try searching and looking into datasheet but i needed answer from someone with experience.


Take a look at section 2.0 in the data sheet "Oscillator module" especially section 2.6 on the PLL - they explain how it works. I have not used the 46k22, but it is basically the same as the 26k22 with more pins.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
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