HELLO all
I am trying to read a differential signal using ADC0 of teensy 3.2 (pin10+,pin11-), but unfortunately i hav'nt get the right signal, I have used a sine wave with 1KHz as an input, I have compiled the following code:
can anyone help please?
thanks in advance.
I am trying to read a differential signal using ADC0 of teensy 3.2 (pin10+,pin11-), but unfortunately i hav'nt get the right signal, I have used a sine wave with 1KHz as an input, I have compiled the following code:
HTML:
#include <ADC.h>
ADC *adc = new ADC(); // adc object
float Sensor_voltage0;
float max_value0;
int Gain=1;
void setup() {
pinMode(A10, INPUT); //Diff Channel 0 Positive ADC0
pinMode(A11, INPUT); //Diff Channel 0 Negative
Serial.begin(9600);
adc->setReference(ADC_REFERENCE::REF_1V2, ADC_0);
//should be 1.2V because of PGA using
//teensy 3.1 and 3.2 have an internal 1.2v reference
//ADC1 used to read signals higher than 1.2 less than or equal 3.3
///// ADC0 ////
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::HIGH_SPEED); // change the sampling speed
//ADC_SAMPLING_SPEED::VERY_LOW_SPEED is the lowest possible sampling speed (+24 ADCK). (ADCK is the ADC clock speed, see below).
//ADC_SAMPLING_SPEED::LOW_SPEED adds +16 ADCK.
//ADC_SAMPLING_SPEED::MED_SPEED adds +10 ADCK.
//ADC_SAMPLING_SPEED::HIGH_SPEED adds +6 ADCK.
//ADC_SAMPLING_SPEED::VERY_HIGH_SPEED is the highest possible sampling speed (0 ADCK added).
// adc->enablePGA(Gain, ADC_0); // gain can be 1,2,4,8,16,32,64
// Use only for signals lower than 1.2 V and only in differential mode
adc->setConversionSpeed(ADC_CONVERSION_SPEED::VERY_HIGH_SPEED); // change the conversion speed
delay(500);
}
void loop() {
// put your main code here, to run repeatedly:
max_value0= adc->getMaxValue(ADC_0);
Sensor_voltage0= (adc->analogReadDifferential(A10, A11, ADC_0))*1.2/max_value0;
Serial.print("Sensor_voltage0=");
Serial.println(Sensor_voltage0);
// analogWrite(A14, (int)adc->analogReadDifferential(A10, A11, ADC_0));
}
can anyone help please?
thanks in advance.