MC9S12ZVML128_BLDC_Sensorless example adding ADC measuring

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

MC9S12ZVML128_BLDC_Sensorless example adding ADC measuring

2,116 Views
subinkim
Contributor II

Hi,

I want to use ADC module to get AMP0 and AN1_0 in BLDC_sensorless example code.

 

My codes are like this,

 

void initGDU()

{
 GDUE_GCSE0 = 1; // enable Current Sense Amplifier 0

}

 

void initGPIO(void)
{
 DDRADH_DDRADH0 = 1; /*AN1_3 set*/
 PTAD_PTADH0 = 1;

}

 

volatile short PTUTriggerEventList[PTU_TOT_TRIGGERs_GEN_NO][PTU_TOT_LISTS_NO][4] ={
  { /*DelayT0 */
    {0x0100, 0x0200, 0x0000, 0x0000}, {0x0000, 0x0000, 0x0000, 0x0000}
  },
  {
    {0x0100, 0x0200, 0x0000, 0x0000}, {0x0000, 0x0000, 0x0000, 0x0000}
  }
};

 

volatile char ADC0CommandList[6][4] = {
  { 0x40, 0xD0, 0x00, 0x00 }, // current sense channel, end of sequence [D0]
  { 0xC0, 0xCB, 0x00, 0x00 }, // end of list + no int [C0], HD voltage [CB], 4 clock cycles sample time [00], reserved [00]
  { 0x00, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x00 } };
PR_SECTION(adcLists)

volatile char ADC1CommandList[6][4] = {
  { 0x40, 0xCA, 0x00, 0x00 }, // [end of list] + no int [C0], phase voltage [CA], 4 clock cycles sample time [00]
  { 0xC0, 0x50, 0x00, 0x00 }, // ADC1 AN1_0
  { 0x00, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x00 } };

volatile unsigned short ADC0ResultList[6] = { 0, 0, 0, 0, 0, 0 };
volatile unsigned short ADC1ResultList[6] = { 0, 0, 0, 0, 0, 0 };

 

void UpdateDutycycle(void) {
 tU16 delay1, delay2;

 PMFVAL0 = duty_cycle;

 

 delay1 = duty_cycle >> 2;    // middle of the pulse - DC Bus current
 if (delay1 < MIN_ADC_TRIGGER_FIRST)
  delay1 = MIN_ADC_TRIGGER_FIRST;
 PTUTriggerEventList[0][0][0] = delay1;

 

 delay2 = MLIB_Mul(duty_cycle,BEMF_SENSING_POINT_FRAC,F16); // end of the pulse
 if (delay2 < MIN_ADC_TRIGGER_FIRST)
  delay2 = MIN_ADC_TRIGGER_FIRST;
 PTUTriggerEventList[1][0][0] = delay2;     // ADC1 - phase voltage

 

 if (delay2 < (delay1 + MIN_ADC_TRIGGER_SECOND))
  delay2 = delay1 + MIN_ADC_TRIGGER_SECOND;
 PTUTriggerEventList[0][0][1] = delay2; // ADC0 second sample - DC Bus Voltage

 
 PTUTriggerEventList[1][0][1] = delay2+35;

 PTUC_PTULDOK = 1;
}

 

 

It looks like that the ADC values are measured, but the BLDC motor is not rotating normally(repeat stop and go).

 

what's the problem of my code?? I beg your opinion.

Tags (3)
4 Replies

1,427 Views
Monke
Contributor I

I have the same problem as you. This is my question.How to config ADC of MTRCKTSBNZVM128_CW11 - NXP Community

Like you, I have read a lot about ADC sampling, but there are no results. How did you solve it later?

0 Kudos
Reply

1,736 Views
528887301
Contributor II

Hi.

 

I use MC9S12ZVML128_BLDC_Sensorless example project.

Only to modify the current acquisition function from the operational AMP0 to the operational AMP1.

But it has never been successful, Is there an example here?

0 Kudos
Reply

1,736 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi,

You can find discussion about this topic on the site below:

MC9S12ZVML128_BLDC_Sensorless adding ADC 

Best regards,

Diana

1,736 Views
subinkim
Contributor II

Hi,

Thank you for your response.

I already read it before I upload the question. But it's now working on mine.

The motor repeats stop and go.

I think it is concerned with trigger timing.

(ISR or value of delay1/2 or UpdateDutycycle() function's TriggerEventList value setting

Please give me your more opinions.

0 Kudos
Reply