View previous topic :: View next topic |
Author |
Message |
pfo
Joined: 22 Feb 2004 Posts: 16 Location: vienna, austria.
|
Internal ADC sampling speed |
Posted: Sun Feb 22, 2004 12:19 pm |
|
|
i've tryed to use a external adc, but i'm now considering using the built-in adc of my PIC18F452. The datasheet states :
Quote: |
TACQ = TAMP + TC + TCOFF
Temperature coefficient is only required for temperatures > 25°C.
TACQ = 2 µs + TC + [(Temp – 25°C)(0.05 µs/°C)]
TC = -CHOLD (RIC + RSS + RS) ln(1/2048)
-120 pF (1 kΩ + 7 kΩ + 2.5 kΩ) ln(0.0004883)
-120 pF (10.5 kΩ) ln(0.0004883)
-1.26 µs (-7.6246)
9.61 µs
TACQ = 2 µs + 9.61 µs + [(50°C – 25°C)(0.05 µs/°C)]
11.61 µs + 1.25 µs
12.86 µs
|
then on the next pages is states that is requiers at least 12 T_ad times to get a reading into adc_l and adc_h registers.
i configured the oscilator to OSC_2, that means 5MHz(operating with 20MHz crystal) -> 0,2us Tad ?! (would that mean that it taks only 6us to get the reading?)
but the conversion seems to be right anyway.
but how do i calculate what it _realy_ taks(do i have to sum 12.86us and 12*T_ad ?) to read a number and asign it to a variable? what is the highest rachable sample reate with 2-3 channels beeing used?
i used timer1 to measure how much ticks of t1 it takes to get one reading on channel 0, the result was that when t1 is set to a resolution of 1.6us(T1_INTERNAL) 17 ticks, that means ~ 27uS. |
|
![](templates/subSilver/images/spacer.gif) |
Felix Althaus
Joined: 09 Sep 2003 Posts: 67 Location: Winterthur, Switzerland
|
|
Posted: Sun Feb 22, 2004 12:35 pm |
|
|
Hi
Tacq and Tad are different things!
Tacq is the acquisitioning time wich is needed that the internal hold-condensator surely can be charged to the input voltage at the PIC pin.
The minimum of this time can be calculated form the formula you show. But it can be longer.
Tad is the time it takes for the PIC to sample one bit. The whole 10bits take 12Tad.
For the PIC16Xxxx adc's the Tad must be somwhere between 2us and 6us. I don't know the values for the 18Fxxx but they should be in the datahseet. So you MUST select the conversion clock divider that the resulting Tad is within this range. There should be a table in the datasheet that shows when to select wich divider.
When you change the ad channel, you have to wait Tacq before you start the conversion.
Felix |
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Sun Feb 22, 2004 1:01 pm |
|
|
A good way to get around all this is to use the built in functions. If you have a capasitor across your analog inputs they are stable. With stable inputs you can simply take a sample after switching channles and throw it out then take your sample and switch to the next channle. 12Tad is usualy going to be enough time for Tacq to occure. For me this is better than using a delay_uS because it waste less time in the event an interupt occurs during the Tacq. |
|
![](templates/subSilver/images/spacer.gif) |
|