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.

LAUNCHXL-F28379D: ADC Reading incorrect values

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: BOOSTXL-DRV8305EVM

Tool/software:

Good afternoon, I'm working on implementing the ADC module into my project but it is currently reading incorrect values. It works well with non changing voltages, but once a triangle wave is applied to the pin with the BOOSTXL-DRV8305EVM motor driver sense pins it will only read the m

#include "adc.h"
#include "adc_priv.h"

#include "..\other\adc.h"
#include "..\other\hw_ints.h"
#include "..\other\device.h"
//#include "C:\ti\C2000Ware_5_05_00_00\device_support\f2837xd\headers\include\F2837xD_adc.h"

COIL_FEEDBACK_TYPE Coil_Feedback;
U16 Array[1024];
U16 i;

void ConfigureAdc(void)
{
    EALLOW;
    //
    // Interrupts that are used in this example are re-mapped to ISR functions
    // found within this file.
    //
    Interrupt_register(INT_ADCA1, &adcA1ISR);

    //
    // Set up the ADC and the ePWM and initialize the SOC
    //
    InitAdc(ADCA_BASE);
    // InitAdc(ADCB_BASE);
    // InitAdc(ADCC_BASE);
    InitAdcSoc();

    EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
    EPWM_setADCTriggerEventPrescale(EPWM1_BASE, EPWM_SOC_A, 1);
    Interrupt_enable(INT_ADCA1);
    EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
    EDIS;
}

void InitAdc(uint32_t adcBase)
{
    //
    // Set ADCDLK divider to /4
    //
    ADC_setPrescaler(adcBase, ADC_CLK_DIV_4_0);

    //
    // Set resolution and signal mode (see #defines above) and load
    // corresponding trims.
    //
#if(EX_ADC_RESOLUTION == 12)
    ADC_setMode(adcBase, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
#elif(EX_ADC_RESOLUTION == 16)
    ADC_setMode(adcBase, ADC_RESOLUTION_16BIT, ADC_MODE_DIFFERENTIAL);
#endif

    //
    // Set pulse positions to late
    //
    ADC_setInterruptPulseMode(adcBase, ADC_PULSE_END_OF_CONV);

    //
    // Power up the ADCs and then delay for 1 ms
    //
    ADC_enableConverter(adcBase);

    //
    // Delay for 1ms to allow ADC time to power up
    //
    DEVICE_DELAY_US(1000);
}

//
// Function to configure SOCs on ADCA and ADCB to be triggered by ePWM1.
//
void InitAdcSoc(void)
{
    //
    // Select the channels to convert and the configure the ePWM trigger 
    //
    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,
                 ADC_CH_ADCIN14, ADC_SAMPLING_WINDOW);      // ADCIN14
    // ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM2_SOCA,
    //              ADC_CH_ADCIN3, ADC_SAMPLING_WINDOW);       // ADCINC3
    // ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM2_SOCA,
    //              ADC_CH_ADCIN3, ADC_SAMPLING_WINDOW);       // ADCINA3
    // ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM2_SOCA,
    //              ADC_CH_ADCIN2, ADC_SAMPLING_WINDOW);       // ADCINC2
    // ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM2_SOCA,
    //              ADC_CH_ADCIN2, ADC_SAMPLING_WINDOW);       // ADCINB2

    ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
    ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
    ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
}

__interrupt void adcA1ISR(void)
{

    Coil_Feedback.V_Sen_A_Raw = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
    // Coil_Feedback.V_Sen_A_Raw = AdcaResultRegs.ADCRESULT0
    if (i > 1023)
    {
        i = 0;
    }
    Array[i++] = Coil_Feedback.V_Sen_A_Raw;
    // Coil_Feedback.V_Sen_B_Raw = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER0);
    // Coil_Feedback.V_Sen_Pvdd_Raw = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER1);
    // Coil_Feedback.I_Sen_A_Raw = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER1);
    // Coil_Feedback.I_Sen_B_Raw = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER0);

    // Coil_Feedback.V_Sen_A = (U16)((F32)V_SEN_GAIN * Coil_Feedback.V_Sen_A_Raw);
    // Coil_Feedback.V_Sen_B = (U16)((F32)V_SEN_GAIN * Coil_Feedback.V_Sen_B_Raw);
    // Coil_Feedback.V_Sen_Pvdd = (U16)((F32)V_SEN_GAIN * Coil_Feedback.V_Sen_Pvdd_Raw);
    
    //Coil_Feedback.Measured_Current = I_SEN_GAIN * ((F32)Coil_Feedback.I_Sen_A_Raw - Coil_Feedback.I_Sen_B_Raw);
    //
    // Clear the interrupt flag
    //
    ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);

    //
    // Check if overflow has occurred
    //
    if(true == ADC_getInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1))
    {
        ADC_clearInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1);
        ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
    }

    //
    // Acknowledge the interrupt
    //
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}

