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/DRV8301-69M-KIT: InstaSPIN Lab 1b data logger graphing and DAC parameter issues

Part Number: DRV8301-69M-KIT
Other Parts Discussed in Thread: MOTORWARE

Tool/software: Code Composer Studio

I have a DRV8301-69M-KIT, and I am trying to work through the InstaSPIN Projects and Labs. I am new to CCS and this hardware. I am having two problems with the data logging feature in Lab 1b. The first is that the signals from the data logger are not being properly displayed in the graph windows, as can be seen in the following plot of the angle gen signal (it jumps all around and does not consistently look like this):

It seems to be a display or buffering issue rather than an issue with the actual signals. They look as expected (mostly) when I probe them with my scope. I read on one of the E2E forum questions that one-shot capture was recommended, and I have tried setting datalog.Flag_EnableLogOneShot = true in proj_lab01b.c, but I have not been successful in getting that to work.

The second issue I am having is that the DAC gains and offsets I set in hal.c do not seem to have any effect on the DAC output signals, neither those displayed in the graphs from the data logger nor those I probe with my scope. As far as I can tell, that code is executing, and the offsets and gains appear to be getting set, but I have no control over the actual offset of the signals, and the angle generator signal is always saturating high when I look at it on my scope.

I would appreciated any guidance that can help me keep progressing through these labs.

Thank you,

