|
Post by slobodan123 on Dec 15, 2016 14:24:51 GMT
Hi all,
I would like to configure the prescaler on ShieldBuddy from Arduino IDE. On Arduino Nano i could do with ADCSRA and ADPS0, ADPS1 and ADPS2. How can I do it for ShieldBuddy?
This is for Arduino Nano:
ADCSRA &= ~(bit (ADPS0) | bit (ADPS1) | bit (ADPS2)); // clear prescaler bits
//---------------------------------------------------------------
// uncomment to set the Prescaler
//---------------------------------------------------------------
ADCSRA |= bit (ADPS0); // 2 - 592.593 [kSamples/sec]
// ADCSRA |= bit (ADPS1); // 4 - 296.296 [kSamples/sec]
// ADCSRA |= bit (ADPS0) | bit (ADPS1); // 8 - 148.148 [kSamples/sec]
// ADCSRA |= bit (ADPS2); // 16 - 74.074 [kSamples/sec]
// ADCSRA |= bit (ADPS0) | bit (ADPS2); // 32 - 37.037 [kSamples/sec]
// ADCSRA |= bit (ADPS1) | bit (ADPS2); // 64 - 18.519 [kSamples/sec]
// ADCSRA |= bit (ADPS0) | bit (ADPS1) | bit (ADPS2); // 128 - 9.259 [kSamples/sec]
Thank you for your help.
|
|
|
Post by mjb on Dec 15, 2016 18:39:07 GMT
Not sure what you mean! Are you trying to increase the sampling rate?
|
|
|
Post by slobodan123 on Dec 15, 2016 23:18:11 GMT
Hi mjb,
Yes, that's right. On the Arduino Nano I can play with different ADPS settings to change the resolution of the sampling (2, 4, 8, 16... bits) which increase or decrease the sampling frequency. If I diminish the resolution, the sampling frequency increase and vice versa. Is it possible to do something similar with ShieldBuddy in Arduino IDE?
|
|
|
Post by mjb on Dec 16, 2016 8:39:55 GMT
The default resolution for ADC conversion results is 10 bits, like on an ordinary Arduino. On the ShieldBuddy you can set 8-bit or 12-bit conversions if required, using the analogReadResolution () function.
/* Set default VADC resolution 10 bits */ analogReadResolution (10u);
To set 12-bits of resolution,:
analogReadResolution (12u);
To set 8-bits:
analogReadResolution (8u);
The theorectical minimum conversion time is about 0.9us using the VADC when it is set up to make a series of conversions of a range of channels. In the ShieldBuddy, the overhead of setting up for single spot conversions means that the effective conversion time is around 1.6us. There is a delta-sigma ADC on the TC275 as well which has a much shorter conversion time but this is not currently supported in the Arduino language. You can access it using the underlying iLLD libraries though.
|
|
|
Post by slobodan123 on Dec 16, 2016 14:56:18 GMT
Thank you mjb, It's working like a charm. What is curious aboutShieldBuddy is that when I put lower than 8 bit resolution (4 or 2 bits), the speed sampling is getting slower. Is that normal? With 8bit resolution I get around 610kS/s which is great!
|
|
|
Post by mjb on Dec 16, 2016 15:09:54 GMT
Only 8, 10 and 12 bits are allowed. If you enter 2 bits, you will really be getting 10bits as this is the default!
|
|
|
Post by slobodan123 on Dec 16, 2016 15:15:12 GMT
Thank you for the explanation.
|
|
|
Post by crazydoc on Apr 21, 2021 14:15:32 GMT
Hello,
Are there any news concerning delta-sigma ADC concerning Arduino IDE. I need to read one analog signals as fast as possible.
Thanks!
|
|