I'm trying to configure the ADC on ADUCM360 in order to read the voltage connected to a PT100 resistor. The input value range goes from about 2V to 3V. This is the code I'm using:
AdcGo(pADI_ADC1,ADCMDE_ADCMD_IDLE); // Place ADC1 in Idle mode
AdcMski(pADI_ADC1,ADCMSKI_RDY,1); // Enable ADC ready interrupt source
AdcFlt(pADI_ADC1,0,0,FLT_NORMAL|ADCFLT_NOTCH2|ADCFLT_CHOP); // ADC filter set for max update rate with chop on enabled
AdcRng(pADI_ADC1,ADCCON_ADCREF_AVDDREF,ADCMDE_PGA_G1,ADCCON_ADCCODE_UINT); // avdd reference selected, Gain of 1, truncate negative results to 0
// Turn off input buffers to ADC and external reference
AdcPin(pADI_ADC1,ADCCON_ADCCN_AGND,ADCCON_ADCCP_AIN1); // Select AIN1 as postive input and AGND as negative input
As you can see the reference selected is AVDD and the ADCCON_ADCCODE is set to UINT (AdcRng function) in order to perform as unipolar (Am I wrong?). I thought this would give me a range from 0 to AVDD and I could read the input data correctly. The thing is that it isn't working.
I'm retreiving the output like this:
fVolts = fVoltage;
fVolts = (1.2 / 268435456); // Internal reference, calculate lsb size in volts
fVoltage = (ulADC1Result * fVolts); // Calculate ADC result in volts
(I'm using this conversion inside ADC1_Int_Handler function for simplicity).
Any help will be really grateful.
I changed fVolts to fVolts = (3.3/368435456) and it seems that is working better. Then I change my question to: How can I set this conversion with the exact value of AVDD, as it may vary a little bit around 3.3V am I right?
Also, I'm getting an error on ADCSTA register 0x10 from time to time, this is meant to be triggered when there is an outrange error, but I don't know how can I fix it, any ideas?