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.

TMS320F28379D: LaunchPad

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

I am trying to use the eQEP module for speed and position detection, with the eqep_posspeed example from c2000ware on a Launchpad device. The motor is running from a sensorless algorithm on another microcontroller. I am reading its encoder pulses on the TI board to estimate speed and position. Speed estimation is working fine. The only problem is that electrical theta as observed on oscilloscope is not synchronized to the index. The response is as if no index signal is being received by the board. 

Here is the poss_speed function that i am using (tweaked from the example)

void POSSPEED_Init(void)
{
EQep1Regs.QUPRD = 1000000; // Unit Timer for 100Hz at 100 MHz (CLOCK/fm)
// SYSCLKOUT
EQep1Regs.QDECCTL.bit.QSRC = 00; // QEP quadrature count mode
EQep1Regs.QEPCTL.bit.FREE_SOFT = 2;
EQep1Regs.QEPCTL.bit.PCRM = 00;//00; // PCRM=00 mode - QPOSCNT reset on
// index event
EQep1Regs.QEPCTL.bit.UTE = 1; // Unit Timeout Enable
EQep1Regs.QEPCTL.bit.QCLM = 1; // Latch on unit time out
EQep1Regs.QPOSMAX = 0x1F3F; //7999 = 8000-1 Counts
EQep1Regs.QEPCTL.bit.QPEN = 1; // QEP enable
EQep1Regs.QCAPCTL.bit.UPPS = 5; // 1/32 for unit position
EQep1Regs.QCAPCTL.bit.CCPS = 6; // 1/64 for CAP clock
EQep1Regs.QCAPCTL.bit.CEN = 1; // QEP Capture Enable
}

Also, I see that the code has a portion to check if an index pulse has occurred and if the angle has sychronized to it. 

// Check an index occurrence
//
if(EQep1Regs.QFLG.bit.IEL== 1)//EQep1Regs.QFLG.bit.IEL
{
p->index_sync_flag = 0x00F0; // This number is 240
EQep1Regs.QCLR.bit.IEL = 1; // Clear __interrupt flag
}

