3

I am new to Raspberry pi. I have an input of continuous pulses. Each pulse width is around 100 nanoseconds . I need to count the pulses for 100 microsecond. Is it possible to do this? Please suggest..

1
2

Probably not.

If you could you would need to write a kernel module. The kernel module would need to handle gpio interrupts.

In userland it takes about 50 µs to be notified of a gpio interrupt. I believe the kernel can record one more before the first is acknowledged. I have no timing for how long it takes to acknowledge the interrupt from userland, I'm going to assume 50 µs. So I believe from userland you count count 0, 1, or 2 pulses in 100 µs.

I'm quite happy to be shown to be wrong.


EDITED TO ADD

I should say it's probably trivial in bare metal. But then you are just using the Pi as a dumb microprocessor. So why not just use a microprocessor?


EDITED TO ADD 2

If you don't want 100% reliability you could use busy loop sampling. If your requirements allow you could sample several 100 µs time slots in succession to get a statistically reliable result. It really depends on the expected pulse patterns as to whether this is sensible.

0

With timings like this, I would never ever use a Pi. Dont even think it will manage what you need reliably.

You'd be WAY better off using an Arduino of some sort. These devices have hardware timers and input pins that actually allow you to measure pulse width or count a number of pulses this tight. Best of all: the software sits idle while the hardware measures, so there is no stressing to handle stuff within a few micro seconds because the next pulse is coming. And even if you have this requirement, The Atmel AVR units which are the heart of Arduino's can cope very well with weird things like this; they have no operating system eating CPU time when you don;t need it; they're simple and completely programmatic.

Not sure how you'd get your data out of the Arduino; you could interface the Arduino with a Pi to do the "high level tricks", or work with a network NIC board on the Arduino... I know there are also Arduino units out there that have (micro)SD card interfaces so you could potentially store your stuff there as well.

0
0

It would be impossible to work at this frequency (10 MHZ) with the raspberry pi.

We benchmarked the raspberry pi 3B and above 20 KHz it's read accuracy gradually drops. At 110 KHz it cannot read anything at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.