PDA

View Full Version : How to choose best oscillator frequency?



Johan
- 21st October 2007, 16:59
How do you guys pickup the best oscillator frequency for your application?
The higher the better ?

mat janssen
- 21st October 2007, 17:44
Not alway's true
If low power consumption is required then a low frequency is then good.
If you use the internal u(s)art, look then what baudrate you want to use, and with which xtal you can build it.
Also the frequency of the pwm depends on the xtal freq.

Johan
- 23rd October 2007, 05:48
Thanks Mat

Aside of those issues, is there really a " performance" differences by clocking the PIC higher ? Better processing speed ?

I am new to PIC, but I guess as it happens on PC , the higher the frequency, the better is the performance ( 3,2 Ghz vs. 1.6 Ghz )

BrianT
- 23rd October 2007, 15:12
The oscillator speed must be chosen to meet your overall design objectives. There is no point running at 20 MHz if you are driving slow devices with the PWM output. There, 4 MHz may be a better solution. Likewise if you need specific timing pulses from TMR0 or TMR1 then you must balance the timer bit length with the clock speed and the desired output rate. If you want longest battery life then slower clocks are better.

In general a faster clock lets you get through more code per unit time so faster is better but you must look at the other system requirements.

HTH
Brian

Jumper
- 23rd October 2007, 16:59
If you use a 18- pic with PLL then 10 is a good choice. Not that power hungry at 10 but with the possibility to kick in the "turbo" and go to 40 MHz with just a change in the config fuses.

/me

BigWumpus
- 23rd October 2007, 21:37
Aside of those issues, is there really a " performance" differences by clocking the PIC higher ? Better processing speed ?

I am new to PIC, but I guess as it happens on PC , the higher the frequency, the better is the performance ( 3,2 Ghz vs. 1.6 Ghz )


Wrong !

A 3000 MHz Sempron running on a bad motherboard (integrated graphics and/or SIS) is slower than a fine Centrino (Pentium III-fellow) with about 1600 MHz !


For the PICs:
You must look at your demands...
All the "normal" things can be done by 4MHz...
Very-Low-Power may use 32kHz RC,
CAN-Bus may require 16MHz or more,
USB requires 48MHz for the USB-part, the core runs slower.
Currently I have a projekt where I change from 4MHz to 16MHz by using the internal RC-oszillator, because I choose to interrupt the work 4000 times a second to monitor a serial signal... so, there is enough power...

4MHz up to 12MHz can be realized by cheap resonators instead of a quartz.

Johan
- 24th October 2007, 18:59
Hmmm....

Suppose I have 8 ADC running at 10 bit and then do some math with the values, then output it to 8 HPWM on a chip like 18f4431, total code around 8k byte, will 8mhz internal osc be sufficient, or will there be a lag somewhere ?

BrianT
- 26th October 2007, 00:45
ALL digital systems have delays and they are almost always variable depending where in the code loop the event you are looking for takes place.

Assume each ADC takes 50 uSec, 100 instructions of maths at 1 uS per instruction per channel, then 8 writes to the HPWM outputs each at 50 uSecs. Yes your mileage will vary but these values are in the ball park.

That makes a complete cycle of 8 inputs to 8 outputs about 400 uSecs for the ADC, 800 uSecs for the maths, plus a further 400 uSecs for the HPWM writes. 1600 uSecs - say 2 mSecs to be safe. If your code does nothing other than scan 8 inputs and write 8 HPWM outputs there will be up to about 2 mSecs delay from input to output.

You will have to decide if your application can live with that.

Cheers
Brian

Johan
- 26th October 2007, 09:33
Thanks Brian,

Yes , this is what I meant.

You said it will be about 2 ms delay from input to output, is it based on 8 Mhz oscillator ?

If I want to change the delay to 1 ms, is it as simple as to change the oscillator to 16 Mhz ?

Squibcakes
- 26th October 2007, 10:09
Wrong !

USB requires 48MHz for the USB-part, the core runs slower.


Hmm, I don't believe this statement is quite right either. Depending on your clock setup, you can have both the usb and core running at 48MHz.

Concidering you can drive the Osc inputs with a 4MHz xtal and pump it up to 48MHz thats value for money!!

I generally like using 20Mhz xtals because the body is small flat and rigid.

For non time critical (commercial) apps - I just use the internal RC osc.

When using Timers with interrupts etc- in general you can get longer delays when using a slower clock.

Squib