//
// End of file
//
ax value of 4095. I checked with a scope and confirmed that the max value of the triangle wave is 1v so it should not be reading the max value.

  • UPDATE: I have confirmed the code works by using a separate board with the motor driver board not attached, so my theory is that it is the motor driver some how. I have tried bending the ADCINA2 pin because of the datasheet it was shorted to VREFHI, but that did not seem to fix the issue. 

  • Hello Kristian,

    This seems like more of a Pin Conflict to me. As you mentioned, ADCINA2 is connected to VREFHI via a 0-ohm resistor or internal trace. This would clamp or bias the ADC input to the reference voltage, making it always read maximum value (4095 for 12-bit ADC). You can try lifting the pin (ADCINA2) from the BOOSTXL-DRV8305EVM header or cutting the trace/resistor that connects it to VREFHI (R35 is often the 0-ohm resistor doing this). Alternatively, use a different ADC input that is not connected to the motor driver board (e.g., ADCINA4 or ADCINB1), to verify your triangle wave source works in general.

    Also, I don't see the ADCINA2 connection to VREFHI in the mentioned boards.

    Best Regards,

    Masoud

  • Hello Masoud, Thank you for your advice on the matter! I agree that it is a pin conflict or some odd hardware problem. Here is what I have tried so far: I Have bent the ADCINA2 pin, and I have routed the triangle wave from the motor driver to a separate ADCIN pin that is not connected to the motor driver itself. I have tried this with 2 different boards and 3 different motor drivers with no luck. I routed VSENA from the motor driver to ADCIN15. Unfortunately the motor driver is what generates the triangle wave so I can not really isolate it. 
    Thank you, Kristian

  • It feels like the VREFHI is being adjusted or shorted somehow to be honest.

  • After playing around with it for a while, I've gotten it to work only when JP1,JP2, and JP3 are connected. This is such an odd issue. are there any potential issues with leaving these plugged in?

  • Happy to know the issue has been resolved. This is due to the fact that the DRV Booster Pack you're using only has a 3.3V LDO and doesn't support 5V conversion from the DC bus voltage. The reference voltage circuit for the ADC on the Launch Pad requires a 5V supply, and if you don't populate JP3, it won't receive power from the USB.

    Best Regards,

    Masoud

  • Why would the datasheet recommend removing the jumpers then if it does not work properly with them off?  

  • Hello Kristian,

    Overall, Launch Pads are designed to work with a wide range of Booster Packs and EVMs for many different examples. Every example or reference design may need different configuration. We ask to remove power jumpers when power is supplied externally through the Booster Pack headers to enable electrical isolation of the board from the PC.

    Best Regards,

    Masoud

  • that makes sense, is their any danger to have the jumpers in when im powering it through the booster pack?

  • Hi Kristian,

    If you feed 5V from the BoosterPack side, then keeping JP3 populated ties two 5 V rails together and can cause supply back-powering. If USB must stay connected for debug and you’re powering from the BoosterPack side, use an isolated configuration. If you’re happy to let USB power the board, keep JP1/JP2/JP3 populated and don’t add another 5 V source.

    Best Regards,

    Masoud

  • So i need to be able to debug it while running the boosterpack, does this mean I have to take the boosterpack off of the board to debug it? 

  • Hi Kristian,

    You don’t need to remove the BOOSTXL-DRV8305EVM to debug. Let USB power the LaunchPad and keep JP1, JP2, JP3 = ON.

    Best regards,
    Masoud