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.

RM44L920: eCAP module random spike of data while measuring wheel speed

Part Number: RM44L920

I am using eCAP module to get wheel speed , by looking in the data i could see random frequent data spike even we areRC filter and low pass filter in algorithm.here i am using eCAP with interrupt.I am attaching my code.

eCAP register 4 is used and eCAP interrupt evt1 & evt4 are enabled. i am using 4 eCAP pulse to calculate speed.Do we need to clear the overflow of the eCAP counter? , do we need to use FIQ for eCAP? as i am also using RTI along with it for every 25 ms.

void calculate_speed()
{      

          volatile uint32 temp1, temp2,temp21,temp22;
          temp1 = c1;
          temp2 = c4;
                    if(temp2>temp1)
                   {
                       T = temp2 - temp1;
                       fwspeed =(1308.3*180.00*100.00)/T;  //Rad/sec
                    }

}

void ecapNotification(ecapBASE_t *ecap, uint16 flags)
{
    if(ecap == ecapREG4){
    count++;
    if(count%2 == 1)
    {
        c1 = ecapGetCAP1(ecapREG4);
        pulsesf++;
        flag = 0;
    }
    else if(count%2 == 0)
    {
        c4 = ecapGetCAP4(ecapREG4);
        count = 0;
        flag = 1;
    }

}
}

int main(){

 _enable_interrupt_();
    _enable_IRQ();

ecapInit();

while(1){

        if(flag==1){
            _disable_IRQ();
            calculate_speed();
            _enable_IRQ();
        }

}

  • I also add the data spike graph.

    you could see at some place at 50 the data is spiking at some places.

  • Hi Karthik,

    How does the input signal look like? Is there noise spike in the ecap input signal which is not filtered out?

    You don't have to enable interrupt for both EVT1 and EVT4. Enabling the EVT4 interrupt is good enough. 

    You use Absolute Time-Stamp mode, can you try Time Difference (Delta) mode which resets the counters at event edge?

  • Hi Wang,

    Yes, Now i am using only EVT4 alone and capturing four cap values , even though we are using RC filter to filter out the noise yet the capture values seems to be unusable eg;(c1 & c2 values are same) , (C1 value time capture is quicker than expected) at these situation we could see the spike in the data, if we filter out these conditions we able to get descent data.But I need to utilize every pulses.

  • Hi,

    The eCAP module supports reset feature: the 32-bit counter can be reset on any of the four event loads. In you application case, the counter should be reset at event1, event2 and event3. I suggest to reset the counters on event 4. Enabling the reset feature will avoid the counter overflow issue.

        ecapREG4->ECCTL1 =   ((uint16)((uint16)RISING_EDGE << 0U) /* Capture Event 1 Polarity */
                                               | (uint16)((uint16)RESET_DISABLE << 1U) /* Counter Reset on Capture Event 1 */
                                               | (uint16)((uint16)RISING_EDGE << 2U) /* Capture Event 2 Polarity */
                                               | (uint16)((uint16)RESET_DISABLE << 3U) /* Counter Reset on Capture Event 2 */
                                               | (uint16)((uint16)RISING_EDGE << 4U) /* Capture Event 3 Polarity */
                                               | (uint16)((uint16)RESET_DISABLE << 5U) /* Counter Reset on Capture Event 3 */
                                               | (uint16)((uint16)RISING_EDGE << 6U) /* Capture Event 4 Polarity */
                                               | (uint16)((uint16)RESET_ENABLE << 7U) /* Counter Reset on Capture Event 4 */
                                               | (uint16)((uint16)0U << 8U) /* Enable/Disable loading on a capture event */
                                               | (uint16)((uint16)0U << 9U)); /* Setup Event Filter prescale */

    If the counter is reset at every events, you may get the same captured value at event 1 and event 4.