This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

PWM analyzer / Pulse counter

Is it possible to count pulses with the 51822 from an external device in the range of 250-15.000 pulses pr. second, while the CPU is powered down (softdevice sleep)?

I've had a look at the pwm_analyzer sample, which might do the trick. But I'm not familiar with all the GPIOTE events and tasks. and I'm a little unsure that the resolution is high enough for this purpose. As far as I can tell the example measures both the low and high duty cycles, and firing an interrupt after right after it has measured the high cycle.

I'm not particular interested in generating an interrupt for this reading, as I would rather read the results while the BLE stack is executing to avoid extra wake-up cycles. But according to the example, it seems there is no specific code that restarts the events/task. So I guess it means that they will continuously provide the result to the registers.

Am I totally off here or is there an easier way to simply count the number of pulses from an external device?

Looking at the Timer description in the reference manual, it can also operate in a counter mode triggered by a COUNT task. Is it possible to setup a GPIO pin to trigger that task by a lo-hi transition? This way I can simply read the register whenever the SD is awake and do the frequency calculation based on the time elapsed since last read.

Parents
  • Thanks for your thorough answer, I wasn't aware that the HFClock was needed. What about the LFClock, I have it on board - will this make any difference?

    I only need to measure the frequency (count pulses), and the duty cycle was just an alternative to that, in order to do the measuring in a small window. I could live with a measurement every second, but 5 measures would be optimal.

    Anyhow, I've made a mistake. The pulse input of 250-15000 is actually the number of pulses per minute. So the real figure is 4-250Hz, which is just making the pulse periods longer, and more costly to measure.

    I like your idea in the seconds paragraph, but it would still mean that if I was to measure a 4Hz signal, the TIMER would need to be on for at least 250ms right (@ ~1mA)?

    This would then consume ~0,25 mA at maximum, but only for 1 reading per second. At 4 readings we are back at ~1 mA, so it would probably be easier to just use the Timer as a counter as you mention.

    Well, right now I'll probably start with the counter. Aside from the pwm_analyzer, is there any examples on using a Timer in counter mode?

Reply
  • Thanks for your thorough answer, I wasn't aware that the HFClock was needed. What about the LFClock, I have it on board - will this make any difference?

    I only need to measure the frequency (count pulses), and the duty cycle was just an alternative to that, in order to do the measuring in a small window. I could live with a measurement every second, but 5 measures would be optimal.

    Anyhow, I've made a mistake. The pulse input of 250-15000 is actually the number of pulses per minute. So the real figure is 4-250Hz, which is just making the pulse periods longer, and more costly to measure.

    I like your idea in the seconds paragraph, but it would still mean that if I was to measure a 4Hz signal, the TIMER would need to be on for at least 250ms right (@ ~1mA)?

    This would then consume ~0,25 mA at maximum, but only for 1 reading per second. At 4 readings we are back at ~1 mA, so it would probably be easier to just use the Timer as a counter as you mention.

    Well, right now I'll probably start with the counter. Aside from the pwm_analyzer, is there any examples on using a Timer in counter mode?

Children
No Data
Related