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.

TMS320F280039C: Hall Calibration in Motor Control SDK Universal

Part Number: TMS320F280039C
Other Parts Discussed in Thread: BOOSTXL-3PHGANINV

Tool/software:

I am using the F280039C microcontroller with the BOOSTXL-3PHGANINV driver and opened Universal_motorcontrol_lab_f28003x.

I connected the Hall sensor of one of my motors to the BOOSTXL-3PHGANINV as explained in the datasheets and I need to do the calibration.

I have not found anything about this procedure, only this post and this comment in the universal motor control lab:

// Enable MOTOR1_HALL_CAL pre-defined symbols, run the motor with FAST for angle calibration
// Copy hall_M1.thetaCalBuf[] to hallAngleBuf[]
// 1->1, 2->2, 3->3, 4->4, 5->5, 6->6, 6->0
// Disable MOTOR1_HALL_CAL pre-defined symbols after calibration for normal operation
                                    // 6           1              2
                                    // 3           4              5
                                    // 6

1) I didn't understand whether I have to activate both the predefined symbol HALL_CAL and MOTOR1_HALL during calibration .. or if I only have to activate HALL_CAL.

2) Where should I write the required code for calibration? Just below the comment in the motor1_drive.c file? In the main?

3) Correct me if I'm wrong, is this the code that needs to be written?

       float32_t hallAngleBuf[7] = { 0, 0, 0, 0, 0 , 0, 0 };
       hallAngleBuf[0] = hall_M1.thetaCalBuff[0];
       hallAngleBuf[1] = hall_M1.thetaCalBuff[1];
       hallAngleBuf[2] = hall_M1.thetaCalBuff[2];
       hallAngleBuf[3] = hall_M1.thetaCalBuff[3];
       hallAngleBuf[4] = hall_M1.thetaCalBuff[4];
       hallAngleBuf[5] = hall_M1.thetaCalBuff[5];
       hallAngleBuf[6] = hall_M1.thetaCalBuff[6];
       hallAngleBuf[0] = hall_M1.thetaCalBuff[6];

After writing the above code in the main, I put hall_M1.thetaCalBuff in the expressions (while debugging) but everything remains at 0.

Investigating a bit, I noticed that the HALL_calibrateIndexAngle function (which I believe is calibration) does not vary ... that is, it is called repeatedly if and only if motorVars_M1.flagEnableRunAndIdentify= 0 but no parameters within it change .. it's all zero!

