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-HC-C2-KIT: Need Help to run INSTA_SPIN_BLDC Project with Encoder feedback

Part Number: DRV8301-HC-C2-KIT
Other Parts Discussed in Thread: DRV8301, DRV8302, INSTASPIN-BLDC, CONTROLSUITE

Tool/software: Code Composer Studio

Hello,

    I'm using DRV 8301 HC_EVM devlopment kit with F28035 controller card. I'm using a maxon EC motor as given in the attachment. I successfully executed InstaSpin_BLDC Project. This project is a sensorless control and for my application, I need to control the motor using quadrature encoder. Below was the snippet used in the project (edited level-8) to control the motor using QEP.

#if (BUILDLEVEL==LEVEL8)   //QEP Testing -Teja

    _iq IDCfdbk;

    // ------------------------------------------------------------------------------
    //    ADC conversion and offset adjustment
    //     Not used, reading is taken for debugging
    // ------------------------------------------------------------------------------

    #if defined(DRV8301) || defined(DRV8302)
        IDCfdbk=-((_IQ15toIQ(AdcResult.ADCRESULT4<<3)-IDC_offset)<<1);
    #endif
    // ------------------------------------------------------------------------------
    //    Connect inputs of the IMPULSE module and call the Impulse macro.
    // ------------------------------------------------------------------------------
      impl1.Period = rmp3.Out;
      IMPULSE_MACRO(impl1)
     // ------------------------------------------------------------------------------
    //    Connect inputs of the MOD6 module and call the Modulo 6 counter macro.
   // ------------------------------------------------------------------------------
   if(DfuncStartup > _IQ(0.0))
  {
            mod_dir1.CntDirection = _IQ(1.0);
  }
  else
   {
            mod_dir1.CntDirection = _IQ(-1.0);
   }
    mod_dir1.TrigInput = impl1.Out;
    PreviousState = mod_dir1.Counter;
     MOD6CNTDIR_MACRO(mod_dir1)
     QEP_MACRO(qep1);

    // ------------------------------------------------------------------------------
    //    Connect inputs of the SPEED_FR module and call the speed calculation macro
    // ------------------------------------------------------------------------------
        speed2.ElecTheta = _IQ24toIQ((int32)qep1.ElecTheta);
        speed2.DirectionQep = (int32)(qep1.DirectionQep);

        SPEED_FR_MACRO(speed2)
        // ------------------------------------------------------------------------------
        //    Connect inputs of the RMP3 module and call the Ramp control 3 macro.
       // ------------------------------------------------------------------------------
        rmp3.DesiredInput = CmtnPeriodTarget;
        rmp3.Ramp3Delay = RampDelay;
        RC3_MACRO(rmp3)
            // ------------------------------------------------------------------------------
            //    Connect inputs of the PID_REG3 module and call the PID speed controller
            //    macro.
            // ------------------------------------------------------------------------------
        if ( lsw == TRUE && (SpeedLoopCount >= SpeedLoopPrescaler) )
        {
            pid1_spd.term.Ref = SpeedRef;   //SpeedRef = 0.3
            pid1_spd.term.Fbk = speed2.Speed;
            PID_GR_MACRO(pid1_spd)
            SpeedLoopCount = 1;
        }
        else
        {
             SpeedLoopCount++;
        }
        if ( lsw == FALSE)
        {
             pid1_spd.data.ui = 0;
             pid1_spd.data.i1 = 0;
             SpeedLoopCount = 1;
        }
        // ------------------------------------------------------------------------------
            //    Connect inputs of the PID_REG3 module and call the PID current controller
            //    macro.
            // ------------------------------------------------------------------------------
        pid1_idc.term.Ref = pid1_spd.term.Out;
        pid1_idc.term.Fbk = IDCfdbk;
        PID_GR_MACRO(pid1_idc)

            // ------------------------------------------------------------------------------
            //    Connect inputs of the PWM_DRV module and call the PWM signal generation
            //    update macro.
            // ------------------------------------------------------------------------------
         pwmcntl1.State = (int16)mod_dir1.Counter;
         if( lsw == TRUE)
         {
                pwmcntl1.Duty = pid1_idc.term.Out;
         }
         else
         {
               
               pwmcntl1.Duty = DfuncStartup;
         }
         PWM_CNTL_MACRO(pwmcntl1)
         //------------------------------------------------------------------------------
         //    Connect inputs of the DATALOG module
         // ------------------------------------------------------------------------------
                    DlogCh1 = (int16)mod_dir1.Counter;
                    DlogCh2 = (int16)_IQtoIQ15(qep1.ElecTheta);
                    DlogCh3 = (int16)_IQtoIQ15(qep1.MechTheta);
                    DlogCh4 = (int16)_IQtoIQ15(qep1.DirectionQep);
#endif // (BUILDLEVEL==LEVEL8)

With this code, with EnableFlag = 1 and lsw = 1, the motor is starting and rotating but after 2-3 mins, the motor is accelerating and is getting stopped.

Kindly help me out to run the motor using encoder feedback. Thank you.EN-241.pdf

  • As you know, InstaSPIN-BLDC is a sensorless trapezoidal control technique that doesn't support the encoder sensor, and we don't have such a trapezoidal control example with encoder too.

    There is a sensored-FCO example project with the encoder in controlSUITE, you might take a look at the example project which can be found in the folder.

    \ti\controlSUITE\development_kits\HVMotorCtrl+PfcKit_v2.1\HVPM_Sensored

  • Thanks a lot for the reply. I've been referring to the above mentioned (HVPM_Sensored) example and edited the snippet. With the modifications given (Code above) the motor is rotating but I'm unable to control the motor velocity. The above code, what i've posted uses QEP data to enable the velocity loop and IDCfdbk to enable the current loop. I'm not sure how to obtain the PWM signals to controll the motor.

    Please help me and correct me if I'm wrong with my work (mentioned above).

    Thank you

  • You have to add a function to generate the commutation trigger by using an encoder if InstaSPIN_BLDC() is not used. As mentioned above, we didn't use an encoder sensor for trapezoidal control before, we can't help you to design such function.