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.

TMDSHVMTRPFCKIT: Speed measurement using eCAP.

Part Number: TMDSHVMTRPFCKIT
Other Parts Discussed in Thread: CONTROLSUITE

Dear TI Hello,

I want to measure the motor speed using CAP-1/Hall-1 already implemented in the TMDSHVMTRPFCKIT,

I am using a laser sensor, I connected the H-1 pin to the positive input '2' and GND to the pin '10',

The issue is even if i change the motor speed the Speed2.SpeedRpm remain unchanged 127!

Is there any other connection or jumpers I have to connect?

Thanks in advance,

Regards,

S.Tarik,

  • Which example are you using? What data type is Speed2.SpeedRpm? 127 is a common value we see at the saturation value for variables of type IQ24. Can you check if this variable is that type?

    Sean

  • Sean,

    I am debugging the Scalar control project of the HVMotorCtrl+PfcKit_v2.1 folder,

    You could find the project in the controlSUITE: C:\ti\controlSUITE\development_kits\HVMotorCtrl+PfcKit_v2.1\HVACI_Scalar,

    Speed2.SpeedRpm is an int32 output r.p.m speed, by default in this project IQ is an IQ24,

    Actually, the speed RPM of my motor is less than 1000rpm, I couldn't figure out why the speed is not calculated,

    In the TI Speed structure we have pu speed and rpm speed, for any speed the two outputs remain unchanged.

    #ifndef __SPEED_PR_H__
    #define __SPEED_PR_H__
    
    typedef struct {
           Uint32 NewTimeStamp;  	// Variable : New 'Timestamp' corresponding to a capture event (Q0) - independently with global Q 
           Uint32 OldTimeStamp;  	// Variable : Old 'Timestamp' corresponding to a capture event (Q0) - independently with global Q 
           Uint32 TimeStamp; 	   	// Input : Current 'Timestamp' corresponding to a capture event (Q0) - independently with global Q 
           Uint32 SpeedScaler;    	// Parameter :  Scaler converting 1/N cycles to a GLOBAL_Q speed (Q0) - independently with global Q
           int32 EventPeriod;    	// Input/Variable :  Event Period (Q0) - independently with global Q
           int16 InputSelect;       // Input : Input selection between TimeStamp (InputSelect=0) and EventPeriod (InputSelect=1)
           _iq Speed;             	// Output :  speed in per-unit
           Uint32 BaseRpm;         	// Parameter : Scaler converting GLOBAL_Q speed to rpm (Q0) speed - independently with global Q
           int32 SpeedRpm;        	// Output : speed in r.p.m. (Q0) - independently with global Q
           } SPEED_MEAS_CAP;       	// Data type created
    
    
    /*-----------------------------------------------------------------------------
    Default initalizer for the SPEED_MEAS_CAP object.
    -----------------------------------------------------------------------------*/                     



    #if (BUILDLEVEL==LEVEL1) // ------------------------------------------------------------------------------ // Connect inputs of the VOLT_PROF module and call the volt profile macro // ------------------------------------------------------------------------------ vhz1.Freq = SpeedRef; VHZ_PROF_MACRO(vhz1); // ------------------------------------------------------------------------------ // Connect inputs of the SVGEN_MF module and call the space-vector gen. macro // ------------------------------------------------------------------------------ svgen_mf1.Gain = vhz1.VoltOut; svgen_mf1.Freq = vhz1.Freq; SVGENMF_MACRO(svgen_mf1); // ------------------------------------------------------------------------------ // Connect inputs of the PWM_DRV module and call the PWM signal generation macro // ------------------------------------------------------------------------------ pwm1.MfuncC1 = svgen_mf1.Ta; pwm1.MfuncC2 = svgen_mf1.Tb; pwm1.MfuncC3 = svgen_mf1.Tc; PWM_MACRO(1,2,3,pwm1) // Calculate the new PWM compare values // ------------------------------------------------------------------------------ // Connect inputs of the PWMDAC module // ------------------------------------------------------------------------------ pwmdac1.MfuncC1 = svgen_mf1.Ta; pwmdac1.MfuncC2 = svgen_mf1.Tb; PWMDAC_MACRO(6,pwmdac1) // PWMDAC 6A, 6B pwmdac1.MfuncC1 = svgen_mf1.Tc; pwmdac1.MfuncC2 = svgen_mf1.Tb-svgen_mf1.Tc; PWMDAC_MACRO(7,pwmdac1) // PWMDAC 7A, 7B // ------------------------------------------------------------------------------ // Call the CAP macro (if sprocket or spur gear used for speed sensing) // Connect inputs of the SPEED_PR module and call the speed calculation macro // ------------------------------------------------------------------------------ CAP_MACRO(1, cap1) if (cap1.CapReturn == 0) // Check the capture return { speed2.EventPeriod = (int32) (cap1.EventPeriod); // Read out new event period SPEED_PR_MACRO(speed2) // Call the speed macro } // ------------------------------------------------------------------------------ // Connect inputs of the DATALOG module // ------------------------------------------------------------------------------ DlogCh1 = (int16)_IQtoIQ15(svgen_mf1.Ta); DlogCh2 = (int16)_IQtoIQ15(svgen_mf1.Tb); DlogCh3 = (int16)_IQtoIQ15(svgen_mf1.Tc); DlogCh4 = (int16)_IQtoIQ15(svgen_mf1.Tb-svgen_mf1.Tc); #endif // (BUILDLEVEL==LEVEL1)

    I am using the eCAP EventPeriod "InputSelect = 1", and I think something is not working/not configured with this module !

    /* ==================================================================================
    File name:        F2803XCAP.H                     
    Target	 : 		  F2803x family              
    =====================================================================================*/
    
    #ifndef __F280X_CAP_H__
    #define __F280X_CAP_H__
    
    #include "f2803xbmsk.h"
    #include "f2803xdrvlib.h"
    
    /*-----------------------------------------------------------------------------
        Initialization states for ECAP Control Registers 1 and 2 for ECAP1
    ------------------------------------------------------------------------------*/
    #define ECCTL1_INIT_STATE   ( CAP1POL_RISING_EDGE +  \
                                  CAPLDEN_ENABLE + \
    							  CTRRST1_DIFFERENCE_TS + \
                                  EVTFLTPS_X_1 + \
                                  EMULATION_FREE  )
    
    #define ECCTL2_INIT_STATE   ( CONTINUOUS_MODE + \
                                  TSCNTSTP_FREE + \
                                  SYNCI_DISABLE + \
                                  SYNCO_DISABLE + \
                                  CAPTURE_MODE )
    
    /*-----------------------------------------------------------------------------
    Define the structure of the Capture Driver Object 
    ------------------------------------------------------------------------------*/
    typedef struct { int32 EventPeriod;    // Output: Timer value difference between two edges detected (Q0) 
                   	 Uint16 CapReturn;
                   } CAPTURE;
    
    /*------------------------------------------------------------------------------
    Default Initializer for the F280X CAPTURE Object
    ------------------------------------------------------------------------------*/
    #define F280XCAP1       {1,0 \
                            }
    
    /*------------------------------------------------------------------------------
    Target Independent Default Initializer CAPTURE Object
    ------------------------------------------------------------------------------*/
    #define CAPTURE_DEFAULTS  F280XCAP1
    
    /*------------------------------------------------------------------------------
    	CAP_INIT & CAP Macro Definitions
    ------------------------------------------------------------------------------*/                                             
    
    #define CAP_INIT_MACRO(n)										\
        /* Init ECAP Control Registers 1 and 2 for ECAP1*/				\
        (*eCAP[n]).ECCTL1.all = ECCTL1_INIT_STATE;						\
        (*eCAP[n]).ECCTL2.all = ECCTL2_INIT_STATE;						\
    
    
    //Make sure that the GPIO configuration is properly done in ...-DevInit_F2803x.c file as shown below\																	\
        EALLOW;                       /* Enable EALLOW */				\
        /* Set up the ECAP1 pin to primary function*/					\
        GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;  /* GPIO24 is ECAP1 */		\
        EDIS;                         /* Disable EALLOW	*/				
    
    	
    	
    #define CAP_MACRO(n,v)																				\
        if((*eCAP[n]).ECFLG.bit.CEVT1 != 0)/* Check status of one entry of first event of ECAP1 pin */		\
        {																									\
        v.EventPeriod = (*eCAP[n]).CAP1;  /* Stamp the timer counter difference between two edges detected*/\
        v.CapReturn=0;                   /* Then, return zero*/												\
        } 																									\
        else																								\
        {																									\
        v.CapReturn=1;                   /* Else, return one */												\
        }
    
    
    #endif //  __F280X_CAP_H__
    

    Regards,

    S.Tarik,

  • SpeedRpm is calculated in the SPEED_PR_MACRO. If you review the code, you can see a division function where the denominator could be zero. You will need to figure out why your denominator is so low. We don't know about the signal integrity of the feedback you use, and how it is received at the CPU pins. You may have to verify these. If possible, use a function generator and verify.
  • We figured out that the eCAP counter doesn't increment,

    The problem was the signal input voltage range coming from the sensor we use to measure the speed, when we use the GBF to output the square wave form everything looks fine,

    We also changed the  SpeedScaler to the suitable value for our application.

    speed2.SpeedScaler = 60*(SYSTEM_FREQUENCY*1000000/(1*x*speed2.BaseRpm));

    Regards,

    S.Tarik,