This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using PEC to handle frequency inputs.

Currently we use the CAPCOM units to read in frequency inputs. The results are fast and accurate but are quite consumptive of processor resources. For example, moving two frequency inputs from 40 Hz to 1500 Hz results in 5% less processor idle time. I was looking for a method outside of hardware to reduce the consumption to 1%.

We fire an interrupt on the rising edge of the incoming frequency signal. The ISR determines the period of elapsed time from the last interrupt, then generates a value based on the average of the last n periods, rollovers are handled. A timer ISR which fires every 26 mS is used to track rollovers.

If I fired a PEC transfer on the rising edge of the incoming frequency signal, I could fill an array of times. The timer ISR would then be modified to average the array of times and create a frequency value, reset the CC unit and reset the PEC. This would mean that the frequency would be updated only every 26 mS which is acceptable for our application.

Given that the new PEC method would entail parsing an array while the old method did not, I am suspicious that the benefit gained by going to a PEC method would be offset by the use of for loops to process an array of data.

Has anybody tried this before and if so, was the PEC method substantially less consumptive of system resources?

(I have written a PEC method for AD conversions and it was markedly less consumptive.)

Parents
  • Yeah I know. The hardware guy won't go for it though.

    I did go ahead and implement the frequency reading with the PEC controller. What an improvement!! Now at high frequencies there is no observable additional load on processor idle time. In fact, I have more idle time at high frequencies now than I had at low frequencies without the PEC. The reason is simple. Instead of averaging the array of values every 26 ms, I just take the last value and subtract from the first value and divide it by the number of (samples - 1). It works beautifully.

Reply
  • Yeah I know. The hardware guy won't go for it though.

    I did go ahead and implement the frequency reading with the PEC controller. What an improvement!! Now at high frequencies there is no observable additional load on processor idle time. In fact, I have more idle time at high frequencies now than I had at low frequencies without the PEC. The reason is simple. Instead of averaging the array of values every 26 ms, I just take the last value and subtract from the first value and divide it by the number of (samples - 1). It works beautifully.

Children
No data