CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

multiple ADC channel conversions with timer int

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
starfire151



Joined: 01 Apr 2007
Posts: 195

View user's profile Send private message

multiple ADC channel conversions with timer int
PostPosted: Sat Dec 11, 2010 2:20 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 2:35 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 3:08 pm     Reply with quote

The 18F4431-series PICs have dual-channel simultaneous sampling ADCs:
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010288

This thread has sample code for it:
http://www.ccsinfo.com/forum/viewtopic.php?t=42256
starfire151



Joined: 01 Apr 2007
Posts: 195

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 3:11 pm     Reply with quote

Excellent. This gives me something to go with.

Thanks for the replies.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 3:31 pm     Reply with quote

PCM programmer wrote:
The 18F4431-series PICs have dual-channel simultaneous sampling ADCs:
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010288



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

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 3:36 pm     Reply with quote

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 !! Very Happy

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

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 4:58 pm     Reply with quote

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 !! Very Happy


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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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