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.

The question of modify the program

Other Parts Discussed in Thread: DRV8301

1.Did the code of lab13e suit for velocity control of PMSM with encoder? I found lab13e cound not make motor run immediately because of initial Rs detection.How to make motor run immediately?What's the harm if omit initial Rs detection?

2.we know J10 is used to connect  five signal wires of HALL sensor on DRV8301-69M-KIT  ,but how to modify the program if I make five signal wires of encoder connect with J10 on my board? Thanks.

  • 1. 13 is position control. Use 12 for velocity.
    2. J4 is the encoder connector on DRV8301 EVM
  • 1.lab12 can not control the acceleration and jerk,I think I can get better performance,if I can control them.
    And I run the lab13e,it looked like only the speed regulation for the different curves that can be used with SpinTAC.So I want to know whether I can use lab13e to implement velocity control?
    2.I knew this already,but on my borad,I only designed J10.I lost J4 due to my negligence.So I have to make five signal wires of encoder connect with J10.hence I need help.I saw a program section in hal.c:
    #ifdef QEP
    // EQEPA
    GPIO_setMode(obj->gpioHandle,GPIO_Number_20,GPIO_20_Mode_EQEP1A);
    GPIO_setQualification(obj->gpioHandle,GPIO_Number_20,GPIO_Qual_Sample_3);

    // EQEPB
    GPIO_setMode(obj->gpioHandle,GPIO_Number_21,GPIO_21_Mode_EQEP1B);
    GPIO_setQualification(obj->gpioHandle,GPIO_Number_21,GPIO_Qual_Sample_3);

    // STATUS
    GPIO_setMode(obj->gpioHandle,GPIO_Number_22,GPIO_22_Mode_GeneralPurpose);

    // EQEP1I
    GPIO_setMode(obj->gpioHandle,GPIO_Number_23,GPIO_23_Mode_EQEP1I);
    GPIO_setQualification(obj->gpioHandle,GPIO_Number_23,GPIO_Qual_Sample_3);

    Excuse me. I wonder whether I can do it successfully just by modifying above GPIO mumber code. Are there other places need to modify?

  • 1, again, velocity control is done in proj_lab12, NOT proj_lab13.
    2. It depends on which MCU pins you have routed your J10. If the pins can be enabled as the proper QEP pins you will do this in HAL like you set-up every other pin. If they can not, you will need to modify your hardware.
  • You should be able to combine lab 12b with lab 6a in order to add in the acceleration and jerk control that you are looking for.
  • Hello Adam

    Combine the two programs...I think it will not be easy.Can I do it Just by modifying the file "proj_lab12b.c" ?If so,I will try to do that.

    You can check if I am making any mistake.

    Step 1:
    I add this function"ST_setupVelMove(stHandle)" to line 244

    Step 2:

    In line 392,I set SpinTAC Move start & end velocity to 0 when the estimator is not running.

    Step 3:

    I add this function"ST_setupVelMove(stHandle)" to line 465

    Step 4:

    I add this function"ST_runVelMove(stHandle, ctrlHandle);" to line 501

    Step 5:

    In this step,  I am in difficulty that how to modify "gMotorVars.SpeedTraj_krpm"?

    In lab6a:  gMotorVars.SpeedTraj_krpm = _IQmpy(STVELMOVE_getVelocityReference(stObj->velMoveHandle),EST_get_pu_to_krpm_sf(obj->estHandle));

    In lab12b: gMotorVars.SpeedTraj_krpm = _IQmpy(CTRL_getSpd_int_ref_pu(handle),EST_get_pu_to_krpm_sf(obj->estHandle));

    So I don't know how to combine them.I need help.

    Step 6:

    I add three variables into the function "updateGlobalVariables_motor(CTRL_Handle handle, ST_Handle sthandle)" in line 604.

    Step 7:

    I add a function "ST_runVelMove(ST_Handle handle, CTRL_Handle ctrlHandle)" in line 650.

    The last step:

    I ran into a difficult problem about the function "ST_runVelCtl(ST_Handle handle, CTRL_Handle ctrlHandle)"

    I found there are some differences between lab06a and lab12b.As shown:

    I wanna know how to combine them.

    Thanks.

  • Hi Adam
    I can not combine the codes in the fifth step and The last step.I hope to get some advice from you.
  • Sorry about the delay.

    For step 5, you should use:  gMotorVars.SpeedTraj_krpm = _IQmpy(STVELMOVE_getVelocityReference(stObj->velMoveHandle),EST_get_pu_to_krpm_sf(obj->estHandle));

    For the final step, in Lab 12b Line 658 should come from Lab 12b and Lines 661 & 662 should come from Lab 06a.

    Hope that helps.