View previous topic :: View next topic |
Author |
Message |
starfire151
Joined: 01 Apr 2007 Posts: 195
|
multiple ADC channel conversions with timer int |
Posted: Sat Dec 11, 2010 2:20 pm |
|
|
I searched the posts related to this but did not see anything specific to this question...
Is it possible to start a conversion on two ADC channels and then, a time delay later, read them out? For instance
from the background:
set_adc_channel(0);
set_adc_channel(1);
and then enable a timer interrupt which interrupts a sufficient time later:
from the timer interrupt service routine:
x = read_adc(0);
y = read_adc(1);
From what I've seen in the data sheet and what has been posted, most of the time the set_adc_channel() and read_adc() operations are done sequentially. Is there any way to get the channels to convert at the same time? |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sat Dec 11, 2010 2:35 pm |
|
|
It depends on the PIC.
Typically the answer is "no". You need to read the datasheet for the device you want to use very carefully.
For example: most PIC18's only have 1 sample/hold and 1 converter. However, the 18Fxx31 has 2 sample/holds and 1 converter.
This means triggering a sample can cause both sample/hold units to sample, then the converter performs it's work on S/H1 and then S/H2.
You get 2 samples at interrupt time (if you have it set that way - but there are more options), but they were arrived at sequentially.
Some of the higher end PIC's (like the 16bit/32bit PIC's) have more than one converter. So they could deliver more than one channel worth of values for a given sample trigger.
If you're using PIC16's or 18F's, most likely you can only do one conversion on one channel at a time.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
starfire151
Joined: 01 Apr 2007 Posts: 195
|
|
Posted: Sat Dec 11, 2010 3:11 pm |
|
|
Excellent. This gives me something to go with.
Thanks for the replies. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sat Dec 11, 2010 3:31 pm |
|
|
Right - but to reiterate,
Dual Sample/Hold -- SINGLE converter.
So that means triggering the A/D will cause both S/H's to initiate their sample... then they hold. This gives 2 channels "captured" in time.. Then the converter will being with S/H unit #1 to provide a conversion... then it will do number 2. (you can actually configure the unit to then auto-switch to another 2 channels and do another conversion set -- while the result FIFO can be set to Interrupt on 1, 2 or 4 results)...
Have fun --- searching the right PIC can sometimes be a little work - but worth it...
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Sat Dec 11, 2010 3:36 pm |
|
|
Quote: | Have fun --- searching the right PIC can sometimes be a little work - but worth it... |
Until you then discover that the perfect solution to your problem is a "future product" ... I think I have been there a few times !!
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 |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sat Dec 11, 2010 4:58 pm |
|
|
gpsmikey wrote: | Quote: | Have fun --- searching the right PIC can sometimes be a little work - but worth it... |
Until you then discover that the perfect solution to your problem is a "future product" ... I think I have been there a few times !!
|
I talked with my local Microchip rep and got PIC18F46J11 44qfp samples before they were available anywhere else... for prototyping, it was perfect.
Never hurts to ask "how much in the future" a PIC is.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|