Hey,
I'm trying to use the ADC to read the voltage of a force sensor I'm calibrating. The Force sensor outputs positive voltage for one direction and negative voltage for the other. I've setup my code to test single ended mode and differential mode, but I'm having issues using the differential mode. The output is very noisy. I attached an oscilloscope to observe the noise from the sensor.
I saw a consistent noise of ~20mV, but the output of the ADC is showing somewhere around ~150-200 mV of noise. The output is also really weird. The noise will only really sit on top of the expected value, it never goes below it. More on that below. Here is my code.
extern void ADCConfig_Diff(){
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
//
// For this example ADC0 is used with AIN0/1 on port E7/E6.
// The actual port and pins used may be different on your part, consult
// the data sheet for more information. GPIO port E needs to be enabled
// so these pins can be used.
// TODO: change this to whichever GPIO port you are using.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
//
// Select the analog ADC function for these pins.
// Consult the data sheet to see which functions are allocated per pin.
// TODO: change this to select the port/pin you are using.
//
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2);
//
// Enable sample sequence 3 with a processor signal trigger. Sequence 3
// will do a single sample when the processor sends a signal to start the
// conversion. Each ADC module has 4 programmable sequences, sequence 0
// to sequence 3. This example is arbitrarily using sequence 3.
//
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
//
// Configure step 0 on sequence 3. Sample channel 0 (ADC_CTL_CH0) in
// differential mode (ADC_CTL_D) and configure the interrupt flag
// (ADC_CTL_IE) to be set when the sample is done. Tell the ADC logic
// that this is the last conversion on sequence 3 (ADC_CTL_END). Sequence
// 3 has only one programmable step. Sequence 1 and 2 have 4 steps, and
// sequence 0 has 8 programmable steps. Since we are only doing a single
// conversion using sequence 3 we will only configure step 0. For more
// information on the ADC sequences and steps, refer to the datasheet.
//
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_D | ADC_CTL_CH0 |
ADC_CTL_IE | ADC_CTL_END);
//
// Since sample sequence 3 is now configured, it must be enabled.
//
ADCSequenceEnable(ADC0_BASE, 3);
//
// Clear the interrupt status flag. This is done to make sure the
// interrupt flag is cleared before we sample.
//
ADCIntClear(ADC0_BASE, 3);
}
Here is the curve. A multimeter showed an output from the force sensor to be 0.384 V. Ignore the legend, it is the unfiltered value.
A value of 0.384 should approximately return 2260, which there is an unmistakable dark line to show consistency, but then there is a lot of extra points above this. At an adc_val of 2350, this is roughly 150 mV above the value, but while watching the oscilloscope, there was never any noise near this range.
Also, here is the response of the same sensor at a similar voltage using the single-ended option.
This value shows so much more accurate results, that you can visually see the sensor resolution.
Any help would be appreciated. Thanks!