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.

Set the values of speed controller in code composer studio v5.3

Other Parts Discussed in Thread: MOTORWARE, DRV8301

Hello,

I am in problem, where i tried and set the values of speed controller and current controller values to debug  in CCS and i want to save these values permanently so that in watch window when i enable the flags i see these values instead of  pre calculated values using the formulae .

I am trying to re-write in proj_lab05b provided by MotorWare software 

But still now i could not find any solution.

I am using drv8301 board 

Can anyone tell me how to set the controllers values ? please. 

Thanks In Advance 

Regards

Archana

  • Archana,

    There are several ways to do this, depending on if you are trying to hard code your entire project right now or just keep these speed PI settings and move to the next project.

    You'll notice that the PID_spd is changed in a background task

    updateGlobalVariables_motor()

    this allows you to make changes in the Expressions Window and have it affect the controller.  You want to keep this as you will need to change the tuning at different speeds/loads.

    and the particular funtion that changes the PID_spd in this function is inside an if statement (only changes settings if the controller is OnLine, motor already identified, and the softwareUpdate1p6() has been checked/patched):

      if((gMotorVars.CtrlState == CTRL_State_OnLine) && (gMotorVars.Flag_MotorIdentified == true) && (Flag_Latch_softwareUpdate == false))
        {
          // set the kp and ki speed values from the watch window
          CTRL_setKp(handle,CTRL_Type_PID_spd,gMotorVars.Kp_spd);
          CTRL_setKi(handle,CTRL_Type_PID_spd,gMotorVars.Ki_spd);

     

    In lab5b.c I would update around line 289, commenting out the existing Kx_spd variable updates.

                  // initialize the watch window kp and ki values with pre-calculated values
                  //gMotorVars.Kp_spd = CTRL_getKp(ctrlHandle,CTRL_Type_PID_spd);
                  //gMotorVars.Ki_spd = CTRL_getKi(ctrlHandle,CTRL_Type_PID_spd);
        
         // hard code initial PID_spd values for my motor
         gMotorVars.Kp_spd = _IQ(5.0);
         gMotorVars.Ki_spd = _IQ(0.05);

    Note that if you move on to another lab you will need to copy this code over to the proj_lab##.c as well

  • Hello Chris,

    I did what you have said and it works. But i am in dilemma that is the value displayed in watch window is same as value at which speed controller is tuned or is the speed controller working in the pre calculated values ? . Because we comment the ctrl handle and add the values to gMotorVars without giving any handle 

    Thanks you in advance 

    Archana

  • Archana,

    If you changed what I said then the control system is using your hard coded values, but you can still make updates through the Expressions window by changing gMotorVars.Kp_spd  and gMotorVars.Ki_spd

    Try changing Kp_spd by 10x and you will see that your control system is certainly using this value :)

    the gMotorVars are getting updated in the background task mentioned in my post above. Similar to polling, when not in control interrupt it goes through the background state. One of the functions is to load certtain gMotorVars (which you the user can change at any time) into the control system.