Kyle

  • For Datalog:

    1. Follow the instaSPIN guide to setup the Graph Properties for datalog, and set the correct "Max Y" and "Min Y" value if you changed the connected inputs of the datalog module.

    2. Change the datalog.Flag_EnableLogOneShot to "1", it will be changed back to "0" automatically. And then click the "refresh" button in Graph window.

    For PWMDAC:

    1. Set the right gain and offset in HAL_setDacParameters() in hal.c if you changed the connected inputs of the PWMDAC module.

    2. Connect the probes of the oscilloscope to the DACPWM pins of J6 on DRV8301-Kit.

    If you haven't had a chance to look at the workshop material, I think this will help demystify some of the terminology and architecture as well.

    https://training.ti.com/c2000-mcu-device-workshops

  • Thank you for your reply. Unfortunately, those are exactly the things I have been doing, but I am still not having success.

    For Datalog:

    1. I imported the appropriate .graphProp files from C:\ti\motorware\motorware_1_01_00_18\sw\solutions\instaspin_foc\src to set up the graph properties. That all worked just fine, and I am not having an issue with graph settings.

    2. I have set datalog.Flag_EnableLogOneShot to "1", and I do get it to display a single shot of buffered data, but it is very close to a flat line in all cases. It looks nothing like it is supposed to. I have tried modifying the buffer and display data sizes, which does change what is displayed, but for no values am I able to get a waveform that looks as it should.

    For PWMDAC:

    1. I am modifying these gain and offset values in hal.c. My problem is that the gains and offsets have no effect on the either the DAC outputs (as measured on my scope) or the data log signals. For example, the angle_gen signal, when viewed on my scope, is saturating high, regardless of the

    2. I am probing the DACPWM pins with my scope. That is how I know that the graphs is not accurately displaying the DAC data. It is also how I have confirmed that the DAC gain and offset settings are not having any effect on the DAC signals.

    I have not looked at the workshop material, but I will. Thank you for pointing that out.

    Any more guidance would be greatly appreciated.

    Thanks,

    Kyle

  • After adjusting the reference speed and the buffer size, I now have the one-shot data logging working. But, still no luck getting the DAC offset and gain values to have any effect. I change the values in hal.c, but the DACPWM signals probed at J6 never change - the angle_gen signal always has a positive offset and is clipping high.

    Any suggestions?

  • Please check if the configuration as the following content in the project. You may replace the original simliar codes with the following codes directly. 

    1. In proj_lab01b.c 

    // set DAC parameters

    gDacData.ptrData[0] = &gPwmData.Tabc.value[0];
    gDacData.ptrData[1] = &gPwmData.Tabc.value[1];
    gDacData.ptrData[2] = &gPwmData.Tabc.value[2];
    gDacData.ptrData[3] = &angle_gen.Angle_pu;

    HAL_setDacParameters(halHandle, &gDacData);

    2. In proj_lab01b.c

    // connect inputs of the PWMDAC module.

    gDacData.value[0] = (*gDacData.ptrData[0]); //
    gDacData.value[1] = (*gDacData.ptrData[1]); //
    gDacData.value[2] = (*gDacData.ptrData[2]); //
    gDacData.value[3] = (*gDacData.ptrData[3]); //

    HAL_writeDacData(halHandle,&gDacData);

    3. In hal.h

    static inline void HAL_writeDacData(HAL_Handle handle,HAL_DacData_t *pDacData)
    {
    HAL_Obj *obj = (HAL_Obj *)handle;

    // convert values from _IQ to _IQ15
    uint_least8_t cnt;
    _iq period;
    _iq dacData_sat_dc;
    _iq value;
    uint16_t cmpValue[4];

    period = (_iq)pDacData->PeriodMax;

    for(cnt=0;cnt<4;cnt++)
    {
    dacData_sat_dc = _IQmpy(pDacData->value[cnt], pDacData->gain[cnt]) + pDacData->offset[cnt];
    value = _IQmpy(dacData_sat_dc, period);
    cmpValue[cnt] = (uint16_t)_IQsat(value, period, 0);
    }

    // write the DAC data
    PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[0]);
    PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_1], cmpValue[1]);
    PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_2], cmpValue[2]);
    PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_3], cmpValue[3]);

    return;
    } // end of HAL_writeDacData() function

    4. In hal.c

    void HAL_setDacParameters(HAL_Handle handle, HAL_DacData_t *pDacData)
    {
    HAL_Obj *obj = (HAL_Obj *)handle;

    pDacData->PeriodMax = PWMDAC_getPeriod(obj->pwmDacHandle[PWMDAC_Number_1]);

    pDacData->offset[0] = _IQ(0.5);
    pDacData->offset[1] = _IQ(0.5);
    pDacData->offset[2] = _IQ(0.5);
    pDacData->offset[3] = _IQ(0.0);

    pDacData->gain[0] = _IQ(1.0);
    pDacData->gain[1] = _IQ(1.0);
    pDacData->gain[2] = _IQ(1.0);
    pDacData->gain[3] = _IQ(1.0);

    return;
    } //end of HAL_setDacParameters() function

    5. In hal.c

    // initialize PWM DAC handles
    obj->pwmDacHandle[0] = PWMDAC_init((void *)PWM_ePWM6_BASE_ADDR,sizeof(PWM_Obj));
    obj->pwmDacHandle[1] = PWMDAC_init((void *)PWM_ePWM5_BASE_ADDR,sizeof(PWM_Obj));
    obj->pwmDacHandle[2] = PWMDAC_init((void *)PWM_ePWM4_BASE_ADDR,sizeof(PWM_Obj));

    6. In hal.c

    void HAL_setupPwmDacs(HAL_Handle handle)
    {
    HAL_Obj *obj = (HAL_Obj *)handle;
    uint16_t halfPeriod_cycles = 512; // 3000->10kHz, 1500->20kHz, 1000-> 30kHz, 500->60kHz
    uint_least8_t cnt;


    for(cnt=0;cnt<3;cnt++)
    {
    // initialize the Time-Base Control Register (TBCTL)
    PWMDAC_setCounterMode(obj->pwmDacHandle[cnt],PWM_CounterMode_UpDown);
    PWMDAC_disableCounterLoad(obj->pwmDacHandle[cnt]);
    PWMDAC_setPeriodLoad(obj->pwmDacHandle[cnt],PWM_PeriodLoad_Immediate);
    PWMDAC_setSyncMode(obj->pwmDacHandle[cnt],PWM_SyncMode_EPWMxSYNC);
    PWMDAC_setHighSpeedClkDiv(obj->pwmDacHandle[cnt],PWM_HspClkDiv_by_1);
    PWMDAC_setClkDiv(obj->pwmDacHandle[cnt],PWM_ClkDiv_by_1);
    PWMDAC_setPhaseDir(obj->pwmDacHandle[cnt],PWM_PhaseDir_CountUp);
    PWMDAC_setRunMode(obj->pwmDacHandle[cnt],PWM_RunMode_FreeRun);

    // initialize the Timer-Based Phase Register (TBPHS)
    PWMDAC_setPhase(obj->pwmDacHandle[cnt],0);

    // setup the Time-Base Counter Register (TBCTR)
    PWMDAC_setCount(obj->pwmDacHandle[cnt],0);

    // Initialize the Time-Base Period Register (TBPRD)
    // set to zero initially
    PWMDAC_setPeriod(obj->pwmDacHandle[cnt],0);

    // initialize the Counter-Compare Control Register (CMPCTL)
    PWMDAC_setLoadMode_CmpA(obj->pwmDacHandle[cnt],PWM_LoadMode_Zero);
    PWMDAC_setLoadMode_CmpB(obj->pwmDacHandle[cnt],PWM_LoadMode_Zero);
    PWMDAC_setShadowMode_CmpA(obj->pwmDacHandle[cnt],PWM_ShadowMode_Shadow);
    PWMDAC_setShadowMode_CmpB(obj->pwmDacHandle[cnt],PWM_ShadowMode_Shadow);

    // Initialize the Action-Qualifier Output A Register (AQCTLA)
    PWMDAC_setActionQual_CntUp_CmpA_PwmA(obj->pwmDacHandle[cnt],PWM_ActionQual_Clear);
    PWMDAC_setActionQual_CntDown_CmpA_PwmA(obj->pwmDacHandle[cnt],PWM_ActionQual_Set);

    // account for EPWM6B
    if(cnt == 0)
    {
    PWMDAC_setActionQual_CntUp_CmpB_PwmB(obj->pwmDacHandle[cnt],PWM_ActionQual_Clear);
    PWMDAC_setActionQual_CntDown_CmpB_PwmB(obj->pwmDacHandle[cnt],PWM_ActionQual_Set);
    }

    // Initialize the Dead-Band Control Register (DBCTL)
    PWMDAC_disableDeadBand(obj->pwmDacHandle[cnt]);

    // Initialize the PWM-Chopper Control Register (PCCTL)
    PWMDAC_disableChopping(obj->pwmDacHandle[cnt]);

    // Initialize the Trip-Zone Control Register (TZSEL)
    PWMDAC_disableTripZones(obj->pwmDacHandle[cnt]);

    // Initialize the Trip-Zone Control Register (TZCTL)
    PWMDAC_setTripZoneState_TZA(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
    PWMDAC_setTripZoneState_TZB(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
    PWMDAC_setTripZoneState_DCAEVT1(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
    PWMDAC_setTripZoneState_DCAEVT2(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
    PWMDAC_setTripZoneState_DCBEVT1(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
    }

    // since the PWM is configured as an up/down counter, the period register is set to one-half
    // of the desired PWM period
    PWMDAC_setPeriod(obj->pwmDacHandle[PWMDAC_Number_1],halfPeriod_cycles); // Set period for both DAC1 and DAC2
    PWMDAC_setPeriod(obj->pwmDacHandle[PWMDAC_Number_2],halfPeriod_cycles);
    PWMDAC_setPeriod(obj->pwmDacHandle[PWMDAC_Number_3],halfPeriod_cycles);

    return;
    } // end of HAL_setupPwmDacs() function

  • The functions in hal.c differed from those in my version of hal.c from my motorWare install. After replacing them, I am now able to control the DAC offsets.

    Thanks for your help.