S32K144 ADC Accuracy Problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K144 ADC Accuracy Problem

Jump to solution
2,608 Views
ldj979
Contributor III

Dear Team,

 

I am having an accuracy problem reading the voltage value using the adc of the s32k144, so I have a question.

I used an op amp on the front to read a voltage of around 240.31mV.

Two points were measured with a multimeter.

1. When I measured pin 1 of the opamp side, I read 240.31mV voltage.

2. When I measured ADC0 13 on pin 45 of s32k144 MCU, I read 240.31mV voltage.

I read the ADC value using S32DS SDK, but the value is incorrect.

I am attaching a code and picture of setup.

What's wrong?

#############################################################

/* Including necessary module. Cpu.h contains other modules needed for compiling.*/
#include "Cpu.h"

volatile int exit_code = 0;

/* User includes (#include below this line is not maintained by Processor Expert) */
#include "stdint.h"

#define ADC_INSTANCE 0UL
#define ADC_CHN 13U
#define ADC_VREFH 5.0f
#define ADC_VREFL 0.0f

int main(void)
{
/* Write your local variable definition here */

uint16_t adcRawValue;
uint16_t adcMax;
float adcValue = 0.0f;

adcMax = (uint16_t) (1 << 12);

 

/* Write your code here */
/* For example: for(;;) { } */

CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);


CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);


PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);


DEV_ASSERT(PackV_ADC_ConvConfig0.channel == ADC_CHN);

ADC_DRV_ConfigConverter(ADC_INSTANCE, &PackV_ADC_ConvConfig0);
ADC_DRV_AutoCalibration(ADC_INSTANCE);

while(1)
{

/* Configure ADC channel and software trigger a conversion */
ADC_DRV_ConfigChan(ADC_INSTANCE, 0U, &PackV_ADC_ChnConfig0);
/* Wait for the conversion to be done */
ADC_DRV_WaitConvDone(ADC_INSTANCE);

/* Store the channel result into a local variable */
ADC_DRV_GetChanResult(ADC_INSTANCE, 0U, &adcRawValue);

/* Process the result to get the value in volts */
adcValue = ((float) adcRawValue / adcMax) * (ADC_VREFH - ADC_VREFL);


OSIF_TimeDelay(1000);

}

/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

 

######################################################################

 

error print

 

problem1.PNG

problem2.PNG

problem3.PNG

   

Regards,

DJ LEE

0 Kudos
1 Solution
2,532 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Whether RC filter is needed depends on whether there are glitches in the signal to be sampled.
In addition, please tell me whether the result of ADC sampling on-board POT R13 is accurate.
VREFH is stable. Did you measure the voltage and ensure it was 5V?

View solution in original post

0 Kudos
6 Replies
2,606 Views
ldj979
Contributor III

The schematic diagram of the front part is also attached.

0 Kudos
2,581 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi ldj979, Please check the voltage of VREFH. Make sure the value match the #define ADC_VREFH 5.0f. I did not find any obvious errors in your configuration. Have you try to measure another voltage signal? (RAD<5kΩ) Is the ADC conversion result still inaccurate?

Table 40. 12-bit ADC operating conditions.pngAnalog source resistance match.png

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
2,542 Views
ldj979
Contributor III

Also, VREFH is stable.

0 Kudos
2,544 Views
ldj979
Contributor III

Dear Robin,

 

Is RC filter necessary in front of the ADC pin of the s32k144?

 

Regards,

DJ LEE

0 Kudos
2,533 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Whether RC filter is needed depends on whether there are glitches in the signal to be sampled.
In addition, please tell me whether the result of ADC sampling on-board POT R13 is accurate.
VREFH is stable. Did you measure the voltage and ensure it was 5V?

0 Kudos
2,178 Views
ldj979
Contributor III

I solved it by attaching a pull-up resistor on the front end. Thank you for answer

0 Kudos