Topics

Arduino 1.8.11 - Teensyduino 1.50 -> changes needed to the ADC code

Frederik
 

I just installed the latest version of Arduino: 1.8.11 and Teensyduino 1.50.

When compiling the latest version ML_v409 I got the the following error:

ML_v409:1287: error: 'class ADC' has no member named 'setSamplingSpeed'
   adc->setSamplingSpeed(ADC_SAMPLING_SPEED::LOW_SPEED);       // Sampling speed, ADC_VERY_LOW_SPEED, ADC_LOW_SPEED, ADC_MED_SPEED, ADC_HIGH_SPEED or ADC_VERY_HIGH_SPEED

Apparently something changed in the ADC.h library so we need to change the following code:
  // Set up the two separate ADCs for synchronous read at 12 bit resolution and lowest possible measurement speed (minimal noise)
  adc->setSamplingSpeed(ADC_SAMPLING_SPEED::LOW_SPEED);       // Sampling speed, ADC_VERY_LOW_SPEED, ADC_LOW_SPEED, ADC_MED_SPEED, ADC_HIGH_SPEED or ADC_VERY_HIGH_SPEED
  adc->setSamplingSpeed(ADC_SAMPLING_SPEED::LOW_SPEED, ADC_1);
  adc->setConversionSpeed(ADC_CONVERSION_SPEED::LOW_SPEED);   // Conversion speed
  adc->setConversionSpeed(ADC_CONVERSION_SPEED::LOW_SPEED, ADC_1);
  adc->setResolution(12);                        // AD resolution, 12 bits
  adc->setResolution(12, ADC_1);
  adc->setAveraging(16);                         // Averaging by taking multiple samples.
  adc->setAveraging(16, ADC_1);                  // 16 samples takes approx 80us per measurement and is just about
to this:
  // Set up the two separate ADCs for synchronous read at 12 bit resolution and lowest possible measurement speed (minimal noise)
  adc->adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::LOW_SPEED);       // Sampling speed, ADC_VERY_LOW_SPEED, ADC_LOW_SPEED, ADC_MED_SPEED, ADC_HIGH_SPEED or ADC_VERY_HIGH_SPEED
  adc->adc1->setSamplingSpeed(ADC_SAMPLING_SPEED::LOW_SPEED);
  adc->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::LOW_SPEED);   // Conversion speed
  adc->adc1->setConversionSpeed(ADC_CONVERSION_SPEED::LOW_SPEED);
  adc->adc0->setResolution(12);                        // AD resolution, 12 bits
  adc->adc1->setResolution(12);
  adc->adc0->setAveraging(16);                         // Averaging by taking multiple samples.
  adc->adc1->setAveraging(16);                  // 16 samples takes approx 80us per measurement and is just about
Then recompile again and you are good to go!

73 de ON5IA
Frederik

Al
 

Nice work Frederik. 
I had a go at the code to add another Transceiver type. 
Hopefully Loftur can incorporate the changes in a new revision. 
Maybe a good time to start a Github thread. 

Al