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.

InstaSPIN access to 2nd motor and PWM of the 28069M LaunchXL / BOOSTXL-DRV8301

Other Parts Discussed in Thread: DRV8301, MOTORWARE

Dear All

How can I drive 2 BLDC motor usinc InstaSPIN FOC / HAL and have access to the PWM of the second BOOSTXL-DRV8301

// write the PWM compare values
HAL_writePwmData(halHandle,&gPwmData);

only access the bottom DRV8301

Thanks

  • we have not released an example project yet that drives two inverters from a single Launchpad. Currently you must select either the J1 (top) or J5 (bottom) headers only (set the #define in user.h)

    it is on the to-do list...but I'm not so hopeful that it will be done this year.
  • I can't wait :-(
    I have an urgent project to address.
    Si if you can guide me, I will make the path clearer for followers...
    Thanks in advance
    I found that I have to use the
    hal_both.c
    file
    but this file there is QEP that is not addressed ? if I compare it with hal.c

    Also Do I have to insanciate 2 ctrlHandle ?
    What should I duplicate and what should I instanciate only once ?

    CTRL_Handle ctrlHandle1, ctrlHandle2; ???;
    HAL_Handle halHandle; ???;
    USER_Params gUserParams; or 2 user data ? each one for a motor even if they are same motors ???
    ...
    HAL_AdcData_t gAdcData1 ,gAdcData2 ???;

    //#ifdef FAST_ROM_V1p6
    CTRL_Obj *controller_ob1, *controller_ob2j; ???;

    thanks
  • Lotfi,
    I'm sorry, we aren't going to be able to help you with this one. It is complex and we don't have a good example to easily share in MotorWare.
  • Lotfi,

    I want to do the same thing. The hal_both.c doesn't contain too much useful in motorware v14. It is just place-holder along with hal_both.h, hal_both_obj.h. I modified the existing hal.

    But the real limitation lies in the CTRL. TI engineers somehow constrain the ctrl and estimator within ROM. They defined a symbol FAST_ROM_V1p6. They didn't provide the source code for us to create a second ctrl.

    I am currently stuck at this step. I wonder if there is anyway to circumvent this problem.
  • in your ctrl_both.h

    #define CTRL_NUM_CONTROLLERS (2)

    you will need to set-up the following for m1 and m2 (or however you are defining). Rest should be the same as normal ctrl.h

    void CTRL_run_m1(CTRL_Handle handle,HAL_Handle halHandle,
    void CTRL_setup_m1(CTRL_Handle handle);
    inline void CTRL_runOffLine_m1(CTRL_Handle handle,HAL_Handle drvHandle,
    HAL_runOffsetEst_m1(halHandle,pAdcData);

    in ctrl.c you will need

    #include "ctrl_both.h"
    #include "hal_both.h"
    #include "user_both.h"
    #include "user_m1.h"
    #include "user_m2.h"


    #ifdef FLASH
    #pragma CODE_SECTION(CTRL_run_m1,"ramfuncs");
    #pragma CODE_SECTION(CTRL_setup_m1,"ramfuncs");

    #pragma CODE_SECTION(CTRL_run_m2,"ramfuncs");
    #pragma CODE_SECTION(CTRL_setup_m2,"ramfuncs");

    #endif

    and for m2 and m1 you will need instances of:

    void CTRL_run_m1(CTRL_Handle handle,HAL_Handle halHandle, CTRL_runOffLine_m1(handle,halHandle,pAdcData,pPwmData);

    void CTRL_setup_m1(CTRL_Handle handle)
  • Dear Chris,

    Thank you for your reply. I couldn't find ctrl_both.h

    Could you explain how to use the CTRL_init(), If FAST_ROM_V1p6 is not defined(I assume it has to be removed if I want to use two CTRL and EST)? I found there is a source of this function sw\modules\ctrl\src\float. Specifically, how do I assign the pmemory?

    My understanding is that CTRL and Estimator have their own memory block in ROM , so called FAST. If I need two CTRL and Estimator, there needs someplace to accommodate the second one, right?

  • you will need to create ctrl_both, or just update your existing ctrl
    I tried to outline which functions need to have version for m1 and m2

    do not use anything from src\float
    these files were included incorrectly in the MotorWare release. they are part of the development process we are using for future versions. they are not used with existing silicon devices.

    Again, this isn't officially supported yet....I'm trying to help best I can because you guys have made so much progress.
  • Dear Chris,

    Thank you very much for your reply. I might figure out where I was wrong:

    I used two CTRL and EST handle.

    CTRL_Handle ctrlHandle;

    CTRL_Handle ctrlHandle_J1;

    so something like ctrlHandle_J1 = CTRL_initCtrl(ctrlNumber_J1, estNumber_J1);  can cause problem, because there is only one CTRL allowed in FAST. Am I right?

    So the major overhaul is to edit the CTRL_Obj, which means a whole bunch of variables , flags and functions.But I need to use only one CTRL_Handle. Am I right?

    Thank you

    Yichao

  • you only need one EST handle as there will be an EST for each CTRL.
    There should be two CTRL handles and two CTRL objects.

    in your main_both.h you will need to setup
    #define MOTOR_Vars_INIT_M1
    #define MOTOR_Vars_INIT_M2


    in you main_both.c or proj_both.c (whatever you are calling it) you will be initializing

    bool_t flag_ctrlStateChanged_m1;
    bool_t flag_ctrlStateChanged_m2;

    CTRL_State_e ctrlState_m1;
    CTRL_State_e ctrlState_m2;

    CTRL_Handle ctrlHandle_m1;
    CTRL_Handle ctrlHandle_m2;

    HAL_Handle halHandle;

    USER_Params gUserParams_m1;
    USER_Params gUserParams_m2;

    HAL_PwmData_t gPwmData_m1;
    HAL_PwmData_t gPwmData_m2;

    HAL_AdcData_t gAdcData_m1;
    HAL_AdcData_t gAdcData_m2;

    CTRL_Obj *controller_obj_m1;
    CTRL_Obj *controller_obj_m2;

    MOTOR_Vars_t gMotorVars_m1 = MOTOR_Vars_INIT_m1;
    MOTOR_Vars_t gMotorVars_m2 = MOTOR_Vars_INIT_m2;


    // initialize the controller
    ctrlHandle_m1 = CTRL_initCtrl(CTRL_NUMBER_m1, EST_NUMBER_m1);
    ctrlHandle_m2 = CTRL_initCtrl(CTRL_NUMBER_m2, EST_NUMBER_m2);

    controller_obj_m1 = (CTRL_Obj *)ctrlHandle_m1;
    controller_obj_m2= (CTRL_Obj *)ctrlHandle_m2;

    // set the default controller parameters
    CTRL_setParams(ctrlHandle_m1,&gUserParams_m1);
    CTRL_setParams(ctrlHandle_m2,&gUserParams_m2);

    that's about the limit of how I can help...
  • This was exactly what I did. I wonder if you guys have ever tested it before.

    I am dubious about:
    ctrlHandle_m1 = CTRL_initCtrl(CTRL_NUMBER_m1, EST_NUMBER_m1);
    ctrlHandle_m2 = CTRL_initCtrl(CTRL_NUMBER_m2, EST_NUMBER_m2);
    because it has a '#ifdef FAST_ROM_V1p6', I don't know what its effect on the ctrlhandle. FAST can allow two ctrlhandle??

    My code now can run m1 ok. but m2 CTRL state is always CTRL_ERROR but the error code says no error.
  • "because it has a '#ifdef FAST_ROM_V1p6', I don't know what its effect on the ctrlhandle. FAST can allow two ctrlhandle??"
    Yes, on the F2806x and F2805x devices the library allows 2 CTRL.

    The code snippets I showed are from code that is controlling a compressor and fan motor today.
  • I see. thank you. I need to take a closer look at my code.
    The only question left is for the second motor,
    'ctrlHandle_m2 = CTRL_initCtrl(CTRL_NUMBER_m2, EST_NUMBER_m2);'
    CTRL_NUMBER_m2 and EST_NUMBER_M2. I use 1. It doesn't matter , right?
  • Hi Yichao and Chris

    Thanks for your help, I will take a look at the code provided by Yichao, but why did you replace  the ctrl.x hal.x in the TI directory, it would be more interesting to replace them in the project working directory

    Right now I am trying to achieve a QEP reading while still using sensorless, and it is not obvious because of the way the CTRL_runOnLine_User and CTRL_runOnLine functions are written

    best

    Lotfi