56F8367EVM  - motor control calculation time "overflow"

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

56F8367EVM  - motor control calculation time "overflow"

1,534 Views
kgeldhof
Contributor I
Hello,

I implemented a simple (proportional) controller to control the current in an inductor. For this goal I used a PWM-triggered timer bean, which triggers the ADC of a 56F8367EVM evaluation board. I wrote a few lines of code in the ADC_OnEnd interrupt routine in order to calculate the duty ratio for the next PWM period:

void AD1_OnEnd(void)
{
  unsigned int   AdcSample,AdcSample_corr;
  byte                i;

  // read ADC result
  if (AD1_GetChanValue(0,&AdcSample)!=ERR_OK) {asm(debughlt);}
   
  // Correct linearity and offset of analog measuring circuit and ADC
  AdcSample_corr=sub(AdcSample,ADC_offset);
  i_measured=mult(AdcSample_corr,ADC_to_current);

  // current control: calculate duty cycle for next PWM period
  Duty=controllerP(i_desired,i_measured,&currentCtrlPIprm);
  fault=PWMC1_SetDuty(2,Duty.ValHigh);
  fault=PWMC1_SetDuty(3,Duty.ValLow);

  // Test pulse (GPIO_C bit 3)
  i=5;
  GPIO_C_DR=0x0008;
  while (i--){asm{nop;}}
  GPIO_C_DR&=~0x0008;

  // load PWM values
  PWMC1_Load();   
}

The function "controllerP" performs a multiplication of (i_desired-i_measured) with a constant factor. With the help of the test pulse and a scope I found that the execution of this routine takes about 25 us. This seems a lot to me for a few simple calculations. The PWM-period is 125 us. As the ADC samples halfway the PWM period, only 125/2-25=37.5 would be still available for other calculations. As I plan to implement a sensorless control, the computational overhead would certainly become too big I assume...

Is this great computational burden normal? Is it because I'm running in debug mode?

Thanks for any help.
Kristof Geldhof

used products: evaluation module 56F8367EVM, CodeWarrior version 5.6.1.



--
Alban Edit: Please always include FSL Part Number in Message Subject line.



Message Edited by Alban on 2007-09-12 12:02 AM
Labels (1)
Tags (1)
0 Kudos
1 Reply

193 Views
trytohelp
NXP Employee
NXP Employee
Hi,
 
There is no difference between demo mode and other version.
Excepted a code size limitation and other special feature like CAN, there is no difference.
The tools are the same.
 
Processor Expert is delivered by a third party.
I need to check this point with them.
 
Please log this issue in our CRM system.
Please use Freescale on line support web page.
  - Go to following URL: http://www.freescale.com/TechSupport
  - Click on Submit a Service Request. You will come to a login page.
  - You can submit your request through the web from there.
Pascal
0 Kudos