Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[moved] How to find sampling rate of ADC in PIC?

Status
Not open for further replies.

Jiadong Yao

Member level 1
Member level 1
Joined
Mar 19, 2014
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
278
Reference thread:

https://www.edaboard.com/threads/175050/

FOSC is the oscillator frequency, as "OSC" means oscillator. So, it's 16 MHz. And TOSC is the oscillator period, which is 0.0625 us.

But, for the program execution, the clock source is divided by 4 to generate 4 phases, which are named as Q1, Q2, Q3 and Q4. And instructions are executed in 4 phases, so TCY = 4 * TOSC. So, each instruction is executed in 0.25 us, except the ones that require 2 TCY.

But the formula for the calculation of the TAD in the datasheet uses TOSC, not TCY.

Hi. I know it has been a long time. But I DO have a question about the Fosc. Indeed, this is the frequency of oscillator. Could you tell me, Fosc is internal frequency or external frequency?
I have this confusion because once a while, Fosc and FRC appear at the same time. The Frc is the "clock derived from A/D RC oscillator".
Many thanks
 
Last edited by a moderator:

Fosc is means what kind of oscillator we using in the microcontroller. It may be like internal or external oscillator.

Sampling rate and conversion time mentioned in the microcontroller datasheet
 
Fosc is means what kind of oscillator we using in the microcontroller. It may be like internal or external oscillator.

Sampling rate and conversion time mentioned in the microcontroller datasheet


Ok!! the first paragraph is really helpful!!! Fosc is just general symbol of oscillator of which the frequency we are using.

But how to find the sampling rate? i don't know where it is....
by the way, do you think there is a mistake when the datasheet mentions the Tad. It says" The RC source has a typical TAD time of 4 ms." But i think it should be 4micro seconds. what do you think?
 

A/D conversion takes 12 TAD and TAD must be no less than 1.6 us. If you choose internal RC for the A/D clock source, TAD varies between 2 and 6 us. There is also acquisition time needed before the conversion begins.

If your Fosc (external crystal frequency) is 20 MHz then Tosc will be 1 / Fosc = 0.05 us

According to your device

See datasheet page 186, it mentiones if internal A/D module RC oscillator is used then TAD varies between 2 us to 6 us.

Lets use a external clock of 20 MHz

So, out Fosc = 20 MHz and Tosc = 1 / Fosc

Tosc = 1 / 20 MHz = 0.05 us

page 186 section 17.2 mentiones

For correct A/D conversions, the A/D conversion clock
(TAD ) must be selected to ensure a minimum TAD time
of 1.6 μs.

So, minimum TAD is 1.6 us.

You have 6 option for getting the right TAD viz

• 2 T OSC
• 4 T OSC
• 8 T OSC
• 16 T OSC
• 32 T OSC
• 64 T OSC

2 * Tosc = 2 * 0.05 us = 0.1 us is less than 1.6 us

4 Tosc = 0.2 us < 1.6 us
8 Tosc = 0.4 us < 1.6 us
16 Tosc = 0.8 us still less
32 Tosc = 1.6 us ok
64 Tosc = 3.2 us


You can use 32 Tosc for TAD

10 bit A/D conversion requires 12 TAD.

So 12 TAD = 1.6 us * 12 = 19.2 us



Acquisition Time: When an specific channel is selected the
voltage from that input channel is stored in an internal holding capacitor.
It takes some time for the capacitor to get fully charged and become equal to
the applied voltage. This time is called acquisition time. The PIC18F4520′s
ADC provides a programmable acquisition time, so you can setup the acquisition
time. Once acquisition time is over the input channel is disconnected from the
source and the conversion begin. The acquisition times depends on several factor
like the source impedance, Vdd of the system and temperature. A safe
value is 2.45uS, so acquisition time must be set to any value
more than this.


After the A/D conversion is aborted, a 2 T AD wait
is required before the next acquisition is started. After
this 2 T AD wait, acquisition on the selected channel is
automatically started.

So, 2 TAD or 2 * 32 Tosc is required between conversions.

= 3.2 uS TACQ is required.

So, you can use 23 Tosc for assigning values to ADCS2-ADCS0

ADCS2-ADCS0 will be 010 from Table 17-1

So, TACQ of 3.2 uS + 12 TAD (19.2 uS) = 22.4 uS is required per Conversion.

1 / 22.4 uS = 44642.85714285714 Hz

So, sampling frequency is 44.643 KHz.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top