I am trying to observe the index_sync_flag in the expressions window but reads zero, indicating that no index pulse has been received (even though the index pulse is being received by the board). I have ensured eQEP GPIO initialization is correct. 

  • Hi Tabish,

    Let me take a look at this issue. Typically when this issue with undetected index is seen, using GPIO qualification on the index signal can assist with ensuring that the index sync is detected. I can provide more debug tips after reviewing this issue in more detail

    Regards,

    Peter

  • Hi Peter,

    Thank you for your response. I really appreciate it. The GPIO initialization is:

    GpioCtrlRegs.GPAPUD.bit.GPIO20 = 1; // Disable pull-up on GPIO20 (EQEP1A)
    GpioCtrlRegs.GPAPUD.bit.GPIO21 = 1; // Disable pull-up on GPIO21 (EQEP1B)
    GpioCtrlRegs.GPAPUD.bit.GPIO22 = 1; // Disable pull-up on GPIO22 (EQEP1S)
    GpioCtrlRegs.GPAPUD.bit.GPIO23 = 1; // Disable pull-up on GPIO23 (EQEP1I)

    GpioCtrlRegs.GPAQSEL2.bit.GPIO20 = 0; // Sync GPIO20 to SYSCLK (EQEP1A)
    GpioCtrlRegs.GPAQSEL2.bit.GPIO21 = 0; // Sync GPIO21 to SYSCLK (EQEP1B)
    GpioCtrlRegs.GPAQSEL2.bit.GPIO22 = 0; // Sync GPIO22 to SYSCLK (EQEP1S)
    GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 0; // Sync GPIO23 to SYSCLK (EQEP1I)


    GpioCtrlRegs.GPAGMUX2.bit.GPIO20 = 0; // 
    GpioCtrlRegs.GPAGMUX2.bit.GPIO21 = 0; // 
    GpioCtrlRegs.GPAGMUX2.bit.GPIO22 = 0; // 
    GpioCtrlRegs.GPAGMUX2.bit.GPIO23 = 0; //

    GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 1; // Configure GPIO20 as EQEP1A
    GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 1; // Configure GPIO21 as EQEP1B
    GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 1; // Configure GPIO22 as EQEP1S
    GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 1; // Configure GPIO23 as EQEP1I

    Even while running the posspeed example exclusively, the controller does not detect the index signal. 

  • I tried GPIO qualification on index pulse. Unfortunately it did not work. Tried all of these individually:

     GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 0;   // Sync GPIO23 to SYSCLK  (EQEP1I)

     GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 1;   // Qualification 3 samples   (EQEP1I)

    GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 2;   // Qualification 6 samples   (EQEP1I)

    GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 3;   // Async 

  • Hi Tabish,

    Would you be able to send scope images of the quadrature signals and index signals going into the MCU? If the index signal recognition is not improved with qualification, then most likely this is an eQEP configuration issue or something to do with hardware.

    I reviewed the configuration you sent initially and it doesn't look like you have changed any major eQEP settings which would break the example. Would you you be able to run the DriverLib based example located at 

    [C2000WARE]\driverlib\f2837xd\examples\cpu1\eqep

    eqep_ex2_pos_speed should be very similar in functionality to the other example you were using

    Regards,

    Peter

  • Hi Peter, 

    Thank you for your response. I started with the configuration that I shared but I did tweak some things (especially IEI, PCRM, IEL) before returning back to this configuration. Nothing seems to work. 

    I am sharing some scope captures for you. The sine wave is the motor current, magenta is the index signal (8 pole motor) and I have also plotted electrical position as calculated by the microcontroller, which is not aligned with the index signal. As you can see, everytime the code is reset, the position count seems to start resetting randomly without synchronizing to the index. 

  • Hi Tabish,

    Thanks for this information. Have you been able to attempt using the other examples provided in the SDK and seeing if those register the index pulse. Additionally, you are using the dedicated eQEP headers located at the bottom of the LaunchPad correct? Can you verify that everything is correctly configured from a hardware standpoint with respect to the index signal? It is strange that you are not getting the index signal. Can you verify what is being shown for the FINF bit in the QEPSTS register?

    Regards,

    Peter

  • Hi Peter,

    Thank you for your response. 

    I tried the driverlib example but i am encountering a number of issues there. That example is not even generating an index pulse (on GPIO2).  The encoder emulation on EPWM1 A and B is working fine. I haven't worked with driverlib before so I am not sure what's wrong with index generation on GPIO2. Perhaps there are some issues with initialization/configuration of GPIO2. I tried connecting the index pin of the encoder (of a spinning motor) to the eQEP header but even then driver lib example does not detect an index as the EQep1Regs.QPOSILAT is maintained at zero. 

    I think everything is sound from the hardware perspective. Yes, I am using the dedicated header for eQEP1 ie. J14 at the bottom. The encoder pulses are 5 V amplitude (which the header supports), and speed and direction estimation through signals A and B is correct even during start up. The only concern is the recognition of/alignment with the index signal. 

    I checked the FIMF bit. It is zero.

    I personally feel there is a setup/configuration issue.

    Best, 

    Tabish

  • Hi Tabish,

    Thank you for confirming that everything is connected correctly from a hardware perspective. You are correct, it is most likely a configuration issue. You mentioned tweaking a few settings previously regarding PCRM, IEI, and IEL. What changes did you tweak? The IEL bit configures the software index trigger but since you are in PCRM=00 mode, this bit is ignored. Can you try changing the PCRM=10 and then manually setting this software index trigger bit within the QEP control register? This should configure the index event to latch the position counter. 

    EQep1Regs.QEPCTL.bit.IEL = 1

    You may also try setting this IEL bit to configure the index event to signal the beginning of counting on the position counter

    EQep1Regs.QEPCTL.bit.IEI = 2

    I believe you may have done this already but I'm not sure why you are not getting an index signal registered, judging the by the FINF bit. Do you have an additional encoder that you can swap out or switch to another LaunchPad?

    Regards,

    Peter

  • Hi Peter. I think I found a solution. The launch pad perhaps routes eqep1 index to GPIO 99. There's a discussion on the TI forum on this:

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/910790/ccs-tms320f28379d-f28379-eqep-pos-speed-example-not-registering-index#3374281

    I will try this as soon as I can but I am hoping this should work. Also I have tried all possible combinations of PCRM and IEL.

  • Hi Tabish,

    I think that may be the solution to your issue. Apologies for not checking the LaunchPad pin out to doublecheck. Yes the software example is configured default to run on the controlCARD, which is why the GPIOs are assigned as such. 

    I believe on the newer example I sent you, there is an option to directly switch the GPIOs to be configured directly for the LaunchPad as opposed to the controlCARD. The old bitfield examples do not have this capability and so the GPIOs must manually be changed

    Regards,

    Peter

  • Hi Peter,

    Yes it did work! Thank you for all your help

    Best regards, 

    Tabish