"ADC1 error: Wrong pin error." using both ADCs (T3.6) in continuous differential mode
Hi,
I try to run both ADCs with startContinuousDifferential on a Teensy 3.6:
The description of startContinuousDifferential says that you have to use A10, A11/ A12, A13 like I did in my example. Anyway I get the error "ADC1 error: Wrong pin error.". When I am using ADC_0 only, I get no error and everything works fine.
I know that the latter questions should be part of separate threads but I didn't want to spam this forum, because this is my first post. So I hope I did nothing wrong. Many thanks in advance for your help
Hi,
I try to run both ADCs with startContinuousDifferential on a Teensy 3.6:
Code:
#include <ADC.h>
#include <RingBufferDMA.h>
ADC *adc = new ADC();
const int BUFFER_SIZE = 128;
DMAMEM static volatile int16_t __attribute__((aligned(BUFFER_SIZE + 0))) buffer1[BUFFER_SIZE];
RingBufferDMA *dmaBuffer1 = new RingBufferDMA(buffer1, BUFFER_SIZE, ADC_0);
DMAMEM static volatile int16_t __attribute__((aligned(BUFFER_SIZE + 0))) buffer2[BUFFER_SIZE];
RingBufferDMA *dmaBuffer2 = new RingBufferDMA(buffer2, BUFFER_SIZE, ADC_0);
void setup() {
Serial.begin(9600);
/**
* Comments from https://github.com/pedvide/ADC/blob/master/ADC.cpp
**/
pinMode(A10, INPUT); // Diff Channel 0 Positive
pinMode(A11, INPUT); // Diff Channel 0 Negative
adc->setAveraging(0, ADC_0);
adc->setResolution(11, ADC_0); // For differential measurements: 9, 11, 13 or 16 bits.
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_HIGH_SPEED, ADC_0);
adc->setConversionSpeed(ADC_CONVERSION_SPEED::VERY_HIGH_SPEED, ADC_0);
adc->enableDMA(ADC_0);
adc->startContinuousDifferential(A10, A11, ADC_0); // A10 and A11 are allowed
dmaBuffer1->start(&dmaBuffer1_isr);
pinMode(A12, INPUT); // Diff Channel 0 Positive
pinMode(A13, INPUT); // Diff Channel 0 Negative
adc->setAveraging(0, ADC_1);
adc->setResolution(11, ADC_1); // For differential measurements: 9, 11, 13 or 16 bits.
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_HIGH_SPEED, ADC_1);
adc->setConversionSpeed(ADC_CONVERSION_SPEED::VERY_HIGH_SPEED, ADC_1);
adc->enableDMA(ADC_1);
adc->startContinuousDifferential(A12, A13, ADC_1); // A12 and A13 are allowed
dmaBuffer2->start(&dmaBuffer2_isr);
}
void dmaBuffer1_isr() {
dmaBuffer1->dmaChannel->clearInterrupt();
}
void dmaBuffer2_isr() {
dmaBuffer2->dmaChannel->clearInterrupt();
}
void loop() {
if (Serial.available()) {
char c = Serial.read();
if(c=='p') {
adc->printError();
}
}
}
The description of startContinuousDifferential says that you have to use A10, A11/ A12, A13 like I did in my example. Anyway I get the error "ADC1 error: Wrong pin error.". When I am using ADC_0 only, I get no error and everything works fine.
- Is it not possible to use both ADCs in continuous differential mode?
- Is Bill Greimans 3 Msps approach (Teensy36AdcDmaLogger.ino )the fastest solution up to now?
- Is it possible to get 3Msps or more with pedvides ADC library using both ADCs in continuous differential mode with RingBufferDMA?
- Do I really need an high pass filter to dampen ambient EM noise, chiefly fluorescent light ballasts (i.e. 50 kHz) and power-line noise (i.e. 60 Hz) if I want to sample a 200khz signal?
I know that the latter questions should be part of separate threads but I didn't want to spam this forum, because this is my first post. So I hope I did nothing wrong. Many thanks in advance for your help