I should have uploaded some pictures, please tell me if you see them

  • Hi,

    1) I didn't understand whether I have to activate both the predefined symbol HALL_CAL and MOTOR1_HALL during calibration .. or if I only have to activate HALL_CAL.

    Activate both of these as well as the FAST pre-define. FAST sensorless algo needs to run in parallel for the calibration process.

    2) Where should I write the required code for calibration? Just below the comment in the motor1_drive.c file? In the main?

    3) Correct me if I'm wrong, is this the code that needs to be written?

    Calibration code already exists, you just need to copy the results between the array definitions after running the calibration routine once.

    Best,

    Kevin

  • Hi and thanks for your reply.

    First of all in your commented code on CCS you talk about "hall_M1.thetaCalBuf", but it does not exist. Maybe you meant hall_M1.thetaCalBuff (with an extra "f") present inside the struct hall_M1.

    When I debug, as soon as I press "Run" button, the array "hall_M1.thetaCalBuff" is all 0 and in the expressions I see:

    - EST_TYPE_FAST_HALL

    - MOTOR_STOP_IDLE

    - EST_STATE_IDLE 

    - HALL_IDLE

    - ESTIMATOR MODE FAST

    When I enable motorVars_M1.flagEnableRunAndIdentify = 1, the array continues to remain 0 and in the expressions there are:

    - EST_TYPE_FAST_HALL

    - MOTOR_SEEK_POS

    - EST_STATE_ONLINE 

    - HALL_IDLE

    - ESTIMATOR MODE FAST

    The motor does not rotate, nor does it draw current

    Without the Hall (only FOC sensorless) the motor runs properly.

    I don't understand what the problem is.

    At the hardware level I have connected everything correctly and switched the small jumpers on the board (as suggested in youtr C200ware universal lab pdf) .. and the Hall sensor works (I tested it with logic analyzer with pull-up resistors on breadboard)

  • Hi,

    Your config sounds correct, but you need to get the motor spinning with EST_TYPE_FAST_HALL and ESTIMATOR_MODE_FAST config. This will use FAST algo for closed loop control, but HALL sensor algo will still run in background to complete the calibration.

    When I enable motorVars_M1.flagEnableRunAndIdentify = 1, the array continues to remain 0 and in the expressions there are:

    - EST_TYPE_FAST_HALL

    - MOTOR_SEEK_POS

    - EST_STATE_ONLINE 

    - HALL_IDLE

    - ESTIMATOR MODE FAST

    Why this isn't working I'm not sure. Which SDK version are you using? Maybe a newer version has some bug fixes.

    Best,

    Kevin

  • I have both EST_TYPE_FAST_HALL and ESTIMATOR_MODE_FAST active. It does not work.

    I don't know if you go into this level of detail, but I attach here the link where you can download the project and check what's wrong. Consider that as much as some parts of the code were changed (by me) to suit my hardware to run the motor only with FAST (such as user_mtr1.h) .. I did not add anything more. I even reimported the project from zero to another workspace, but same problem.

    (if the link is not accessible tell me, I reloaded it)

    Motor SDK I downloaded in November, so I would say it is a fairly recent version.

  • I noticed that MOTOR_SEEK_POS is active only if flying start is ... and this imposes a speed control off.

    So I disabled flying start so that now the status is MOTOR_ALIGNMENT.

    Is this correct?

  • Another thing, motorVars_M1.ISRCount contained in "__interrupt void motor1CtrlISR(void)" does not vary. As soon as I debug it stops at 1872

  • Hi,

    Another thing, motorVars_M1.ISRCount contained in "__interrupt void motor1CtrlISR(void)" does not vary. As soon as I debug it stops at 1872

    Is there a trip occurring that is disabling the ePWM?

    I can try the SDK example project out myself to verify it's working properly when I have some time.

    Best,

    Kevin

  • The pwm frequency was 45kHz.

    Now I changed it to 30kHz and the code correctly found thetaCalBuff ... how is that possible? why with 45kHz it was not going?

  • So, to recap, I just copy the values like this into "motor1_drive.c" and disable HALL_CAL:

    #if (USER_MOTOR1 == Teknic_M2310PLN04K)
    const float32_t hallAngleBuf[7] = { 2.60931063f,  -0.45987016f, -2.57219672f, \
                                        -1.50797582f, 1.59862518f , 0.580176473f,
                                        2.60931063f };
    
    #elif (USER_MOTOR1 == Anaheim_BLY172S_24V)
    const float32_t hallAngleBuf[7] = { -1.41421735f,  1.75656128f, -2.48391223f, \
                                        2.76515913f,  -0.460148782f, 0.606459916f,
                                        -1.41421735f };
    #elif (USER_MOTOR1 == Anaheim_BLWS235D)
    const float32_t hallAngleBuf[7] = { 1.64448488f,  -1.54361129f,  0.548367858f, \
                                       -0.390248626f,  2.67842388f, -2.52673817f,
                                        1.64448488f };
    #elif (USER_MOTOR1 == Tool_Makita_GFD01)
    const float32_t hallAngleBuf[7] = { -2.71645141f,  0.399317622f, 2.47442961f,  \
                                        1.47019732f, -1.67825437f, -0.643157125f, \
                                        -2.71645141f };
    // ---------------THIS ONE IS MY MOTOR------------------
    #elif (USER_MOTOR1 == my_pm_motor_1)
    const float32_t hallAngleBuf[7] = { -2.01914597f,  2.15623236f, 2.71764278f,  \
                                        0.133888945f, -1.24430346f, 0.692704678f, \
                                        -2.01914597f };

  • Also, the motor (FAST sensorless configuration) does not rotate over if I set USER_M1_PWM_FREQ_kHz greater than 47 .

    www.dropbox.com/.../ACffQGwc16NQM6l1VMoHuCA

  • Hi,

    Now I changed it to 30kHz and the code correctly found thetaCalBuff ... how is that possible? why with 45kHz it was not going?

    It's possible the ISR / code execution takes too long for 45KHz to work.

    So, to recap, I just copy the values like this into "motor1_drive.c" and disable HALL_CAL:

    Right, the calibration values should settle and not change much after some time. It just needs to be run once really.

    Best,

    Kevin