This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi guys,
I want to read in 2 ADC channels and afterwards calculating the difference between them.
My actual status is, I read in 1 ADC channel with an ADC interrupt which is started by a timer interrupt (every 5s) and now I want to update my project on a second ADC input.
Do I have to configure a second interrupt or could I use the differential mode when i configuring the ADC, for the first time?
Thanks,
Chris
Hi Dennis,
thank you for your fast answer.
But when I configure a second input channel how could I read out the information of the both seperated inputs from the ADC?
For one input channel I use this, but I don't know how to go on with 2 inputs.
wert=ADC14MEM0;
//write ADC value to variable wert
void ADCConfig(void) { ADC14CTL0 = ADC14SHT0_2 | ADC14SHP | ADC14ON; // Sampling time, S&H=16, ADC14 on ADC14CTL1 = ADC14RES_2; // Use sampling timer, 12-bit conversion results ADC14MCTL0 |= ADC14INCH_2 | ADC14DIF; } //GPIO Config P5SEL1 |= BIT3 | BIT2; // Configure P5.3/2 (A2/3) for ADC P5SEL0 |= BIT3 | BIT2;
Your configuration looks OK to me. Can you show the rest of the code? Keep in mind that the ADC result is binary unsigned, means it has an offset of 8192 (at 14 bits).
Dennis
You can not leave one channel unconnected. Floating inputs pick up any crap from the surrounding. So when measuring differential and have one input unconnected, you will definitely get a wrong result. You can tie it to GND (Vref-) or VCC (Vref+) instead.
When both inputs are the same you have 8192 as result. When the negative input is higher than the positive, your output decreases down to a minimum of 0. If the positive input is higher than the negative one, your output increases up to a maximum of 16383. This is for full 14 bits of resolution.
If you use 12 bit conversion resolution, what you do by setting ADC14RES_2,
ADC14CTL1 = ADC14RES_2; // Use sampling timer, 12-bit conversion results
your maximum value is 4095 and your midscale is 2048. So your result of nearly 2000 looks OK if your bridge is in balance.
Dennis
This is just a point of view. If you subtract 2048 from each result, you have -2048 for negative full-scale and +2047 for positive full-scale and in single-ended mode your result is 0 to 4095 (in 12 bit mode).
**Attention** This is a public forum