|
|
View previous topic :: View next topic |
Author |
Message |
smiles
Joined: 20 Feb 2008 Posts: 33
|
ADC Time Question ? |
Posted: Mon Apr 14, 2008 2:38 am |
|
|
Here is the code that I see from other
Code: | #include <18F2550.h>
#device adc=8
#use delay(clock=12000000)
...
(adc_2550.h)
...
set_adc_channel(0);
delay_ms(10); // time for waiting have to be large enough
value=read_adc(adc_start_and_read);
//disable_interrupts(GLOBAL);
lcd_display(1,1,value);
...
(main.c) |
I want to ask do we need delay_ms(10) ?
Thanks !!! |
|
|
Ttelmah Guest
|
|
Posted: Mon Apr 14, 2008 3:10 am |
|
|
You don't.
You need something under 10 _micro_ seconds.
Read the data sheet. The 'key' is that the internal ADC on the PIC, actually starts with a capacitor inside the chip. It is the voltage on this, which is 'read' by the ADC. The capacitor is disconnected from the external world, when the reading is actually 'done'. When you select an ADC channel, it connects the external pin to this capacitor, _which must then be allowed to charge to the voltage before a reading can be done_. The time needed, depends on the size of the capacitor (in the data sheet), the impedance of your source, the internal resistances in the chip, and how close the voltage needs to get. MicroChip recommend a maximum source impedance of 2.5KR (for your particular ADC), and with this, the time needed to get within half a bit value of the actual incoming voltage, is 6.4uSec. Most older chips need a little longer (10uSec typically).
Section 21.1 in the data sheet.
They specify this as:
"After the analog input channel is selected (changed), the channel must be sampled for at least the minimum acquisition time, before starting a conversion".
This is also the time that you must wait _between_ successive readings, since the capacitor is disconnected during a reading.
Some people are rather 'over generous' in the time they allow!...
Best Wishes |
|
|
smiles
Joined: 20 Feb 2008 Posts: 33
|
|
Posted: Tue Apr 15, 2008 5:31 am |
|
|
That clearly !!!
Thanks so much |
|
|
|
|
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
|