harshas123 wrote:Hi Joan,
I tried using the "request Notification" as you suggested using the exact same code provided by you.
Prior to running your code, I generated a 250kHz clock in Pin number 4.
The final file size is 178932636 bytes which translates to 14911053 samples ~ 15 million samples as expected.
For frequencies above 300kHz, the number of samples notified is almost half the number of samples expected.
The notify command only takes notice of changes in the gpio pin. However what I need is to be able to obtain the sample value of 8 GPIO pins @ 250 kHz, even if there is no change in the voltage in those pins.
Additionally, would you please tell me what are the bytes written to the /dev/pigpiox file by the nb command?
That's much better than I would expect.
pigpio works by sampling the GPIO. In the example above you were sampling at 500 thousand times per second. That should reliably detect a 250 kHz clock. See
Nyquist for a probably confusing reason why. You could sample at 1MHz (sudo pigpiod -s1) but I'd only use that
in exceptional circumstances if nothing else worked.
The resulting file is binary. Each sample is 12 bytes long.
Code: Select all
typedef struct
{
uint16_t seqno;
uint16_t flags;
uint32_t tick;
uint32_t level;
} gpioReport_t;
seqno: starts at 0 each time the handle is opened and then increments by one for each report.
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE. If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags indicate a gpio which has had a watchdog timeout; if bit 6 is set (PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the pipe/socket and is sent once a minute in the absence of other notification activity.
tick: the number of microseconds since system boot. It wraps around after 1h12m.
level: indicates the level of each gpio. If bit 1<<x is set then gpio x is high.
You can ignore all the data apart from level.
level is a 32 bit quantity. It gives the level of GPIO 0-31 when the sample was taken. So it has everything you need, just check that the clock bit is 1 (if the trigger is a rising edge) then extract the bits you want.