Hello,
i´m programming with an TMS320F28069 mikrocontroller for my masterthesis. The program is for controlling a threephase voltage source converter. The sample time of the discrete control technique is 31.25µs. I read in the multiday-workshop and the IQ-Math-Guide that using variable from _iq-type is faster than run the program with double or float-variables, so I used the _iq-type.
Now I have a problem, that my interrupt-service-routine with the AD-sampling and control-functions needs about 192µs, which is too much time refered to the control-loop-/sample-time of 31.25µs. I tested the cycle-time by setting and clearing an IO-pin. I compared the cycle-time of a part of program when reading the ADCresult-regs for 13 channels. With IQ-variables the part of program needs ca. 58µs and with double-variables it needs ca.5.8µs. Here are the two tested parts:
// note: the variables are arrays
*i_fu_u = _IQmpy(iq_readAdc(0),_IQ(-0.019536)) + _IQ(40); // convert Analog A0
*i_fu_v = _IQmpy(iq_readAdc(1),_IQ(-0.019536)) + _IQ(40); // convert Analog A1
*i_fu_w = _IQmpy(iq_readAdc(2),_IQ(-0.019536)) + _IQ(40); // convert Analog A2
*i_vm_u = _IQmpy(iq_readAdc(3),_IQ(-0.019536)) + _IQ(40); // convert Analog A3
*i_vm_v = _IQmpy(iq_readAdc(4),_IQ(-0.019536)) + _IQ(40); // convert Analog A4
*i_vm_w = _IQmpy(iq_readAdc(5),_IQ(-0.019536)) + _IQ(40); // convert Analog A5
*u_vm_dc = _IQmpy(iq_readAdc(6),_IQ(200)); // convert Analog A6
*temperatur = _IQmpy(iq_readAdc(7),_IQ(0.08058608)); // convert Analog A7 // u(t)=10mV/C° *T +0° // T = 3,3V/4095*100*(C°/V)=0.08058608
*u_fu_pwm_u = _IQmpy(iq_readAdc(8) ,_IQ(-0.27876)) + _IQ(519); // convert Analog B0 u_adc_b0 = -1/346*u +1,5V; u = Result*(-0,27876)+519
*u_fu_pwm_v = _IQmpy(iq_readAdc(9) ,_IQ(-0.27876)) + _IQ(519); // convert Analog B1 u_adc_b1 = -1/346*u +1,5V
*u_fu_pwm_w = _IQmpy(iq_readAdc(10),_IQ(-0.27876)) + _IQ(519); // convert Analog B2 u_adc_b2 = -1/346*u +1,5V
*poti_buffer_1 = (iq_readAdc(11)); // convert Analog B3
*poti_buffer_2 = (iq_readAdc(12)); // convert Analog B4
// other programming technique with double-variables:
test_variable = ((double)(AdcResult.ADCRESULT0)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT1)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT2)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT3)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT4)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT5)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT6)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT7)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT8)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT9)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT10)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT11)-2046.0)*2.0;
test_variable = ((double)(AdcResult.ADCRESULT12)-2046.0)*2.0;
I expected programming with the IQ-Math-lib would increase the speed instead of decreasing it.
The µC runs from Flash with 3 waitstates at 90MHz. Currently I´m reading how to boot from flash but runthe program in RAM.
I hope anybody can help me,
yours sincerely,
B.Eng. Andreas Bauer