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.

ADC Mapping changing Problem

Other Parts Discussed in Thread: DRV8312

I Changed the ADC Hardware mapping with my customized board based on the design of DRV8312 and F28054M

The default setting of current offsets are :

I_a connect to ADC_B3

I_b connect to ADC_B5

I_c connect to ADC_B7

I changed them to followings:

I_a connect to ADC_A1

I_b connect to ADC_B1

I_c connect to ADC_A3

I KEEP THE VOLTAGE OFFESETS MAPPING THE SAME as DRV8312

Since I changed the hardware connections, I need to change software ADC mapping as well

So I changed the ADC pin map in void HAL_setupAdcs(HAL_Handle handle) from hal.c

  // configure the SOCs for drv8312kit_revD
  // sample the first sample twice due to errata sprz342f
  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_0,ADC_SocChanNumber_A1);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_0,ADC_SocTrigSrc_EPWM1_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_0,ADC_SocSampleDelay_7_cycles);

  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_1,ADC_SocChanNumber_A1);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_1,ADC_SocTrigSrc_EPWM1_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_1,ADC_SocSampleDelay_7_cycles);

  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_2,ADC_SocChanNumber_B1);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_2,ADC_SocTrigSrc_EPWM1_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_2,ADC_SocSampleDelay_7_cycles);

  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_3,ADC_SocChanNumber_A3);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_3,ADC_SocTrigSrc_EPWM1_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_3,ADC_SocSampleDelay_7_cycles);

  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_4,ADC_SocChanNumber_B7);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_4,ADC_SocTrigSrc_EPWM1_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_4,ADC_SocSampleDelay_7_cycles);

  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_5,ADC_SocChanNumber_A7);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_5,ADC_SocTrigSrc_EPWM1_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_5,ADC_SocSampleDelay_7_cycles);

  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_6,ADC_SocChanNumber_B4);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_6,ADC_SocTrigSrc_EPWM1_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_6,ADC_SocSampleDelay_7_cycles);

  ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_7,ADC_SocChanNumber_B2);
  ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_7,ADC_SocTrigSrc_EPWM1_ADCSOCA);
  ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_7,ADC_SocSampleDelay_7_cycles);

  return;
} // end of HAL_setupAdcs() function

After I made these changes, I am still NOT able to read correct current offsets, which supposes to get these similar values

#define   I_A_offset    (-0.8692960739)
#define   I_B_offset    (-0.8690671921)
#define   I_C_offset    (-0.8657041192)

BUT I am getting following values:

I_A_offset    (-0.259814620)
I_B_offset    (-0.247000575)
I_C_offset    (-0.138281882)

Did I miss anything that also need to be changed?

 

  • Were you able to obtain a correct conversion with the original channels used? Or have you been unable to obtain one at all with your hardware? I'm wondering if this is hardware related or not

    Sean
  • Hi Sean,

    I don't think it's hardware related problem. I did few tests.

    Without using my own board, I used DRV8312 with F2805M, I changed it to the same ADC pins as my customized board in hal.c
    I_a connect to ADC_A1
    I_b connect to ADC_B1
    I_c connect to ADC_A3

    It generated the same output reading as my own customized board:
    I_A_offset (-0.259814620)
    I_B_offset (-0.247000575)
    I_C_offset (-0.138281882)

    BUT If I changed the ADC pins back to default in hal.c as
    I_a connect to ADC_B3
    I_b connect to ADC_B5
    I_c connect to ADC_B7

    I am able to get the correct reading of:
    I_A_offset (-0.8692960739)
    I_B_offset (-0.8690671921)
    I_C_offset (-0.8657041192)


    So I double checked the hardware connection of DRV8312,
    I_A is both connected with ADC_A1 and ADC_B3(hal.c default)
    I_B is both connected with ADC_B1 and ADC_B5(hal.c default)
    I_C is both connected with ADC_A3 and ADC_A5(hal.c default)

    Sadly, my customized board's hardware connections are only connected as
    I_a connect to ADC_A1
    I_b connect to ADC_B1
    I_c connect to ADC_A3

    I don't know why A1,B1,A3 can't be used to read the correct offset values. Or It just doesn't work by only changing these values in hal.c , maybe there are more modifications required?
  • It appears that there are also some switch settings that need to be confirmed for the F28054M control card. Switches SW5, 6 & 8 control divide-by-3 hardware pre-scalars for the ADC channels A1, B1 and A3. Can you confirm these are placed in the downward (0, right) position to allow these channels to be passed directly to the MCU?

    Sean
  • Yes, these switches are placed downward 0 to allow these channels to be passed directly to the MCU.
    But Same problem.
    I_A_offset (-0.259814620)
    I_B_offset (-0.247000575)
    I_C_offset (-0.138281882)

    Is Hal.c the only file that need to be changed when i use different ADC mapping?