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/TMS320F28335: CCS/TMS320F28335

Part Number: TMS320F28335
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

I'm using the TMS320F28335 DSP board for PMSM speed control and I tried to implement the encoder part using the eQEP module. 

I want to use the eqep_pos_speed example for reading the sped from the encoder. for testing this example I use jumper wires to connect  GPIO0 and 1 to the EQEP input pins as section of the eqep_pos_speed chapter the F2833x_DEV_USER_GUIDE.pdf. then,  for checking the speed I add "qep_posspeed" to Watch Expression and I set a breakpoint in line 235. the SpeedRpm_pr should be 300 rpm but it shows in watch expression 5 or 6 rpm. Could you please help me with this. I want to check this then I want to connect the encoders output to eQEP to read the speed of the motor.
Thank you very much

  • Hi,

    Have you connected the index signal (EQEPI) at GPIO 4 ? Because the example uses this signal to determine the position and direction of rotation.

    If my reply answers your question please click on "This resolved my issue" button located at the bottom of my post.

    Regards

    Himanshu

  • Hi,

    Yes, I have connected. When I put a breakpoint on line 235, and in breakpoint properties, I change the Action to Refresh All Windows in watch Expression it shows 5 rpm. 

  • Actually, when I set a breakpoint the speed in watch expression is not shown correctly.

    Also, I have another question, if I want to use the speed that calculated from the low-speed calculation in a PI controller. I should use

     p->SpeedRpm_pr

    or 

    qep_posspeed.SpeedRpm_pr

    ??

    I tried to put "qep_posspeed.SpeedRpm_pr" in a variable like a to use it in my calculation and control system but in watch expression, it shows error  Identifore Not Found. SO, I could not see that I have speed or no.

    Thanks

  • Hi,

    The example that you are using is configured for the below system details :

    So please ensure that these hold true for your system as well and if not then make the code changes as per your requirements before running this. Also we have added another example recently for motor speed calculation by using unit timeout interrupt of EQEP, I suggest you check that out as well. You can find this example "eqep_ex5_speed_dir_motor" in the path "C2000Ware_X_X_X_X\driverlib\f2838x\examples\c28x\eqep", although this is not for F2833x device directly but could be good reference to understand the details.

    On your second question, "qep_posspeed.SpeedRpm_pr" should be used if measurement is intended with capture unit.

    If my reply answers your question please click on "This resolved my issue" button located at the bottom of my post.

    Regards

    Himanshu

  • Hi Himanshu,

    Thank you for your continuing support.

    My system information is as follows.

    Encoder: 1024 PPR. pole Pair=4, Base speed 6000 rpm.

    So, I changed the mech_Scaler from 16776 to 16383, from the excel file I change the speed scaler to 92, pole pair to 4. Also, I change the interrupt count to 1024.

    // Defines for the default initializer for the POSSPEED Object.
    //
    #if (CPU_FRQ_150MHZ)
        #define POSSPEED_DEFAULTS {0x0, 0x0,0x0,0x0,0x0,16383,4,0,0x0,\
            92,0,6000,0,\
            0,0,0,\
            (void (*)(long))POSSPEED_Init,\
            (void (*)(long))POSSPEED_Calc }

    and 

    // Every 1024 interrupts(4096 QCLK counts or 1 rev.)
        //
        if (Interrupt_Count==1000)
        {
            EALLOW;
    
            //
            // Pulse Index signal  (1 pulse/rev.)
            //
            GpioDataRegs.GPASET.bit.GPIO4 = 1;
            for (i=0; i<700; i++)
            {
    
            }
            GpioDataRegs.GPACLEAR.bit.GPIO4 = 1;
            Interrupt_Count = 0;                   // Reset count
            EDIS;
        }
    
        //

    Just for double-checking the changes that I made are correct?

    I want to control the PMSM motor so, I need the electrical angle that it is Q15, should I transfer it to Q0 and multiply by 2*pi touse in Clark and Park transformation matrix? 

    I mean I need electrical theta in Rad. Could you please help me with this.  can I do like this

    define a float variable like Elec_theta

    Elec_theta=(qep_posspeed.theta_elec/2^15)*2*pi