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.

CCS: how to change CCS number format in code

Other Parts Discussed in Thread: DRV8301, MOTORWARE

Tool/software: Code Composer Studio

Hey,

I am working with DRV8301 with a board Piccolo F28069 Experimenter's Kit .  I have modified the already existing code in proj_lab05a..  It is basically a pi controller I designed and while running the code all the values are getting modified as desired. Here at the end of the code gmotorvars.IqRef_A should be modified. In the watch window I can see the value of this variable is around 10.00(Q-value 24). But in the oscilloscope it is around 2Amps. Here is the problem. The value which oscilloscope showing is correct. So how can I change the number format in the coding. When I try to change the format in watch window to decimal, the value I get there doesn't make any sense because its giving me a 6 or 7 digit number. I tried different format and nothing helped. here is the code

void updateIqRef(CTRL_Handle handle)
{
k++;
if(k==15) {
error=gMotorVars.VdcBus_kV-_IQ(BusVRef); //finding error
error_kp=_IQmpy(error,kp);
error_kiT=_IQmpy(error,kiT);
summation=_IQmpy((Iq_before_kaw+error_kiT+previous),D); //summation
before_sat=_IQmpy((error_kp+summation),D); //before saturation

if((before_sat >= _IQ(0)) || (before_sat <= _IQ(10))) //checking the limits for saturation
{gMotorVars.IqRef_A= before_sat ;}
if(before_sat <= _IQ(0)) { gMotorVars.IqRef_A = _IQ(0); }

if(before_sat >= _IQ(10)) { gMotorVars.IqRef_A = _IQ(10); }

previous=summation; //summation updation
Iq_before_kaw=gMotorVars.IqRef_A-before_sat; //Iq before the gain kaw
Iq_kaw=_IQmpy(Iq_before_kaw,kaw); //Iq after the gain kaw
k=0;

// _iq iq_ref = gMotorVars.IqRef_A;
_iq iq_ref = _IQmpy(gMotorVars.IqRef_A,_IQ(1.0/USER_IQ_FULL_SCALE_CURRENT_A));

// Set the Iq reference that use to come out of the PI speed control
CTRL_setIq_ref_pu(handle, iq_ref);
}
return;

for this the initialization of the variable is 

_iq kp =_IQ(01);
_iq kiT =_IQ(0.001);
_iq kaw =_IQ(1) ;
_iq previous =_IQ(0);
_iq T =_IQ(0.001);
_iq D =_IQ(1);
_iq error;
_iq error_kp;
_iq error_kiT;
_iq Iq_kaw;
_iq summation;
_iq before_sat;
_iq Iq_before_kaw =0;

Here D is just a variable(value 1) which I used to multiply every lines of the code to standardize the format to 24. This was done only after I have seen a lot of senseless numbers in the watch window. If I am not doing this, until the calculation of before_sat makes sense. But then IqRef_A will be in a different format which I couldn't figure. Even after standardizing the code in q-24 format, in the watch window when I convert to decimal, it gives a value with 5 or 6 digit number which is supposed to be 2 Amps.

Thanks in advance for any help 

Best regards,

Ambika

  • You don't need and can't change the global Q in any InstaSPIN-FOC projects if you are working on it. All control variables of the InstaSPIN-FOC algorithm in motorWare are using PU format, not SI format.

    Btw, as the knowledge of motor control you knew, Iqref is the reference torque current for motor control, not its phase current.

  • So how can I resolve this issue. I mean the value I am getting in CCS watch window is entirely different from the oscilloscope. Would you give me any suggestion to make the value in watch window to  be equal to the oscilloscope value.?

  • Unfortunately, we don't have such examples since a motor control doesn't need to do this work. You have to code a function to do this conversion from PU format to an SI format. As you know, we just provide support on TI devices and related reference design.