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.

Problem with ECAP counts being off

I am running the 28335 processor for a motor control application.  The clock is set to 150 MHz.  I have 3 hall sensors feeding into the ECAPs.  I have measured the speed with a tach and the counts from rising edge to rising edge on Hall1 is not matching up to the expected value.  The state is being checked in a 100Khz polling loop (PRD function using DSP BIOS).  My assumption is that each count equates to 1 clock tick of the 150 MHz clock.  Has anyone seen this or is there something wrong with my assumption or implementation?  Below is the initialization  code.

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped
   ECap1Regs.ECCTL1.bit.CAPLDEN = 1;          // Enable CAP1-CAP4 register loads
   ECap1Regs.ECCTL1.bit.CAP1POL = 0;
   ECap1Regs.ECCTL1.bit.CTRRST1 = 1;  
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1;        // Start Counter

 

This is my logic in the polling loop:

   if (ECap1Regs.ECFLG.bit.CEVT1 != 0)
   {
      timeStamp = ECap1Regs.CAP1;

      ECap1Regs.ECCLR.bit.CEVT1 = 1;
   }

  • >each count equates to 1 clock tick of the 150 MHz clock Don't think so. If You poll at 100KHz or at 200 or at 500 - there is no difference. You have to measure in ROTATIONS PER MINUTE. or per second. or per millisecond...... 150MHz clock(is known period) can be used to convert timer ticks(clock ticks) to seconds/minutes and so on.... And remember about Nyquist frequency. Or I have not understood a problem?
  • I want to calculate RPM.  My thought was that the formula would be:

          timeStamp = ECap1Regs.CAP1;
          temp = (float32)(timeStamp) * (1.0/150000000.0) * 3.0;
          if (temp != 0)
          {
             (1.0 / temp) * 60;
          }
          else
          {
             speed = 0;
          }

    There should be 3 rising edges on the 6 pole motor per revolution.

  • I am sorry, seems to be eCAP really counts time in 150 MHz clock periods.
  • I think I can't really help You because I have no sufficient experiense in eCAP using. Sorry.
  • Please remember to consider the number of motor poles when calculating actual motor RPM. The hall sensor outputs are related to electrical frequency.  Here is one way to calculate motor sppeed from Hall frequency

    Suppose one of the hall sensor output is 200Hz for a 4 pole motor.

    In this case two pulses = 1 mechanical revolutaion. Therefore, for 200 Hz

    speed = (200/2) revoluation per second

    Resulting 100*60 = 6000 RPM