Comments (6)
If pigpio used interrupts rather than sampling it would break a lot of functionality.
For instance this view would be impossible https://www.youtube.com/watch?v=Lp7oEj0iAe8
A fundamental problem with gpio interrupts is they are not time-stamped so you have little idea of when they happened. By default pigpio sampling will give relative timings to +/- 10µs, with gpio interrupts you are talking about +/- 100µs and considerably worse on occasion.
There will also be a cross-over point where sampling will use less resources than interrupts. I suggest you do an experiment and see how many gpio interrupts per second are needed before 10-20% CPU is hit.
Also gpio interrupts can't handle changes in rapid succession, anything less than 50µs apart are likely to be missed.
from pigpio.
Thanks for the explanation. Yet I think GPIO interrupts would be a nice extra for the library for not-so-time-critical applications where one could live with -+100µs.
Could eventually a (helper) kernel module provide somewhat accurate time stamps for GPIO interrupts?
from pigpio.
pigpio doesn't stop you using interrupts. I use them myself when I want to compare performance.
If you need quick reaction on the Pi interrupts are great. Typically a one off event will be processed within 50µs rather than the 500µs imposed by the pigpio method of batching of events,
For most applications that reaction time is irrlevant, what is important is knowing the relative time of events with respect to each other.
I don't understand why the kernel doesn't time-stamp events. To me there is no down side. I assume it's because there is no portable clock in current Linux systems to use for the time-stamp.
Apparently LIRC has problems when the system is busy in discriminating the length of 500µs plus times between gpio levels! A suggested solution is to sample 8000 times per second. pigpio samples at a default 200 thousand times per second.
from pigpio.
Thanks for the explanation again. Another option would be for me to further reduce the sampling rate. Is there any easy way to do it? (Haven't looked at the code yet.) 10µs is still "too high" for my application. Is there any reason for not allowing lower sampling rates?
from pigpio.
I wouldn't call it easy, but it is not as hard as it use to be. I used to support using both the 19.2MHz clock and 500MHz clock for timing.
20µs is the obvious first choice. I'll have a look and get a feel for how hard the change will be. I might take several days though.
If you don't need the sampling logic it would be simpler to just make that thread a NOP.
In pthAlertThread change
cycle = (oldSlot/PULSE_PER_CYCLE);
pulse = (oldSlot%PULSE_PER_CYCLE);
stopped = 0;
while (1)
{
to
cycle = (oldSlot/PULSE_PER_CYCLE);
pulse = (oldSlot%PULSE_PER_CYCLE);
stopped = 0;
while(1) sleep(1);
while (1)
{
from pigpio.
OK. Thanks again. Never mind if you don't have the time tough. The library is fine as it is.
I suggest to make the information from this dialog somewhere in a FAQ or such documented for the next one who asks the same questions.
from pigpio.
Related Issues (20)
- Pigpio BB Serial Read CPU Resource vs. RPI version HOT 4
- Is there a way to flush an open gpioSerialRead buffer? HOT 9
- event_callback with 0 bytes
- Issue with pigpio Initialization on Raspberry Pi 5 Model B HOT 1
- Understanding pigpiod command implementation HOT 9
- Glitch filter active while doing bbSerialRead? HOT 3
- SPI Slave - BSCX not consistently working RPi4B HOT 6
- i2c_open() returns the same handle for two devices on the same bus HOT 37
- Scheduling repetitive SPI writes HOT 3
- Isr doesn't work on raspberry os 12.5 HOT 3
- Continuous Wave Program Concept HOT 6
- SPI6 mode 3 HOT 1
- Leave CS low HOT 1
- Pigpio stuck on activating HOT 4
- Adding new functions to the library HOT 2
- Missed packets using RaspberryPi and nRF24L01. HOT 8
- Python 3.11.2 is installed but still getting "Depends: python:any (>= 2.7~) but it is not installable" HOT 2
- gpioSetISRFunc error -123 HOT 1
- setup.py does not work with python 3.12
- libpigpio1 and libpigpio-dev version issue with pigpio
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pigpio.