• 0

ADC sampling rate WiFire board


Question

Hi,

 

I have a ChipKit Wi-Fire board and using MPIDE 0150 (2015-03-18 build). One reason I picked this board was because the MCU has an ADC which can support sampling rates up to 500 ksps (for my project I would need around 200 ksps, 8 bit resolution). When I do a simple test and capture the time (micros()) before an after the analog read, I end up with a time difference of 2469 us, which means a meager ADC sampling rate of 405 sps. Why is it so slow? How can I achieve rates up to 200 ksps with MPIDE and the built in libraries? I found an article for the Arduino board, where someone has boosted up the sampling rate by going around the analog read

library:

 

http://www.microsmart.co.za/technical/2014/03/01/advanced-arduino-adc/

 

Would I have to do something similar in my case? Has anyone done this for the ChipKit boards and could share some code? I would assume there must be more people than myself who has the need for a fast ADC. The code I wrote to test the analog read speed is as follows:

int sensorPin = A12;    
int sensorValue = 0;  
int start_time;
int end_time;

void setup() {
  Serial.begin(9600);  
}

void loop() {
  start_time = micros();
  sensorValue = analogRead(sensorPin);  
  end_time = micros();
  Serial.println(end_time-start_time, DEC);  
  while(1);                 
}
Edited by Josh
Added Tags
Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi c64,

 

I know the pre-production engineering silicon that comes on the Wi-Fire board had some issues including the ADC not being able to perform at the specified rates (see Microchip's errata and datasheet clarification). However, you should still definitely not be getting that slow of rate; I've contacted our chipKIT support about this and he should get back to me early next week.

 

Thank you for your patience.

 

Thanks,

JColvin

Link to post
Share on other sites
  • 0

Hi JColvin,

 

Thanks for being on the case, I appreciate it. I read the errata earlier today, and it struck me that I can't expect higher rates than 125 ksps (or thereabout). But I guess this is for a 10 bit resolution? Do you happen to know what the expected rate is for an 8 bit resolution? I may have to go for an external ADC with an SPI channel if 125 ksps is the max. And then I read that the SPI channel itself has some pre-production problems haha. But I guess the SPI clock of 27 MHz ought to be enough to get a data throughput of 1.6 Mbps. I should probably just test it with a logic analyzer. Also, do you happen to know if there are any planned release dates for chips that solve the ADC shortcomings?

 

Thanks!

Link to post
Share on other sites
  • 0

Hi c64,

 

I personally don't know what the rate would be for 8-bit or how one would somehow adjust the internal ADC to only do 8-bits. The SPI clock should be fast enough to get that data rate though.

 

As for the updated chip, it looks Microchip made the chip in production (as opposed to pre-production) earlier this April and the featured list and datasheet seem to list that at least 1 ADC can get up to the 500 ksps.  I don't know the details on a corresponding Wi-Fire board on the Digilent side though.

 

Thanks,

JColvin

Link to post
Share on other sites
  • 0

I got a response from our chipKIT guy, he said the ADC on that particular chip is pipelined and so will only achieve the rated data output rate when streaming.  MPIDE is currently set up for a single conversion and a lot of time is spent in code priming the pipeline. They are working on getting this more streamlined though.

 

Thanks,

JColvin

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now