joan2937 / pigpio

pigpio is a C library for the Raspberry which allows control of the General Purpose Input Outputs (GPIO).
The Unlicense
1.45k stars 406 forks source link

State changes not being detected with notifications #52

Closed fivdi closed 8 years ago

fivdi commented 8 years ago

While testing the pigpio Node.js module I noticed that state changes don't always appear to be detected by the notification mechanisms provided by the pigpio C library. Similar issues can be seen when the pigpio C library is used directly, i.e., without the Node.js module.

Here is how the test was performed with the pigpio C library.

The following program was run on an ATmega328P clocked at 8 Mhz. The program generates generates 50000 pulses or 100000 state changes on PB1 of the ATmega. The pulses are approximately 8 microseconds wide with a 50% duty cycle. After generating the pulses, the program waits 5 seconds before repeating the same thing again.

/*
avr-gcc -Wall -c -g -Os -mmcu=atmega328p -DF_CPU=8000000UL pulse.c
avr-gcc -g -mmcu=atmega328p -o pulse.elf pulse.o
avr-objcopy -j .text -j .data -O ihex pulse.elf pulse.hex
sudo avrdude -c dragon_isp -P usb -p m328p -e -U flash:w:pulse.hex
*/

#include <avr/io.h>
#include <avr/power.h>
#include <util/delay.h>

#define LED PB0
#define LED_DDR DDRB
#define LED_PORT PORTB

#define PULSE PB1
#define PULSE_DDR DDRB
#define PULSE_PORT PORTB

#define DELAYTIME 4

#define setBit(sfr, bit) (_SFR_BYTE(sfr) |= (1 << bit))
#define clearBit(sfr, bit) (_SFR_BYTE(sfr) &= ~(1 << bit))
#define toggleBit(sfr, bit) (_SFR_BYTE(sfr) ^= (1 << bit))

int main(void) {
  uint32_t i;

  clock_prescale_set(clock_div_1); // 8Mhz clock

  setBit(LED_DDR, LED); // configure LED pin as an output
  setBit(PULSE_DDR, PULSE); // configure PULSE pin as an output

  while (1) {
    setBit(LED_PORT, LED); // LED on

    for (i = 0; i != 50000; ++i) {
      setBit(PULSE_PORT, PULSE); // PULSE high
      _delay_us(DELAYTIME);

      clearBit(PULSE_PORT, PULSE); // PULSE low
      _delay_us(DELAYTIME);
    }

    clearBit(LED_PORT, LED); // LED off

    _delay_ms(5000);
  }

  return (0);
}

PB1 on the ATmega328P is connected to GPIO18 on a Raspberry Pi 3. The following program is run on the Pi. It simply counts the number of state changes on GPIO18 and prints the number of state changes detected once per second.

// gcc -o pulsein pulsein.c -lpigpio -lpthread -lrt

#include <fcntl.h>
#include <stdio.h>
#include <pigpio.h>

#define PULSE_GPIO 18
#define BUF_SIZE 1000

static uint32_t notificationCount = 0;

void timerFunc(void) {
  printf("%u\n", notificationCount);
}

int main() {
  int version;
  int handle;
  char pipePath[32];
  int fd;
  int bytes;
  gpioReport_t r[BUF_SIZE];
  uint16_t lastSeqno = 0xffff;
  int entries;
  int i;

  gpioCfgClock(1, 1, 1);

  if ((version = gpioInitialise()) < 0) {
    printf("gpioInitialise error\n");
    return -1;
  }

  printf("version: %d\n", version);

  if (gpioSetTimerFunc(0, 2000, timerFunc) < 0) {
    printf("gpioSetTimerFunc error\n");
  }

  if ((handle = gpioNotifyOpen()) < 0) {
    printf("gpioNotifyOpen error\n");
    return -1;
  }

  if (gpioNotifyBegin(handle, (1 << PULSE_GPIO)) < 0) {
    printf("gpioNotifyBegin error\n");
    return -1;
  }

  sprintf(pipePath, "/dev/pigpio%d", handle);

  if ((fd = open(pipePath, O_RDONLY)) < 0) {
    printf("open error\n");
    return -1;
  }

  for (;;) {
    bytes = read(fd, r, 12 * BUF_SIZE);

    if (bytes <= 0) {
      printf("read error\n");
      return -1;
    }

    entries = bytes / 12;

    if (entries * 12 != bytes) {
      printf("Oops partial entries are not handled");
      return -1;
    }

    for (i = 0; i != entries; ++i) {
      ++notificationCount;

      if (((uint16_t) (lastSeqno + 1)) != r[i].seqno) {
        printf("  sequence error - lastSeqno: %d, seqno: %d\n", lastSeqno, r[i].seqno);
        printf("    %d\n", notificationCount);
      }

      lastSeqno = r[i].seqno;
    }
  }

  gpioTerminate();

  return 0;
}

Here is an example of typical console output on the Pi. As can be seen, some state changes are not detected. In this particular test run sometimes 4 and sometimes 2 state changes were not detected for batches of 100000 state changes.

root@raspberrypi:/home/pi/pigpioc# ./pulsein 
version: 47
100000
100000
199996
199996
199996
299994
299994
299994
399990
399990
499986
499986
499986
599982
599982
599982
699978
699978
799974
799974
799974
899970

Note that it's not essential to generate batches of 50000 pulses to see the issue. It can also be seen with less pulses, but it can take longer to reproduce the issue.

The question is, is this to be expected or is there a problem that needs to be fixed?

joan2937 commented 8 years ago

Do you have disable_pvt=1 in your /boot/config.txt?

The Pi GPU stalls the DMA for a fraction of a second twice per second to temperature correct RAM refresh rates. That might be a factor.

fivdi commented 8 years ago

Thanks for the feedback :)

No, disable_pvt=1 wasn't in /boot/config.txt but adding it does improve things.

Below is some output from the test program with disable_pvt=1 in /boot/config.txt. Here are some notes describing the output::

root@raspberrypi:/home/pi/pigpioc# ./pulsein 
version: 47
2            <- The two unauthentic state changes
100002
100002
182688
200002
200002
300002
300002
300002
400002
400002
486283
500002
500002
600002
600002
600002
700002
700002
791612
800002
800002
900002
900002
900002
1000002
1000002
1092226
1100002 <- No concurrent activity in other processes up to and including here.
1100002 
1199998 <- Concurrent activity in other processes started while detecting state changes counted here
1199998
1199998
1299998
1299998
1393830
1399994
1399994
1499990
1499990
1499990
1599986
1599986
1698847
1699982
1699982 
1799974 <- last batch counted where there was concurrent activity in other processes
1799974
1799974
1899974
1899974
1999974
1999974
1999974
2099974
2099974
2099974
2199974
2199974
2299974
2299974
2299974
2399974
2399974
2399974
2499974
2499974
2599974
2599974
2599974
2699974
2699974
2699974
2799974
2799974
2899974
2899974
2899974
2999974
2999974
2999974
3099974
3099974
3199974
3199974
3199974
3299974
3299974
3299974
3399974
3399974
3499974
3499974
3499974
3599974
3599974
joan2937 commented 8 years ago

I get similar results when I test between a Pi2B generating the pulses and a Pi3B receiving.

I used your code with a slight modification to only show the final count and GPIO 13.

/*
issue52.c

gcc -Wall -pthread -o 52 issue52.c -lpigpio
*/

#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

#include <pigpio.h>

#define PULSE_GPIO 13
#define BUF_SIZE 1000

static uint32_t notificationCount = 0;

void timerFunc(void) {
  static int s_same=0, s_oldcount = 0;
  if (s_oldcount == notificationCount)
  {
    if (++s_same > 2)
    {
       s_same = -1000;
       if (s_oldcount) printf("%u\n", notificationCount);
       notificationCount = 0;
    }
  }
  else
  {
    s_oldcount = notificationCount;
    s_same = 0;
  }
}

int main() {
  int version;
  int handle;
  char pipePath[32];
  int fd;
  int bytes;
  gpioReport_t r[BUF_SIZE];
  uint16_t lastSeqno = 0xffff;
  int entries;
  int i;

  gpioCfgDMAchannels(6, 14);
  gpioCfgClock(1, 1, 1);

  if ((version = gpioInitialise()) < 0) {
    printf("gpioInitialise error\n");
    return -1;
  }

  printf("version: %d\n", version);

  if (gpioSetTimerFunc(0, 2000, timerFunc) < 0) {
    printf("gpioSetTimerFunc error\n");
  }

  if ((handle = gpioNotifyOpen()) < 0) {
    printf("gpioNotifyOpen error\n");
    return -1;
  }

  if (gpioNotifyBegin(handle, (1 << PULSE_GPIO)) < 0) {
    printf("gpioNotifyBegin error\n");
    return -1;
  }

  sprintf(pipePath, "/dev/pigpio%d", handle);

  if ((fd = open(pipePath, O_RDONLY)) < 0) {
    printf("open error\n");
    return -1;
  }

  for (;;) {
    bytes = read(fd, r, 12 * BUF_SIZE);

    if (bytes <= 0) {
      printf("read error\n");
      return -1;
    }

    entries = bytes / 12;

    if (entries * 12 != bytes) {
      printf("Oops partial entries are not handled");
      return -1;
    }

    for (i = 0; i != entries; ++i) {
      ++notificationCount;

      if (((uint16_t) (lastSeqno + 1)) != r[i].seqno) {
        printf("  sequence error - lastSeqno: %d, seqno: %d\n", lastSeqno, r[i].seqno);
        printf("    %d\n", notificationCount);
      }

      lastSeqno = r[i].seqno;
    }
  }

  gpioTerminate();

  return 0;
}

I used wave chains to generate known test data.

#!/usr/bin/env python

import time
import pigpio

GPIO=13

pi = pigpio.pi()
if not pi.connected:
   exit(0)

pi.wave_clear()

bit = 1<<GPIO
pi.set_mode(GPIO, pigpio.OUTPUT)

wid = []

for d1 in range (5, 11):
   for d2 in range (d1, d1+2):
      pi.wave_add_generic(
              [pigpio.pulse(bit, 0, d1), pigpio.pulse(0, bit, d2)])
      wid.append(pi.wave_create())

for w in wid:
   for i in range(5):
      print(w, i)
      pi.wave_chain([255, 0, 255, 0, w, 255, 1, 0x88, 0x13, 255, 1, 100, 0])
      time.sleep(20)

pi.stop()

The wave chain repeats the given wave 100 * 0x1388 = 100 * 5000 = 500 thousand times of on and off.

I did the tests at 1µs and 2µs sampling rates.

    id on off
Wave 0 5 5
Wave 1 5 6
Wave 2 6 6
Wave 3 6 7
Wave 4 7 7
Wave 5 7 8
Wave 6 8 8
Wave 7 8 9
Wave 8 9 9
Wave 9 9 10
Wave 10 10 10

Formatted results are

1 µs sampling

0 998410 998208 998044 998458 998316

1 998424 998636 998368 998160 998552

2 999224 999424 999452 999302 999456

3 999384 999370 999340 999480 999400

4 999758 999704 999698 999780 999730

5 999680 999790 999744 999740 999826

6 999998 999992 999988 999996 999986

7 999994 999996 999994 999998 1000000

8 1000000 1000000 1000000 1000000 1000000

9 1000000 1000000 1000000 1000000 1000000

10 1000000 1000000 1000000 1000000 1000000

2 µs sampling

0 792716 802156 863096 831020 815168

1 804792 819990 814750 813048 816620

2 978564 975792 977438 977336 978790

3 977512 976994 978974 977506 976588

4 983148 982384 984358 983734 982128

5 982366 981744 983254 981318 982646

6 994488 995462 994556 995320 994132

7 993820 994240 995564 994824 994536

8 999382 999544 999384 999552 999400

9 999422 999428 999382 999466 999524

10 999750 999754 999752 999764 999674

Clearly there is an issue at these rates and pulse lengths. I don't fully understand what is going on and am not sure if there is any solution.

fivdi commented 8 years ago

I haven't performed any tests yet, but do you think the issue will only occur at these rates and pulse lengths or will it also occur at low rates and higher pulse lengths but perhaps less often?

fivdi commented 8 years ago

I performed a few more test. The output below is for a pulse width of 20μs and a pulse period of 40μs. 12500 pulses or 25000 state changes are generated on the ATmega328P. The sampling rate was set to 5μs and pigpio was configured to buffer 2000 milliseconds of GPIO samples. /boot/config.txt contained disable_pvt=1. 10 Node.js processes that executed an empty infinite loop were running.

  ...
  gpioCfgClock(5, 1, 1);

  if (gpioCfgBufferSize(2000)) {
    printf("gpioCfgBufferSize error\n");
    return -1;
  }
  ...
version: 47
2
24998
24998
27134
49996
49996
74996
74996
74996
99992
99992
99992
124986
124986
149986
149986
149986
174986
174986
174986
199984
199984
218617
224984
224984
249984
249984
249984
274984
274984
286660
299984
299984
324982
324982
324982
349978
349978
354700
374976
374976
399974
joan2937 commented 8 years ago

I did 20 µs on 40 µs off x one million from a Pi2B to a Pi3B sampling at 5 µs.

Pi2B $ pigs wvclr $ pigs wvag $((1<<13)) 0 20 0 $((1<<13)) 40 2 $ pigs wvcre 0 $ pigs wvcha 255 0 255 0 0 255 1 0x88 0x13 255 1 100 0

I changed the output slightly to record the gap between successive reports (in a perfect world you'd expect 500k at 20 and 500k at 40).

1000000 5=138 9=11 10=9239 11=14 14=819 15=338179 16=841 19=428 20=149906 21=425 39=999 40=148792 41=959 44=2274 45=335218 46=2366 49=70 50=9108 51=72 55=42 60=18 64=1 65=74 66=1 70=4 71=1 99=1 1000000 5=130 6=1 9=10 10=8156 11=16 14=770 15=320783 16=808 19=508 20=168249 21=567 25=1 30=1 35=1 39=1118 40=167151 41=1061 44=2179 45=317961 46=2209 49=62 50=8060 51=60 55=36 56=2 60=21 61=1 64=3 65=70 66=2 70=2 99=1 999998 5=127 9=18 10=8525 11=16 14=832 15=332914 16=853 19=457 20=155787 21=469 30=1 35=1 39=1074 40=154562 41=1088 44=2211 45=330118 46=2246 49=52 50=8463 51=49 55=32 56=2 60=20 64=3 65=71 66=1 70=4 99=2 999996 5=124 9=15 10=7801 11=19 14=770 15=332204 16=752 19=503 20=157309 21=501 39=1069 40=156118 41=1129 44=2189 45=329316 46=2211 49=62 50=7699 51=72 54=1 55=32 60=23 65=68 66=2 70=4 99=3 999998 5=133 9=7 10=6966 11=11 14=784 15=321694 16=800 19=563 20=168509 21=532 39=1160 40=167201 41=1221 44=2108 45=319085 46=2125 49=40 50=6873 51=49 55=36 56=1 60=19 65=76 70=3 99=2 1000000 5=137 9=19 10=11301 11=21 14=880 15=351484 16=897 19=370 20=134499 21=392 39=895 40=133446 41=906 44=2402 45=348461 46=2426 49=79 50=11159 51=80 55=46 60=20 65=73 70=6 99=1 999998 5=126 9=18 10=7309 11=17 14=738 15=290830 16=796 19=579 20=199017 21=567 25=1 30=2 39=1265 40=197577 41=1332 44=1988 45=288387 46=1963 49=59 50=7249 51=50 55=27 60=14 64=2 65=77 66=1 70=5 99=2 999998 5=131 9=14 10=9098 11=15 14=870 15=365127 16=875 19=349 20=123142 21=378 39=850 40=122158 41=879 44=2506 45=361810 46=2518 49=56 50=9026 51=57 55=39 60=15 64=2 65=76 66=2 70=3 99=2 999998 5=125 9=17 10=7300 11=11 14=811 15=343893 16=847 19=413 20=146152 21=430 39=980 40=145007 41=1005 44=2385 45=340769 46=2400 49=61 50=7215 51=49 55=27 56=1 60=12 65=80 66=1 70=4 75=1 99=2 999998 5=127 9=12 10=7453 11=16 14=809 15=335195 16=796 19=439 20=154715 21=437 39=1069 40=153441 41=1080 44=2194 45=332355 46=2251 49=37 50=7382 51=59 55=31 60=18 64=2 65=75 70=3 99=2 1000000 4=1 5=128 6=1 9=17 10=7778 11=11 14=816 15=361475 16=862 19=403 20=128133 21=375 39=876 40=127102 41=927 44=2444 45=358271 46=2446 49=58 50=7668 51=73 54=1 55=33 60=17 64=2 65=79 70=2 99=1

joan2937 commented 8 years ago

I've done a few more tests and I'm coming to the conclusion there isn't much wrong. I just feel we are pushing against the electronic limits.

I think the spurious pulses were simply because you were counting keep alive signals which are sent on the pipe every minute in the absence of other traffic.

Looking at the event times I can see that there appear to be signal rise and fall times which need to be taken into account. E.g. if on 5 off 5 is sent it might end up as on 2 off 8 by the time it has travelled over the wires. This can sends the pulses outside the sampling envelope.

If you get a chance try the following code (it takes the GPIO as an optional argument, default 12). It records the pulse times and ignores keep alive signals.

/*
issue52.c

gcc -Wall -pthread -o 52 issue52.c -lpigpio
*/

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <pigpio.h>

#define PULSE_GPIO 12

static int pulse_gpio = PULSE_GPIO;

#define BUF_SIZE 1000

static uint32_t notificationCount = 0;
static int notFirstReport = 0;

#define DIFFS 200
#define HALF (DIFFS/2)

int diffs[DIFFS];

void timerFunc(void)
{
   static int s_same=0, s_oldcount = 0;
   int i;
   if (s_oldcount == notificationCount)
   {
      if (++s_same > 2)
      {
         s_same = -1000;
         if (s_oldcount)
         {
            printf("%u\n", notificationCount);
            for (i=0; i<DIFFS; i++)
            {
               if (diffs[i])
               {
                  printf("%d=%d ", i-HALF, diffs[i]);
                  diffs[i] = 0;
               }
            }
            printf("\n");
         }
         notificationCount = 0;
         notFirstReport = 0;
      }
   }
   else
   {
      s_oldcount = notificationCount;
      s_same = 0;
   }
}

int main(int argc, char *argv[])
{
   int version;
   int handle;
   char pipePath[32];
   int fd;
   int bytes;
   gpioReport_t r[BUF_SIZE];
   uint16_t lastSeqno = 0xffff;
   uint32_t lastTick = 0;
   int tickDiff;
   int entries;
   int i;

   if (argc > 1) pulse_gpio = atoi(argv[1]);

   //gpioCfgDMAchannels(6, 14);
   gpioCfgClock(1, 1, 1);

   if ((version = gpioInitialise()) < 0)
   {
      printf("gpioInitialise error\n");
      return -1;
   }

   gpioSetMode(pulse_gpio, PI_INPUT);

   printf("version: %d GPIO=%d\n", version, pulse_gpio);

   if (gpioSetTimerFunc(0, 1000, timerFunc) < 0)
   {
      printf("gpioSetTimerFunc error\n");
   }

   if ((handle = gpioNotifyOpen()) < 0)
   {
      printf("gpioNotifyOpen error\n");
      return -1;
   }

   if (gpioNotifyBegin(handle, (1 << pulse_gpio)) < 0)
   {
      printf("gpioNotifyBegin error\n");
      return -1;
   }

   sprintf(pipePath, "/dev/pigpio%d", handle);

   if ((fd = open(pipePath, O_RDONLY)) < 0)
   {
      printf("open error\n");
      return -1;
   }

   for (;;)
   {
      bytes = read(fd, r, 12 * BUF_SIZE);

      if (bytes <= 0)
      {
         printf("read error\n");
         return -1;
      }

      entries = bytes / 12;

      if (entries * 12 != bytes)
      {
         printf("Oops partial entries are not handled");
         return -1;
      }

      for (i = 0; i != entries; ++i)
      {
         if (r[i].flags)
         {
             /* Ignore watchdogs and keep alives. */
            lastSeqno = r[i].seqno;
            break;
         }

         ++notificationCount;

         if (notFirstReport)
         {
            tickDiff = (r[i].tick - lastTick) + HALF;
            if (tickDiff < 0) diffs[0]++;
            else if (tickDiff >= DIFFS) diffs[DIFFS-1]++;
            else diffs[tickDiff]++;
         }
         else notFirstReport = 1;

         lastTick = r[i].tick;

         if (((uint16_t) (lastSeqno + 1)) != r[i].seqno)
         {
            printf("  sequence error - lastSeqno: %d, seqno: %d\n",
               lastSeqno, r[i].seqno);
            printf("    %d\n", notificationCount);
         }

         lastSeqno = r[i].seqno;
      }
   }

   gpioTerminate();

   return 0;
}
fivdi commented 8 years ago

I think the spurious pulses were simply because you were counting keep alive signals which are sent on the pipe every minute in the absence of other traffic.

The spurious pulses were seen within two seconds of program start. My interpretation of the documentation for gpioNotifyBegin is that keep alive signals will not be seen during the first minute of program execution, even if there is no activity. Is this interpretation correct? I'll do some more tests that take this into account, for example, with the last test program you posted above.

Looking at the event times I can see that there appear to be signal rise and fall times which need to be taken into account. E.g. if on 5 off 5 is sent it might end up as on 2 off 8 by the time it has travelled over the wires. This can sends the pulses outside the sampling envelope.

I'm not sure about this and would expect the signal rise and fall times to be in the nanoseconds region on an ATmega328P. That being said, I can't find the corresponding figures for GPIO ports in the ATmega328P datasheet. For TWI the rise time for both SDA and SCL is max. 300 nanoseconds. For TWI the output fall time is max. 250 nanoseconds. For SPI rise/fall time is 3.6 nanoseconds.

If you get a chance try the following code (it takes the GPIO as an optional argument, default 12). It records the pulse times and ignores keep alive signals.

Will do.

joan2937 commented 8 years ago

Yes, I'm probably wrong about blaming the electronics and rise/fall times being a factor. I said that because I used a TI Launchpad to do what you were doing and there is a definite discrepancy between low and high edges for equal lengths. I checked with one of those Saleae logic analyser USB dongles at 24 MHz sampling. The Launchpad uses the Energia environment which is a clone of the Arduino IDE.

I haven't seen any spurious edges once I remembered to ignore keep alive reports.

fivdi commented 8 years ago

I did two tests with the test program you provided above and the ATmega328P.

The first test was with 20 µs on 40 µs off 500000 times. Here's the output:

version: 47 GPIO=18 999976 1=1 3=8 4=8 5=6 6=9 7=5 8=5 9=4 10=8 11=8 12=7 13=7 14=6 15=6 16=8 17=7 18=1311 19=143918 20=348169 21=6338 22=33 23=23 24=14 25=23 26=17 27=13 28=15 29=10 30=17 31=20 32=18 33=16 34=22 35=18 36=19 37=25 38=22 39=5187 40=286320 41=205078 42=3056 43=27 44=10 45=21 46=20 47=12 48=14 49=7 50=10 51=6 52=5 53=3 54=10 55=5 56=5 57=1 58=1 59=1 99=12 999990 1=3 2=9 3=7 4=1 5=3 6=10 7=7 8=13 9=5 10=3 11=4 12=12 13=7 14=10 15=7 16=7 17=4 18=1340 19=150136 20=342372 21=5884 22=36 23=14 24=17 25=22 26=16 27=18 28=12 29=21 30=15 31=23 32=11 33=16 34=25 35=19 36=21 37=19 38=21 39=5609 40=297620 41=193589 42=2834 43=20 44=14 45=16 46=18 47=10 48=11 49=7 50=13 51=8 52=9 53=7 54=11 55=4 56=4 57=4 58=4 59=2 99=5 999990 2=8 3=4 4=4 5=5 6=3 7=2 8=5 9=4 10=6 11=9 12=4 13=5 14=9 15=7 16=8 17=10 18=1321 19=149093 20=343404 21=5922 22=28 23=21 24=21 25=28 26=14 27=16 28=28 29=10 30=15 31=21 32=21 33=16 34=28 35=25 36=25 37=22 38=24 39=5466 40=296291 41=195023 42=2870 43=15 44=19 45=9 46=16 47=11 48=14 49=13 50=9 51=5 52=8 53=4 54=4 55=2 56=4 57=1 58=2 60=2 99=5 999984 1=2 2=7 3=10 4=6 5=7 6=3 7=2 8=5 9=5 10=5 11=6 12=6 13=6 14=7 15=12 16=9 17=3 18=1256 19=143321 20=349036 21=6115 22=28 23=18 24=17 25=13 26=22 27=16 28=23 29=29 30=21 31=25 32=25 33=17 34=18 35=20 36=19 37=14 38=19 39=5034 40=284094 41=207374 42=3148 43=29 44=14 45=14 46=10 47=14 48=9 49=10 50=13 51=6 52=7 53=5 54=3 55=3 56=8 57=3 58=3 59=1 99=8 999984 1=1 2=4 3=6 4=5 5=8 6=4 7=9 8=8 9=7 10=9 11=9 12=7 13=10 14=10 15=11 16=6 17=11 18=1248 19=147751 20=344866 21=5870 22=32 23=16 24=16 25=14 26=12 27=16 28=15 29=21 30=9 31=17 32=13 33=17 34=12 35=18 36=12 37=22 38=29 39=5287 40=294506 41=196958 42=2909 43=24 44=14 45=15 46=15 47=11 48=14 49=12 50=11 51=9 52=6 53=9 54=12 55=6 56=2 57=2 58=1 59=1 99=8 999988 1=2 2=7 3=5 4=7 5=5 6=6 7=6 8=5 9=4 10=8 11=6 12=8 13=3 14=11 15=11 16=8 17=6 18=1252 19=143782 20=348439 21=6257 22=40 23=24 24=18 25=15 26=16 27=12 28=17 29=17 30=19 31=16 32=11 33=23 34=14 35=19 36=22 37=23 38=30 39=5077 40=285018 41=206467 42=3092 43=25 44=13 45=15 46=18 47=9 48=9 49=11 50=9 51=9 52=5 53=7 54=2 55=6 56=10 58=2 59=3 99=6 999988 1=3 2=3 3=10 4=3 5=5 6=3 7=6 8=5 9=4 10=11 11=9 12=9 13=10 14=4 15=9 16=6 17=7 18=1304 19=142394 20=349812 21=6217 22=33 23=22 24=19 25=21 26=18 27=16 28=10 29=24 30=26 31=15 32=13 33=13 34=23 35=16 36=21 37=24 38=20 39=5010 40=284040 41=207426 42=3166 43=34 44=28 45=9 46=14 47=11 48=21 49=10 50=8 51=5 52=13 53=6 54=4 55=1 56=3 57=2 59=1 63=1 99=6 999990 1=2 2=7 3=5 4=8 5=6 6=10 7=3 8=5 9=8 10=5 11=6 12=4 13=6 14=7 15=6 16=5 17=9 18=1278 19=142501 20=349722 21=6221 22=39 23=24 24=21 25=13 26=19 27=18 28=19 29=16 30=21 31=19 32=21 33=22 34=11 35=17 36=33 37=23 38=29 39=5010 40=282340 41=209115 42=3189 43=17 44=12 45=14 46=18 47=5 48=11 49=6 50=8 51=12 52=5 53=10 54=5 55=5 56=6 57=2 58=3 59=2 99=5 999982 1=3 2=3 3=5 4=3 5=6 6=4 7=4 8=6 9=5 10=7 11=4 12=5 13=8 14=9 15=9 16=10 17=11 18=1122 19=130409 20=361237 21=6962 22=36 23=23 24=23 25=20 26=16 27=12 28=17 29=15 30=15 31=18 32=14 33=21 34=22 35=16 36=32 37=19 38=19 39=4178 40=257976 41=233947 42=3545 43=32 44=17 45=20 46=11 47=10 48=6 49=11 50=9 51=6 52=9 53=6 54=6 55=4 56=1 57=4 58=2 59=2 99=9 999988 2=2 3=5 4=3 5=5 6=7 7=9 8=9 9=5 10=6 11=8 12=10 13=10 14=7 15=7 16=9 17=8 18=1155 19=132107 20=359678 21=6781 22=45 23=15 24=19 25=17 26=18 27=23 28=16 29=11 30=16 31=19 32=19 33=20 34=21 35=17 36=18 37=27 38=22 39=4266 40=262003 41=229844 42=3533 43=26 44=19 45=14 46=18 47=15 48=11 49=10 50=3 51=9 52=7 53=11 54=7 55=2 56=4 57=5 99=6 999990 1=5 2=4 3=2 4=3 5=4 6=9 7=3 8=8 9=11 10=9 11=5 12=7 13=6 14=7 15=8 16=10 17=6 18=1218 19=133534 20=358185 21=6785 22=32 23=23 24=18 25=24 26=12 27=27 28=26 29=9 30=23 31=17 32=28 33=13 34=22 35=20 36=15 37=13 38=22 39=4393 40=265417 41=226352 42=3486 43=23 44=16 45=25 46=18 47=15 48=9 49=4 50=10 51=11 52=9 53=11 54=3 56=2 57=3 58=1 59=3 99=5 999982 1=1 2=12 3=8 4=6 5=11 6=7 7=5 8=3 9=6 10=6 11=6 12=4 13=8 14=6 15=7 16=3 17=7 18=1192 19=134226 20=357523 21=6793 22=32 23=22 24=15 25=16 26=14 27=16 28=26 29=15 30=16 31=18 32=18 33=21 34=13 35=19 36=19 37=19 38=26 39=4413 40=265402 41=226322 42=3514 43=19 44=15 45=14 46=11 47=12 48=14 49=10 50=9 51=9 52=5 53=4 54=7 55=7 56=10 57=2 58=2 59=4 60=2 99=9 999982 1=3 2=6 3=5 4=3 5=5 6=6 7=5 8=2 9=8 10=9 11=11 12=5 13=8 14=8 15=9 16=4 17=10 18=1245 19=142072 20=350089 21=6323 22=39 23=12 24=18 25=17 26=20 27=16 28=24 29=15 30=15 31=15 32=22 33=22 34=24 35=27 36=13 37=16 38=23 39=4853 40=281128 41=210422 42=3233 43=24 44=19 45=16 46=11 47=14 48=11 49=14 50=8 51=7 52=9 53=6 54=5 55=8 56=4 57=3 58=1 59=1 60=1 99=9 999986 0=1 1=1 2=4 3=6 4=7 5=5 6=5 7=5 8=2 9=6 10=6 11=3 12=7 13=7 14=10 15=9 16=12 17=9 18=1194 19=135367 20=356667 21=6500 22=50 23=12 24=16 25=19 26=23 27=19 28=15 29=13 30=13 31=16 32=20 33=18 34=14 35=18 36=20 37=19 38=28 39=4508 40=268749 41=222952 42=3446 43=22 44=16 45=20 46=20 47=13 48=8 49=8 50=9 51=14 52=10 53=5 54=2 55=2 56=1 57=1 58=5 59=1 99=7 999990 1=3 2=5 3=4 4=4 5=12 6=5 7=8 8=1 9=3 10=5 11=9 12=6 13=1 14=9 15=4 16=9 17=10 18=1349 19=143112 20=348928 21=6356 22=37 23=18 24=22 25=15 26=13 27=13 28=22 29=17 30=13 31=23 32=18 33=15 34=16 35=20 36=22 37=18 38=26 39=5112 40=284448 41=206943 42=3163 43=25 44=13 45=12 46=11 47=11 48=13 49=13 50=8 51=3 52=14 53=7 54=4 55=6 56=4 57=1 59=2 99=5 999982 1=1 2=3 3=4 4=3 5=11 6=4 7=8 8=8 9=2 10=8 11=6 12=7 13=5 14=7 15=9 16=6 17=11 18=1254 19=145582 20=346771 21=6135 22=31 23=17 24=14 25=17 26=20 27=11 28=17 29=19 30=19 31=20 32=12 33=21 34=15 35=20 36=22 37=21 38=23 39=5291 40=289306 41=202086 42=2980 43=30 44=10 45=15 46=12 47=8 48=14 49=5 50=12 51=8 52=4 53=10 54=4 55=8 56=2 57=1 59=2 99=9 999984 1=2 2=4 3=6 4=8 5=5 6=8 7=10 8=10 9=8 10=6 11=7 12=4 13=4 14=2 15=9 16=4 17=10 18=1262 19=139743 20=352381 21=6333 22=41 23=19 24=18 25=13 26=16 27=19 28=27 29=17 30=13 31=27 32=14 33=21 34=16 35=20 36=21 37=22 38=27 39=4889 40=278546 41=212941 42=3258 43=29 44=16 45=17 46=14 47=12 48=13 49=7 50=10 51=9 52=10 53=4 54=8 55=5 56=4 57=2 58=2 59=1 60=1 99=8 999996 1=5 2=5 3=9 4=2 5=6 6=6 7=6 8=5 9=5 10=7 11=8 12=3 13=4 14=8 15=5 16=6 17=4 18=1242 19=138555 20=353535 21=6407 22=39 23=21 24=15 25=18 26=12 27=28 28=22 29=14 30=15 31=20 32=22 33=17 34=18 35=20 36=21 37=18 38=20 39=4670 40=275117 41=216522 42=3364 43=25 44=14 45=13 46=14 47=9 48=15 49=5 50=11 51=8 52=7 53=8 54=6 55=3 56=2 57=2 58=3 59=1 62=1 99=2 999994 1=6 2=6 3=6 4=6 5=10 6=5 7=6 8=2 9=7 10=5 11=4 12=11 13=7 14=5 15=3 16=7 17=9 18=1105 19=131674 20=360111 21=6839 22=45 23=15 24=25 25=14 26=16 27=16 28=18 29=16 30=22 31=28 32=13 33=15 34=13 35=15 36=25 37=18 38=27 39=4313 40=261096 41=230675 42=3566 43=31 44=9 45=9 46=17 47=17 48=14 49=11 50=9 51=6 52=9 53=4 54=7 55=6 56=7 57=3 58=6 99=3 999988 1=5 2=4 3=7 4=9 5=4 6=6 7=6 8=6 9=7 10=13 11=12 12=4 13=8 14=4 15=4 16=5 17=14 18=1218 19=130759 20=360775 21=6975 22=36 23=13 24=12 25=11 26=22 27=17 28=23 29=15 30=18 31=23 32=27 33=20 34=14 35=15 36=18 37=19 38=11 39=4220 40=259271 41=232441 42=3706 43=36 44=14 45=13 46=10 47=17 48=16 49=21 50=10 51=8 52=10 53=11 54=3 55=1 56=6 57=4 58=3 59=1 99=6 999982 1=2 2=4 3=4 4=5 5=5 6=11 7=5 8=7 9=9 10=7 11=5 12=6 13=9 14=3 15=4 16=10 17=4 18=1223 19=139480 20=352661 21=6376 22=36 23=13 24=16 25=15 26=24 27=15 28=18 29=19 30=22 31=21 32=11 33=22 34=15 35=26 36=12 37=26 38=17 39=4751 40=277507 41=214105 42=3282 43=30 44=11 45=8 46=13 47=13 48=11 49=12 50=20 51=6 52=9 53=8 54=4 55=4 56=3 57=1 58=6 99=9 999980 1=3 2=8 3=4 4=3 5=7 6=4 7=7 8=10 9=4 10=8 11=5 12=5 13=8 14=3 15=4 16=5 17=10 18=1154 19=132086 20=359498 21=6987 22=41 23=23 24=16 25=24 26=10 27=20 28=19 29=19 30=14 31=17 32=22 33=15 34=21 35=14 36=25 37=18 38=22 39=4367 40=261164 41=230537 42=3590 43=26 44=13 45=17 46=13 47=9 48=10 49=11 50=12 51=6 52=9 53=4 54=3 55=6 56=3 57=1 58=1 59=2 60=2 99=10 999992 2=10 3=10 4=6 5=9 6=4 7=9 8=9 9=5 10=7 11=6 12=5 13=5 14=5 15=7 16=8 17=9 18=1350 19=139101 20=352823 21=6439 22=44 23=17 24=25 25=14 26=15 27=10 28=35 29=19 30=12 31=22 32=19 33=11 34=16 35=17 36=24 37=24 38=23 39=4709 40=276235 41=215323 42=3381 43=30 44=15 45=12 46=11 47=13 48=15 49=10 50=14 51=6 52=7 53=9 54=3 55=2 56=5 57=6 58=4 59=2 60=1 99=4 999976 1=5 2=5 3=7 4=4 5=5 6=6 7=2 8=7 9=7 10=7 11=2 12=12 13=2 14=8 15=7 16=10 17=6 18=1163 19=135790 20=356154 21=6626 22=34 23=17 24=17 25=20 26=23 27=22 28=14 29=19 30=17 31=10 32=16 33=20 34=15 35=18 36=21 37=17 38=20 39=4540 40=268623 41=223101 42=3385 43=18 44=21 45=18 46=15 47=15 48=10 49=16 50=9 51=9 52=5 53=10 54=2 55=3 56=3 57=2 58=1 60=2 99=12 999982 1=4 2=9 3=8 4=3 5=2 6=9 7=3 8=3 9=3 10=9 11=6 12=6 13=7 14=6 15=2 16=8 17=6 18=1264 19=140646 20=351540 21=6270 22=43 23=24 24=25 25=14 26=21 27=20 28=14 29=24 30=17 31=16 32=16 33=23 34=18 35=22 36=24 37=12 38=26 39=4919 40=279987 41=211488 42=3263 43=27 44=14 45=6 46=9 47=18 48=12 49=3 50=6 51=10 52=8 53=6 54=8 55=6 56=5 57=1 58=2 60=1 99=9 999988 1=1 2=11 3=5 4=3 5=7 6=3 7=5 8=5 9=12 10=10 11=7 12=8 13=4 14=8 15=12 16=5 17=9 18=1158 19=130047 20=361602 21=6920 22=36 23=12 24=19 25=15 26=15 27=18 28=22 29=19 30=16 31=26 32=21 33=12 34=13 35=24 36=10 37=21 38=19 39=4073 40=258238 41=233757 42=3587 43=23 44=23 45=16 46=17 47=10 48=9 49=6 50=10 51=5 52=8 53=6 54=11 55=8 56=3 57=3 58=4 59=2 60=2 99=6 999988 1=6 2=5 3=4 4=5 5=6 6=8 7=7 8=12 9=9 10=5 11=3 12=5 13=5 14=6 15=5 16=8 17=5 18=1154 19=128232 20=363260 21=7088 22=37 23=19 24=21 25=11 26=14 27=23 28=14 29=20 30=28 31=11 32=24 33=9 34=19 35=13 36=23 37=19 38=22 39=3991 40=254510 41=237440 42=3703 43=27 44=23 45=14 46=13 47=19 48=12 49=9 50=9 51=8 52=6 53=7 54=7 55=6 56=8 58=2 60=2 99=6 999986 1=3 2=1 3=6 4=6 5=6 6=4 7=4 8=5 9=8 10=6 11=7 12=6 13=6 14=7 15=7 16=3 17=11 18=1109 19=132096 20=359791 21=6738 22=44 23=22 24=15 25=9 26=13 27=24 28=14 29=24 30=21 31=15 32=26 33=15 34=17 35=20 36=21 37=15 38=21 39=4319 40=262196 41=229643 42=3520 43=17 44=14 45=11 46=12 47=8 48=8 49=15 50=7 51=9 52=7 53=4 54=3 55=9 56=3 57=4 58=2 60=1 99=7

The second test was with 20 µs on 40 µs off 10000 times. Here's the output:

version: 47 GPIO=18 20000 5=1 18=25 19=2765 20=7039 21=166 24=2 25=1 27=1 32=1 34=1 35=2 38=4 39=434 40=8573 41=961 42=22 53=1 20000 17=1 18=24 19=2727 20=7111 21=134 22=1 26=1 29=1 30=1 31=1 32=1 36=1 38=3 39=393 40=8669 41=910 42=17 43=1 46=1 49=1 20000 6=1 9=1 10=1 13=1 18=44 19=2981 20=6814 21=153 22=2 24=1 27=1 33=1 35=1 38=22 39=678 40=8633 41=654 42=6 45=1 47=1 53=2 20000 3=1 15=1 18=21 19=2923 20=6939 21=113 23=1 25=1 34=1 37=1 38=1 39=501 40=8847 41=642 42=4 43=1 59=1 20000 18=44 19=2740 20=7033 21=177 22=3 24=1 26=1 27=1 29=1 31=1 34=1 36=1 37=1 38=6 39=447 40=8512 41=1008 42=20 46=1 20000 3=1 14=1 18=30 19=2614 20=7223 21=126 22=2 23=1 26=1 28=1 29=1 31=1 33=1 38=5 39=317 40=8645 41=1016 42=8 43=1 44=1 45=2 50=1 20000 1=1 5=1 8=1 18=34 19=2730 20=7054 21=177 26=1 27=1 29=1 31=1 35=1 38=7 39=507 40=8563 41=904 42=9 45=2 46=1 49=1 51=1 56=1 20000 8=1 18=37 19=2746 20=7065 21=146 22=1 23=2 25=1 27=2 34=1 35=1 37=1 38=1 39=379 40=8583 41=1010 42=20 46=1 50=1 20000 2=1 9=1 10=1 18=25 19=2764 20=7055 21=151 23=1 24=1 35=2 36=1 38=4 39=383 40=8618 41=978 42=8 43=1 45=1 48=2 57=1 20000 2=1 3=1 17=1 18=26 19=2763 20=7046 21=159 24=1 26=1 28=1 31=2 36=1 38=5 39=444 40=8662 41=871 42=12 54=1 57=1 20000 13=1 18=17 19=2579 20=7280 21=120 22=1 24=2 30=1 32=1 35=1 38=3 39=307 40=8561 41=1116 42=5 43=1 44=1 46=1 47=1 20000 8=1 14=2 18=15 19=2590 20=7265 21=123 22=1 23=1 24=1 29=1 30=1 36=3 38=2 39=270 40=8495 41=1217 42=7 45=2 47=1 49=1 20000 12=1 18=8 19=2511 20=7386 21=90 22=2 26=1 29=1 30=1 32=1 33=1 38=1 39=215 40=8626 41=1150 42=2 44=1 47=1 20000 10=1 12=1 17=1 18=20 19=2675 20=7181 21=117 23=2 27=3 31=1 35=1 36=1 38=3 39=370 40=8643 41=962 42=14 46=2 47=1 20000 18=14 19=2549 20=7319 21=113 22=1 24=3 29=1 30=1 35=3 37=2 39=237 40=8592 41=1156 42=7 43=1 19998 12=1 18=24 19=2641 20=7176 21=153 22=2 23=1 27=1 32=1 36=3 38=1 39=374 40=8539 41=1061 42=17 47=1 99=1 20000 3=2 6=1 7=1 12=1 18=18 19=2730 20=7150 21=97 39=329 40=8763 41=895 42=7 47=1 53=1 56=1 58=2 20000 6=1 10=2 12=1 16=1 18=16 19=2728 20=7098 21=152 22=1 37=1 38=5 39=362 40=8579 41=1032 42=14 43=1 44=1 48=1 49=2 50=1 20000 10=1 16=1 18=29 19=2688 20=7145 21=133 25=1 28=1 29=1 30=1 31=1 34=1 38=2 39=354 40=8592 41=1031 42=14 43=1 44=1 46=1 19998 7=1 17=1 18=32 19=2733 20=7090 21=140 24=1 28=1 30=1 33=1 34=1 38=2 39=430 40=8579 41=973 42=8 49=1 52=1 99=1 19998 12=1 15=1 18=34 19=2647 20=7155 21=160 22=1 36=1 38=3 39=430 40=8390 41=1154 42=18 51=1 99=1 20000 3=1 13=1 17=2 18=21 19=2744 20=7102 21=125 22=1 24=1 28=1 29=3 35=1 38=4 39=375 40=8597 41=1002 42=15 47=2 49=1 20000 15=1 18=28 19=2570 20=7226 21=173 24=1 28=1 31=1 32=1 35=1 38=1 39=372 40=8370 41=1225 42=26 44=1 48=1 20000 6=1 18=18 19=2508 20=7338 21=132 27=1 28=1 29=2 31=1 32=1 37=1 38=3 39=280 40=8490 41=1208 42=13 57=1 20000 10=1 13=2 18=37 19=2570 20=7196 21=192 27=1 28=1 29=1 32=2 38=2 39=399 40=8411 41=1157 42=23 46=1 47=1 50=2 20000 3=1 8=1 13=1 18=21 19=2624 20=7218 21=132 25=1 27=1 32=1 34=1 38=4 39=317 40=8492 41=1162 42=18 43=1 46=1 50=1 60=1 20000 11=1 16=1 18=36 19=2639 20=7175 21=144 22=1 25=1 26=1 27=1 28=1 32=1 33=1 38=4 39=398 40=8556 41=1023 42=13 48=2 20000 5=1 12=2 14=1 16=1 18=16 19=2353 20=7503 21=122 22=1 38=2 39=223 40=8314 41=1444 42=11 43=1 45=1 47=2 54=1 20000 1=1 8=1 11=1 13=1 18=9 19=2428 20=7402 21=155 25=1 26=1 34=2 38=3 39=295 40=8238 41=1440 42=17 46=1 48=1 50=1 57=1 20000 7=1 18=20 19=2361 20=7494 21=119 24=1 25=1 26=2 28=1 31=1 32=1 33=1 35=1 36=1 39=213 40=8167 41=1595 42=18 52=1 20000 2=1 12=1 18=7 19=2333 20=7522 21=132 23=1 27=2 28=1 32=3 36=1 38=1 39=233 40=8254 41=1495 42=10 48=1 59=1 20000 14=1 18=11 19=2399 20=7455 21=129 22=2 23=1 26=1 27=1 31=1 33=1 34=1 36=2 37=1 38=1 39=225 40=8287 41=1463 42=16 53=1 20000 3=1 4=2 10=1 11=1 18=9 19=2559 20=7329 21=96 22=1 26=1 33=1 39=283 40=8689 41=1011 42=8 43=1 46=1 48=1 49=1 50=1 53=1 55=1 20000 14=1 17=1 18=35 19=2625 20=7190 21=146 22=1 29=1 31=1 36=1 38=4 39=325 40=8549 41=1103 42=15 45=1 20000 10=1 15=1 18=27 19=2685 20=7120 21=162 22=1 23=1 25=1 26=1 31=1 33=1 34=1 36=1 38=2 39=374 40=8555 41=1044 42=17 44=1 46=1 49=1 20000 7=1 9=1 10=1 18=39 19=2731 20=7066 21=158 24=2 25=1 35=2 36=1 38=3 39=455 40=8553 41=962 42=19 44=1 45=1 50=1 51=1 20000 2=1 4=1 18=38 19=2439 20=7345 21=171 22=1 23=1 24=1 27=1 28=1 32=2 36=2 38=3 39=314 40=8274 41=1389 42=13 56=1 57=1 20000 3=1 18=39 19=2610 20=7172 21=174 22=2 23=1 27=1 28=1 31=1 36=1 38=1 39=377 40=8268 41=1324 42=24 51=1 57=1 20000 5=1 14=1 18=31 19=2582 20=7232 21=148 22=1 23=1 29=3 30=2 31=1 35=1 38=3 39=315 40=8451 41=1203 42=20 45=1 46=1 49=1 19998 10=1 18=30 19=2594 20=7203 21=167 22=1 23=1 24=2 32=1 34=1 35=1 38=3 39=371 40=8344 41=1252 42=22 43=1 49=1 99=1 20000 3=1 11=1 12=1 18=23 19=2560 20=7263 21=149 24=1 27=1 32=1 35=1 38=1 39=314 40=8437 41=1237 42=4 45=1 48=1 49=1 51=1 20000 13=1 18=27 19=2403 20=7400 21=166 22=1 26=1 29=1 30=1 33=1 38=3 39=295 40=8022 41=1649 42=27 44=1 20000 8=1 15=1 16=1 18=11 19=2382 20=7468 21=133 25=1 28=1 29=1 30=1 31=1 34=1 37=1 38=2 39=221 40=8141 41=1608 42=20 45=1 47=1 51=1 20000 18=14 19=2285 20=7555 21=140 22=2 26=1 28=1 29=5 31=1 36=1 38=1 39=171 40=7774 41=2032 42=15 44=1 20000 5=2 17=1 18=17 19=2134 20=7707 21=135 22=1 25=1 26=1 27=1 32=1 33=1 34=1 38=1 39=211 40=8087 41=1679 42=16 54=2 20000 2=1 14=1 18=5 19=2481 20=7402 21=106 25=1 26=1 28=1 29=1 30=1 31=1 33=1 34=1 39=213 40=8574 41=1200 42=6 47=1 57=1 20000 13=1 15=1 18=16 19=2388 20=7435 21=156 22=1 23=1 28=1 30=1 32=1 36=1 37=1 39=279 40=8241 41=1453 42=20 45=1 54=1 20000 7=1 18=20 19=2687 20=7167 21=121 22=1 24=1 28=2 31=1 32=2 37=1 38=3 39=327 40=8684 41=971 42=8 46=1 52=1 19998 3=1 13=1 18=44 19=2460 20=7298 21=193 22=1 27=1 30=1 32=1 38=6 39=359 40=7996 41=1594 42=36 45=2 49=1 53=1 99=1 19998 3=1 18=27 19=2525 20=7310 21=134 22=1 24=1 35=1 36=1 38=2 39=267 40=8500 41=1207 42=17 47=1 51=1 99=1 20000 18=40 19=2626 20=7140 21=189 24=2 25=2 27=1 32=1 33=1 34=1 35=1 36=1 38=1 39=404 40=8272 41=1281 42=36 20000 18=18 19=2304 20=7508 21=166 26=1 28=2 30=2 31=2 32=1 33=1 38=4 39=257 40=8118 41=1591 42=23 47=1 20000 2=1 14=1 15=1 18=19 19=2355 20=7434 21=187 22=1 28=1 32=1 34=1 36=1 37=1 38=2 39=277 40=8001 41=1681 42=30 45=1 46=1 47=1 58=1 19998 11=1 12=1 15=1 18=27 19=2600 20=7221 21=146 23=1 28=1 31=1 34=1 35=1 38=4 39=359 40=8453 41=1151 42=24 46=1 48=1 52=1 99=1 20000 7=1 17=1 18=26 19=2677 20=7172 21=120 22=1 26=1 27=1 31=1 33=1 38=4 39=337 40=8631 41=1016 42=7 43=1 49=1 20000 11=1 18=14 19=2058 20=7786 21=137 22=1 23=1 27=1 29=2 32=1 36=1 38=2 39=205 40=8218 41=1555 42=15 47=1 20000 8=1 11=1 12=1 18=7 19=2311 20=7559 21=117 26=1 27=1 29=1 30=1 31=1 32=1 36=1 38=1 39=171 40=8087 41=1728 42=4 44=1 46=1 52=2 20000 18=21 19=2594 20=7243 21=137 22=1 23=2 25=1 29=1 30=1 33=1 34=1 36=1 38=4 39=277 40=8497 41=1200 42=16 44=1 19998 9=1 12=1 15=1 18=11 19=2505 20=7371 21=107 22=1 29=2 35=1 36=1 37=1 39=224 40=8500 41=1262 42=3 43=1 46=1 50=1 56=1 99=1 20000 17=1 18=21 19=2603 20=7255 21=116 22=2 26=1 28=1 30=1 31=1 33=1 36=1 38=3 39=325 40=8612 41=1035 42=18 43=1 46=1 20000 1=1 7=1 14=1 16=1 18=13 19=2618 20=7261 21=103 23=1 34=1 38=2 39=269 40=8669 41=1044 42=9 43=1 44=1 45=1 52=1 54=1 20000 8=1 13=1 14=1 18=21 19=2602 20=7225 21=146 22=2 25=1 33=1 34=1 38=4 39=341 40=8468 41=1155 42=25 44=1 45=1 46=1 50=1 20000 3=1 11=1 16=1 18=40 19=2689 20=7145 21=119 22=2 25=1 28=1 31=1 34=2 38=4 39=333 40=8626 41=1015 42=14 43=1 46=1 49=1 56=1 20000 15=1 17=1 18=29 19=2612 20=7175 21=181 22=1 36=1 38=4 39=390 40=8300 41=1285 42=16 43=3 19998 3=1 4=1 8=1 18=34 19=2637 20=7161 21=162 22=1 27=1 32=1 37=1 38=7 39=380 40=8501 41=1085 42=17 43=1 45=1 51=1 53=1 55=1 99=1 19998 2=1 10=1 18=31 19=2524 20=7287 21=154 25=1 33=1 38=2 39=311 40=8308 41=1347 42=26 49=1 55=1 99=1 20000 3=1 11=1 18=38 19=2703 20=7108 21=145 23=1 25=3 28=1 34=2 36=1 38=5 39=401 40=8605 41=966 42=14 45=2 49=1 53=1 20000 3=1 4=1 18=37 19=2683 20=7131 21=144 22=1 23=1 24=1 30=1 36=2 38=6 39=405 40=8574 41=1002 42=3 43=1 45=1 46=2 50=1 53=1 20000 6=1 10=1 18=33 19=2559 20=7233 21=168 22=2 24=1 26=1 29=1 30=1 32=1 35=2 38=3 39=396 40=8398 41=1174 42=21 44=1 49=1 50=1 20000 12=1 18=21 19=2681 20=7176 21=115 22=2 25=1 28=2 30=3 31=1 34=1 37=1 38=5 39=335 40=8607 41=1036 42=10 46=1 20000 14=1 17=1 18=27 19=2438 20=7371 21=160 24=1 27=1 31=1 35=2 38=2 39=300 40=8275 41=1391 42=26 44=1 45=1 20000 5=1 6=1 11=1 15=1 18=10 19=2509 20=7365 21=109 22=1 25=2 28=1 34=1 37=1 39=234 40=8562 41=1190 42=4 45=1 46=1 47=1 48=1 52=2 19998 18=20 19=2601 20=7229 21=143 22=2 23=1 24=1 26=1 29=1 30=1 32=1 35=1 36=2 38=4 39=310 40=8539 41=1127 42=12 99=1 20000 9=1 16=1 18=17 19=2601 20=7247 21=129 22=1 27=1 28=1 29=1 30=1 31=1 32=1 36=1 38=2 39=330 40=8605 41=1051 42=5 44=1 50=1 20000 2=1 9=1 10=1 17=1 18=19 19=2660 20=7185 21=131 23=1 36=1 38=2 39=364 40=8650 41=971 42=7 43=1 49=2 58=1 20000 3=1 4=1 5=1 18=9 19=2543 20=7341 21=103 26=1 33=1 39=234 40=8556 41=1198 42=6 43=1 53=1 54=1 57=1 20000 4=1 18=12 19=2450 20=7410 21=124 23=1 24=1 25=1 34=1 35=1 37=1 38=2 39=237 40=8454 41=1293 42=9 55=1 20000 2=1 14=1 18=16 19=2604 20=7239 21=137 22=1 26=1 32=1 33=1 34=1 36=1 37=1 38=2 39=273 40=8530 41=1174 42=11 46=1 48=1 49=1 51=1 20000 2=1 18=16 19=2629 20=7201 21=150 24=2 28=1 31=1 35=1 36=1 38=2 39=320 40=8511 41=1156 42=6 60=1 20000 13=1 18=31 19=2444 20=7329 21=191 23=1 24=2 28=1 31=1 35=2 37=1 38=4 39=316 40=8138 41=1509 42=27 46=1 20000 2=1 4=1 8=1 18=27 19=2430 20=7381 21=156 22=1 26=1 27=1 32=1 33=1 37=1 38=2 39=284 40=8273 41=1414 42=19 45=1 51=1 53=1 54=1 20000 11=1 14=1 18=43 19=2402 20=7354 21=195 24=1 25=2 28=1 32=1 34=2 35=1 37=2 38=1 39=357 40=8060 41=1543 42=30 49=1 52=1 20000 10=1 18=20 19=2469 20=7355 21=150 22=2 24=1 25=1 29=1 30=1 33=1 36=1 37=1 38=5 39=269 40=8348 41=1354 42=17 44=1 46=1 20000 4=1 16=1 18=26 19=2387 20=7391 21=191 25=1 29=2 30=1 31=2 34=1 38=2 39=307 40=7727 41=1924 42=32 44=1 51=1 55=1 20000 13=1 18=20 19=2433 20=7408 21=133 23=1 24=1 25=1 28=1 29=2 30=2 35=2 38=1 39=250 40=8290 41=1439 42=12 46=2 20000 5=1 13=1 18=18 19=2453 20=7371 21=153 22=1 24=1 26=1 34=1 35=1 38=3 39=305 40=8241 41=1424 42=21 47=2 48=1 20000 2=1 9=1 18=13 19=2530 20=7328 21=124 22=1 25=1 27=1 32=1 35=2 37=1 38=3 39=286 40=8547 41=1145 42=11 43=1 54=1 55=1 19998 12=1 16=1 18=18 19=2427 20=7419 21=130 24=1 27=1 28=1 31=1 32=1 36=1 39=261 40=8352 41=1368 42=11 43=1 46=1 99=1 20000 2=1 14=1 18=21 19=2290 20=7550 21=133 22=2 27=2 33=2 35=1 37=1 38=3 39=220 40=8095 41=1661 42=13 43=1 50=1 54=1 20000 10=1 14=1 17=1 18=9 19=2273 20=7595 21=116 22=3 23=1 31=1 38=4 39=161 40=8183 41=1641 42=6 46=2 47=1 19998 11=1 16=1 18=17 19=2560 20=7270 21=148 28=1 30=2 31=1 35=1 38=1 39=294 40=8442 41=1231 42=24 43=1 55=1 99=1 20000 2=1 9=1 10=1 13=1 16=1 18=11 19=2369 20=7486 21=128 29=1 30=1 32=1 35=1 38=1 39=221 40=8347 41=1407 42=14 44=1 46=1 49=1 52=1 54=1 55=1 20000 4=1 18=35 19=2493 20=7290 21=176 22=1 23=1 26=1 28=2 30=1 31=1 32=1 36=1 37=1 39=327 40=8162 41=1469 42=35 55=1 20000 12=1 16=1 18=19 19=2450 20=7377 21=148 22=1 23=1 26=1 29=1 31=1 34=1 36=1 38=4 39=258 40=8279 41=1442 42=11 44=1 49=1 20000 0=1 8=1 13=1 18=36 19=2543 20=7215 21=199 22=1 24=1 25=1 27=1 31=1 34=1 35=1 38=3 39=387 40=8216 41=1357 42=30 46=1 52=1 59=1 20000 3=1 6=1 16=1 18=26 19=2373 20=7435 21=160 22=1 23=1 24=1 35=1 36=2 38=3 39=281 40=8068 41=1619 42=20 43=2 47=2 55=1 20000 7=1 11=1 14=1 18=37 19=2583 20=7210 21=164 22=1 25=2 34=2 36=1 38=3 39=374 40=8417 41=1183 42=16 46=1 48=1 56=1 19998 2=1 3=1 18=34 19=2873 20=6933 21=153 22=2 24=1 25=1 28=1 35=1 37=1 38=4 39=497 40=8718 41=761 42=9 44=1 46=1 47=1 49=1 55=1 98=1 20000 4=1 5=1 17=1 18=29 19=2893 20=6952 21=122 24=1 34=1 35=1 38=2 39=509 40=8710 41=767 42=6 48=1 53=1 54=1 20000 7=1 17=1 18=36 19=2674 20=7138 21=147 24=2 26=1 33=2 35=2 38=2 39=453 40=8568 41=952 42=18 50=1 52=1 20000 4=1 6=1 18=6 19=2669 20=7226 21=95 24=2 34=1 35=1 38=2 39=284 40=8746 41=957 42=6 51=1 53=1 20000 8=1 18=19 19=2809 20=7064 21=103 26=3 28=1 31=1 33=2 34=2 38=2 39=416 40=8769 41=799 42=6 45=1 52=1 20000 5=1 10=1 18=5 19=2597 20=7298 21=93 22=3 23=1 24=1 31=1 34=2 36=1 38=1 39=224 40=8610 41=1152 42=4 47=1 48=1 49=1 51=1 20000 4=1 16=1 18=22 19=2634 20=7197 21=141 22=2 24=2 30=1 35=2 37=1 38=2 39=340 40=8554 41=1084 42=11 43=2 49=1 55=1 20000 7=1 14=1 15=1 17=1 18=11 19=2560 20=7324 21=101 36=1 37=1 38=2 39=252 40=8635 41=1097 42=8 48=1 49=1 54=1 20000 6=1 7=1 13=1 14=1 15=1 18=18 19=2554 20=7294 21=129 38=4 39=329 40=8554 41=1092 42=13 44=1 45=3 48=1 49=2 20000 13=1 15=1 18=12 19=2693 20=7190 21=98 22=3 23=1 28=1 30=1 35=1 37=1 38=3 39=280 40=8694 41=1007 42=10 45=1 46=1 20000 15=1 17=1 18=15 19=2832 20=7044 21=104 27=1 29=2 30=2 31=1 38=4 39=416 40=8744 41=825 42=6 43=1 20000 5=1 18=15 19=2557 20=7288 21=136 26=2 29=1 30=1 32=1 33=1 38=1 39=298 40=8458 41=1224 42=14 55=1 20000 2=1 7=1 11=1 17=1 18=29 19=2529 20=7277 21=160 22=1 38=2 39=339 40=8200 41=1438 42=15 43=1 44=1 48=1 51=1 57=1 20000 9=1 10=1 18=27 19=2570 20=7240 21=156 22=2 26=2 28=1 30=1 33=1 34=1 37=1 38=8 39=373 40=8429 41=1165 42=18 53=2 20000 17=1 18=25 19=2454 20=7360 21=156 22=1 24=2 28=2 30=1 31=2 34=1 36=1 38=1 39=297 40=8223 41=1449 42=20 47=1 52=2 20000 3=1 17=1 18=25 19=2649 20=7144 21=175 22=1 23=1 25=1 26=1 29=2 34=2 36=1 38=5 39=418 40=8510 41=1042 42=18 48=2 20000 3=1 11=1 17=1 18=22 19=2672 20=7164 21=138 25=1 34=2 38=3 39=362 40=8596 41=1025 42=8 48=2 55=1 20000 3=1 18=39 19=2673 20=7131 21=151 22=2 26=1 27=1 29=1 31=1 32=2 33=1 38=2 39=428 40=8487 41=1052 42=24 46=1 56=1 20000 10=1 16=1 18=12 19=2784 20=7072 21=128 27=1 29=1 30=1 31=1 36=1 37=1 38=2 39=394 40=8676 41=909 42=12 47=1 50=1 20000 3=1 8=1 9=1 18=39 19=2646 20=7142 21=169 26=1 31=1 33=1 34=1 36=1 38=5 39=389 40=8422 41=1159 42=16 48=1 49=1 56=1 57=1 20000 10=1 12=1 13=1 18=20 19=2517 20=7323 21=135 23=1 26=1 33=1 36=1 38=3 39=308 40=8500 41=1173 42=10 47=1 48=1 53=1 20000 6=1 8=1 17=1 18=25 19=2620 20=7219 21=129 22=1 24=1 26=1 27=1 32=1 33=1 35=2 38=1 39=319 40=8554 41=1110 42=8 47=1 51=1 52=1 20000 16=1 17=1 18=14 19=2661 20=7220 21=99 23=2 25=1 26=1 33=1 34=2 35=1 37=1 38=1 39=281 40=8653 41=1053 42=4 43=1 49=1 20000 1=1 14=1 18=16 19=2628 20=7225 21=125 22=1 24=3 35=1 36=4 38=1 39=297 40=8631 41=1059 42=3 46=1 49=1 52=1 19996 3=1 16=1 18=12 19=2704 20=7173 21=105 22=1 28=1 32=1 36=1 38=1 39=318 40=8753 41=911 42=8 43=1 58=1 99=2 20000 3=1 18=10 19=2724 20=7179 21=82 24=2 26=1 28=1 31=1 33=1 35=2 38=1 39=260 40=8756 41=970 42=6 47=1 51=1 20000 17=1 18=19 19=2723 20=7119 21=133 22=1 24=1 25=1 27=3 29=1 32=2 36=1 38=3 39=381 40=8721 41=879 42=6 43=1 44=1 47=1 50=1 20000 9=2 18=10 19=2646 20=7235 21=103 24=1 26=1 28=1 29=1 30=1 31=2 34=1 35=1 38=3 39=302 40=8743 41=939 42=4 44=1 50=1 56=1 20000 6=1 13=1 16=1 18=21 19=2670 20=7151 21=152 22=2 24=1 34=2 37=1 38=5 39=410 40=8570 41=998 42=9 44=2 47=1 53=1 20000 1=1 11=1 17=1 18=27 19=2693 20=7136 21=137 22=1 28=2 29=2 30=1 31=1 38=3 39=368 40=8624 41=986 42=12 43=1 48=1 58=1 20000 7=1 18=35 19=2697 20=7075 21=187 24=1 26=1 27=1 28=2 31=2 32=1 33=1 35=1 38=6 39=432 40=8411 41=1125 42=18 46=1 47=1 20000 2=1 14=1 18=20 19=2616 20=7222 21=137 26=2 28=1 30=1 32=1 33=1 38=2 39=368 40=8695 41=915 42=13 46=1 48=1 49=1 20000 10=1 11=1 18=39 19=2782 20=7021 21=153 23=1 24=2 35=2 36=1 38=4 39=430 40=8601 41=944 42=13 43=2 46=1 49=1 19998 9=1 14=1 18=29 19=2798 20=7045 21=124 25=1 32=1 35=1 36=1 37=1 38=6 39=453 40=8720 41=802 42=7 43=2 47=1 48=1 49=1 99=1 20000 2=1 4=1 18=30 19=2670 20=7154 21=141 22=1 23=1 24=1 36=2 37=1 39=388 40=8560 41=1031 42=14 43=1 54=1 58=1 20000 15=1 18=36 19=2626 20=7149 21=183 23=2 25=1 27=2 30=1 32=1 34=1 37=2 38=8 39=410 40=8444 41=1113 42=17 43=2 20000 18=20 19=2489 20=7333 21=152 22=1 23=1 25=1 26=2 29=1 30=1 32=1 34=2 36=1 37=1 38=2 39=309 40=8299 41=1364 42=19 20000 14=1 18=35 19=2786 20=6995 21=178 22=1 25=1 27=2 29=1 31=2 32=1 34=2 35=1 38=2 39=466 40=8505 41=1005 42=12 43=1 47=1 49=1 20000 4=1 8=1 10=1 18=17 19=2682 20=7201 21=95 27=1 28=1 30=1 32=1 35=1 38=1 39=321 40=8698 41=968 42=5 50=1 56=2 20000 1=1 5=1 9=1 18=21 19=2723 20=7112 21=139 23=1 24=1 36=1 37=1 38=4 39=391 40=8589 41=994 42=16 52=1 53=1 58=1 20000 2=1 6=1 16=1 18=15 19=2677 20=7200 21=103 22=1 24=1 35=1 36=1 38=1 39=310 40=8746 41=926 42=8 43=1 44=1 45=1 46=1 48=1 56=1 20000 1=1 9=1 12=1 16=1 18=21 19=2791 20=7057 21=124 22=1 24=1 25=1 31=1 35=1 38=3 39=396 40=8620 41=969 42=5 45=1 47=1 51=1 58=1 20000 2=2 18=19 19=2690 20=7175 21=112 26=1 29=1 31=1 32=1 37=1 39=327 40=8721 41=938 42=6 45=1 47=1 50=1 52=1 20000 7=1 9=1 11=1 14=1 18=23 19=2741 20=7100 21=129 22=1 26=1 28=2 31=1 38=5 39=416 40=8683 41=886 42=1 43=1 45=1 46=1 49=2 51=1 20000 17=1 18=18 19=2524 20=7322 21=130 22=1 24=2 26=1 27=1 33=1 34=2 35=2 38=1 39=275 40=8492 41=1216 42=9 44=1 20000 12=1 18=16 19=2661 20=7219 21=100 22=1 27=1 29=1 30=2 31=1 38=3 39=278 40=8663 41=1042 42=7 44=2 51=1 20000 8=1 9=1 10=1 12=1 18=25 19=2891 20=6942 21=137 28=1 30=1 38=1 39=462 40=8760 41=763 42=8 47=1 48=1 50=1 52=1 20000 8=1 11=2 14=1 18=25 19=2949 20=6895 21=125 22=1 29=1 30=1 35=1 38=3 39=486 40=8865 41=626 42=13 43=1 46=1 48=1 51=1 20000 11=1 13=1 17=1 18=49 19=2722 20=7009 21=213 22=2 23=1 26=1 33=2 37=1 38=4 39=493 40=8490 41=986 42=21 45=1 47=1 20000 16=1 18=11 19=2606 20=7256 21=122 23=1 24=1 25=1 27=1 32=1 34=1 35=1 36=1 38=1 39=308 40=8558 41=1120 42=7 43=1 20000 6=1 10=1 11=1 18=46 19=2767 20=7004 21=178 22=1 28=1 31=1 37=2 38=5 39=482 40=8452 41=1036 42=17 46=1 47=1 49=1 52=1 20000 1=1 3=1 10=1 17=1 18=23 19=2765 20=7064 21=144 36=1 38=1 39=385 40=8709 41=884 42=14 48=2 49=1 50=1 58=1 20000 1=1 7=1 17=1 18=35 19=2650 20=7162 21=147 22=1 23=1 25=1 34=1 36=1 37=1 38=3 39=389 40=8549 41=1040 42=12 43=1 50=1 60=1 20000 2=1 6=1 11=1 18=43 19=2642 20=7158 21=150 22=2 24=1 25=1 33=1 36=1 37=1 38=3 39=369 40=8445 41=1163 42=12 45=1 48=1 49=1 58=1 20000 11=2 18=22 19=2881 20=6967 21=124 22=1 25=2 26=1 33=2 34=1 38=5 39=457 40=8774 41=750 42=7 43=1 45=1 48=1 20000 4=1 9=1 18=34 19=2560 20=7248 21=153 22=1 25=1 26=1 33=1 34=1 38=4 39=353 40=8312 41=1303 42=21 43=1 44=1 47=1 53=1 19998 15=1 18=11 19=2532 20=7334 21=118 22=2 23=1 34=1 37=2 38=2 39=255 40=8605 41=1127 42=3 44=1 46=1 99=1 20000 14=1 18=19 19=2831 20=7041 21=103 22=1 23=2 28=1 29=1 30=1 31=1 35=1 36=1 37=1 38=3 39=398 40=8802 41=783 42=6 43=1 44=1

For reference, here's the program that was used on the ATmega328P for the first test:

/*
avr-gcc -Wall -c -g -Os -mmcu=atmega328p -DF_CPU=8000000UL pulse.c
avr-gcc -g -mmcu=atmega328p -o pulse.elf pulse.o
avr-objcopy -j .text -j .data -O ihex pulse.elf pulse.hex
sudo avrdude -c dragon_isp -P usb -p m328p -e -U flash:w:pulse.hex

*/

#include <avr/io.h>
#include <avr/power.h>
#include <util/delay.h>

#define LED PB0
#define LED_DDR DDRB
#define LED_PORT PORTB

#define PULSE PB1
#define PULSE_DDR DDRB
#define PULSE_PORT PORTB

#define HIGHTIME 20
#define LOWTIME 40

#define setBit(sfr, bit) (_SFR_BYTE(sfr) |= (1 << bit))
#define clearBit(sfr, bit) (_SFR_BYTE(sfr) &= ~(1 << bit))
#define toggleBit(sfr, bit) (_SFR_BYTE(sfr) ^= (1 << bit))

int main(void) {
  uint32_t i;

  clock_prescale_set(clock_div_1); // 8Mhz clock

  setBit(LED_DDR, LED); // configure LED pin as an output
  setBit(PULSE_DDR, PULSE); // configure PULSE pin as an output

  while (1) {
    setBit(LED_PORT, LED); // LED on

    for (i = 0; i != 500000; ++i) {
      setBit(PULSE_PORT, PULSE); // PULSE high
      _delay_us(HIGHTIME);

      clearBit(PULSE_PORT, PULSE); // PULSE low
      _delay_us(LOWTIME);
    }

    clearBit(LED_PORT, LED); // LED off

    _delay_ms(5000);
  }

  return (0);
}

The results for 1000000 state changes that you're getting are a lot better than those that I'm getting. I'm beginning to wonder if I have a faulty circuit.

fivdi commented 8 years ago

The ability of pigpio to detect state changes appears to be either dependent on the temperature of the Pi or the CPU load. Here's a modified version of the test program that also outputs the temperature of the Pi in thousandths of degrees Celsius.

/*
issue52.c

gcc -Wall -pthread -o 52 issue52.c -lpigpio
*/

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <pigpio.h>

#define PULSE_GPIO 12

static int pulse_gpio = PULSE_GPIO;

#define BUF_SIZE 1000

static uint32_t notificationCount = 0;
static int notFirstReport = 0;

#define DIFFS 200
#define HALF (DIFFS/2)

int diffs[DIFFS];

void timerFunc(void)
{
   char pi_temperature[10];
   FILE *fp;
   static int s_same=0, s_oldcount = 0;
   int i;
   if (s_oldcount == notificationCount)
   {
      if (++s_same > 2)
      {
         s_same = -1000;
         if (s_oldcount)
         {
            fp = fopen("/sys/class/thermal/thermal_zone0/temp", "r");
            fgets(pi_temperature, sizeof(pi_temperature), fp);
            printf("temp: %s", pi_temperature);
            fclose(fp);

            printf("%u\n", notificationCount);
            for (i=0; i<DIFFS; i++)
            {
               if (diffs[i])
               {
                  printf("%d=%d ", i-HALF, diffs[i]);
                  diffs[i] = 0;
               }
            }
            printf("\n");
         }
         notificationCount = 0;
         notFirstReport = 0;
      }
   }
   else
   {
      s_oldcount = notificationCount;
      s_same = 0;
   }
}

int main(int argc, char *argv[])
{
   int version;
   int handle;
   char pipePath[32];
   int fd;
   int bytes;
   gpioReport_t r[BUF_SIZE];
   uint16_t lastSeqno = 0xffff;
   uint32_t lastTick = 0;
   int tickDiff;
   int entries;
   int i;

   if (argc > 1) pulse_gpio = atoi(argv[1]);

   //gpioCfgDMAchannels(6, 14);
   gpioCfgClock(1, 1, 1);

   if ((version = gpioInitialise()) < 0)
   {
      printf("gpioInitialise error\n");
      return -1;
   }

   gpioSetMode(pulse_gpio, PI_INPUT);

   printf("version: %d GPIO=%d\n", version, pulse_gpio);

   if (gpioSetTimerFunc(0, 1000, timerFunc) < 0)
   {
      printf("gpioSetTimerFunc error\n");
   }

   if ((handle = gpioNotifyOpen()) < 0)
   {
      printf("gpioNotifyOpen error\n");
      return -1;
   }

   if (gpioNotifyBegin(handle, (1 << pulse_gpio)) < 0)
   {
      printf("gpioNotifyBegin error\n");
      return -1;
   }

   sprintf(pipePath, "/dev/pigpio%d", handle);

   if ((fd = open(pipePath, O_RDONLY)) < 0)
   {
      printf("open error\n");
      return -1;
   }

   for (;;)
   {
      bytes = read(fd, r, 12 * BUF_SIZE);

      if (bytes <= 0)
      {
         printf("read error\n");
         return -1;
      }

      entries = bytes / 12;

      if (entries * 12 != bytes)
      {
         printf("Oops partial entries are not handled");
         return -1;
      }

      for (i = 0; i != entries; ++i)
      {
         if (r[i].flags)
         {
             /* Ignore watchdogs and keep alives. */
            lastSeqno = r[i].seqno;
            break;
         }

         ++notificationCount;

         if (notFirstReport)
         {
            tickDiff = (r[i].tick - lastTick) + HALF;
            if (tickDiff < 0) diffs[0]++;
            else if (tickDiff >= DIFFS) diffs[DIFFS-1]++;
            else diffs[tickDiff]++;
         }
         else notFirstReport = 1;

         lastTick = r[i].tick;

         if (((uint16_t) (lastSeqno + 1)) != r[i].seqno)
         {
            printf("  sequence error - lastSeqno: %d, seqno: %d\n",
               lastSeqno, r[i].seqno);
            printf("    %d\n", notificationCount);
         }

         lastSeqno = r[i].seqno;
      }
   }

   gpioTerminate();

   return 0;
}

The test was with 20 µs on 40 µs off 500,000 times. After successfully detecting 7,000,000 state changes the temperature of the Pi was increased by starting 160 Node.js processes that run an empty loop (while (1);). Before long the temperature increased to over 80°C and the ability of pigpio to detect state changes deteriorated. After a while the Node.js processes were stopped and the temperature dropped. After the temperature dropped, pigpio was able to detect all state changes again.

version: 48 GPIO=18
temp: 39007
1000000
4=1 5=1 6=1 7=1 9=2 10=1 11=1 12=4 13=1 14=1 15=3 16=3 17=4 18=1773 19=163249 20=324398 21=10529 22=1 23=5 24=4 25=1 26=3 27=2 28=6 29=5 30=6 31=5 32=4 33=4 34=2 35=4 36=3 37=6 38=53 39=10506 40=302108 41=184421 42=2846 43=6 44=3 45=5 46=2 47=2 48=1 49=4 50=2 51=2 53=2 54=1 55=1 
temp: 38470
1000000
5=1 6=1 7=1 8=4 10=1 13=1 14=1 15=1 16=5 17=3 18=1656 19=153886 20=332850 21=11552 22=6 23=4 24=6 25=5 26=7 27=2 28=3 29=5 30=3 31=6 32=3 33=4 34=3 35=9 36=4 37=4 38=48 39=8754 40=285037 41=202662 42=3434 43=5 44=4 45=5 46=3 47=3 49=2 50=2 51=1 52=1 53=1 
temp: 38470
1000000
5=5 6=3 7=2 8=2 10=1 11=2 12=1 13=1 14=2 16=3 17=1 18=1671 19=161147 20=326280 21=10849 22=5 23=4 24=2 25=1 26=5 27=2 28=7 29=3 30=6 31=4 32=8 33=2 34=1 35=4 36=5 37=4 38=57 39=10313 40=297456 41=189152 42=2951 43=7 44=6 45=3 46=3 47=2 48=2 49=1 50=5 51=3 52=1 53=4 
temp: 38470
1000000
3=1 4=1 5=3 6=1 9=2 10=2 11=3 12=2 13=1 15=1 16=1 17=6 18=1659 19=157294 20=329622 21=11373 22=7 23=3 24=2 25=1 26=5 27=5 28=2 29=3 31=5 32=6 33=4 34=2 35=3 36=2 37=2 38=46 39=9415 40=289424 41=197716 42=3348 43=4 44=3 45=3 46=2 47=3 48=2 50=2 51=1 52=3 53=2 55=1 
temp: 39007
1000000
3=1 5=4 6=2 7=2 8=3 9=2 10=1 13=2 15=1 16=2 17=4 18=1730 19=156265 20=330751 21=11204 22=4 23=2 24=3 25=4 26=3 27=4 28=5 29=2 31=2 32=6 33=2 34=9 35=2 36=3 37=2 38=42 39=9029 40=289484 41=198008 42=3376 43=7 44=3 45=2 46=3 47=4 48=3 49=2 50=2 51=2 52=2 53=2 54=1 
temp: 38470
1000000
4=2 5=1 6=1 7=2 8=2 9=1 10=3 12=1 14=1 15=2 16=3 17=2 18=1564 19=150027 20=336085 21=12275 22=4 23=8 24=1 25=4 26=1 27=5 28=5 29=1 30=2 31=4 32=6 33=3 35=1 36=7 37=4 38=32 39=8163 40=277252 41=210906 42=3585 43=8 44=5 45=4 46=4 48=2 50=1 51=5 52=2 53=1 56=1 
temp: 39007
1000000
3=2 4=2 5=4 7=4 8=1 9=1 11=3 12=3 14=3 16=1 17=4 18=1653 19=154609 20=332071 21=11609 22=7 24=5 25=3 27=8 28=6 29=3 30=2 31=5 32=3 33=6 34=4 35=2 36=2 37=3 38=31 39=8922 40=287062 41=200572 42=3344 43=7 44=3 45=5 46=5 47=1 48=4 49=1 50=1 51=3 52=1 53=3 54=4 57=1 
temp: 69674
1000000
2=1 4=1 5=1 6=1 7=1 9=3 10=2 11=1 13=2 14=2 15=3 16=12 17=29 18=1766 19=155059 20=336220 21=6798 22=60 23=17 24=3 25=6 26=3 27=2 28=4 29=3 30=4 31=4 33=5 34=5 35=3 36=6 37=16 38=89 39=7228 40=299654 41=189446 42=3468 43=42 44=5 45=4 46=2 47=3 48=6 49=3 50=2 51=1 52=1 53=1 57=1 
temp: 75592
1000000
3=1 5=3 6=2 7=2 8=1 12=2 14=2 15=3 16=2 18=1290 19=148759 20=344143 21=5758 22=9 23=5 24=3 25=3 26=1 27=6 28=4 29=3 30=3 31=3 32=4 33=2 34=3 35=1 36=6 37=3 38=10 39=5342 40=294120 41=197707 42=2767 43=5 44=2 46=4 47=3 48=4 51=2 52=1 54=4 57=1 
temp: 79896
1000000
4=1 5=3 6=3 7=1 8=2 9=4 10=1 12=1 13=1 15=1 16=4 18=1367 19=154724 20=338314 21=5542 22=6 23=3 24=1 25=7 26=3 27=4 28=3 29=4 30=5 31=2 32=6 33=3 34=5 35=2 36=4 37=2 38=8 39=5769 40=302098 41=189382 42=2680 43=6 44=1 45=2 46=4 47=2 48=5 49=4 50=1 51=2 52=1 53=2 54=2 55=1 
temp: 80434
999980
1=4 2=4 3=4 4=5 5=11 6=10 7=9 8=4 9=7 10=8 11=11 12=5 13=6 14=6 15=11 16=8 17=8 18=1246 19=140479 20=351466 21=6487 22=51 23=21 24=21 25=28 26=17 27=22 28=16 29=20 30=23 31=19 32=16 33=18 34=36 35=17 36=23 37=15 38=39 39=4803 40=274479 41=216992 42=3302 43=27 44=25 45=21 46=19 47=16 48=13 49=12 50=11 51=9 52=11 53=4 54=9 55=3 56=2 57=4 58=4 59=2 99=10 
temp: 80972
999992
0=1 1=6 2=10 3=5 4=5 5=5 6=8 7=3 8=11 9=5 10=10 11=8 12=8 13=11 14=8 15=17 16=12 17=11 18=1322 19=137625 20=353629 21=7081 22=55 23=27 24=24 25=23 26=13 27=20 28=18 29=18 30=19 31=24 32=14 33=17 34=29 35=22 36=27 37=26 38=45 39=5063 40=267671 41=222932 42=3881 43=36 44=29 45=26 46=12 47=25 48=8 49=13 50=14 51=9 52=11 53=9 54=5 55=7 56=5 57=2 58=2 59=4 60=1 99=4 
temp: 81510
999984
1=1 2=7 3=9 4=8 5=4 6=10 7=11 8=8 9=9 10=7 11=10 12=12 13=11 14=14 15=7 16=9 17=15 18=1249 19=137629 20=354053 21=6731 22=50 23=22 24=16 25=20 26=18 27=19 28=10 29=27 30=30 31=17 32=14 33=15 34=22 35=22 36=20 37=24 38=36 39=4737 40=268002 41=223223 42=3603 43=32 44=26 45=18 46=9 47=23 48=13 49=17 50=15 51=16 52=12 53=8 54=2 55=8 56=7 57=5 58=2 60=1 99=8 
temp: 81510
999988
1=5 2=5 3=6 4=4 5=4 6=5 7=9 8=14 9=5 10=2 11=4 12=7 13=8 14=9 15=8 16=9 17=14 18=1252 19=141374 20=350809 21=6256 22=42 23=20 24=18 25=20 26=24 27=18 28=27 29=21 30=21 31=23 32=23 33=30 34=23 35=17 36=19 37=19 38=28 39=4649 40=275881 41=215774 42=3296 43=31 44=15 45=17 46=27 47=12 48=13 49=9 50=11 51=7 52=8 53=4 54=6 55=8 56=9 58=2 99=6 
temp: 82048
999986
1=6 2=9 3=6 4=6 5=3 6=9 7=9 8=11 9=3 10=8 11=11 12=10 13=7 14=3 15=12 16=8 17=16 18=1378 19=136238 20=354655 21=7385 22=65 23=22 24=28 25=15 26=15 27=22 28=17 29=18 30=24 31=20 32=20 33=14 34=20 35=20 36=24 37=29 38=38 39=5140 40=266152 41=224353 42=3915 43=44 44=25 45=22 46=11 47=17 48=15 49=18 50=14 51=12 52=7 53=6 54=6 56=3 57=2 58=9 59=1 60=1 62=1 99=7 
temp: 82048
999992
1=1 2=8 3=5 4=9 5=8 6=11 7=4 8=5 9=13 10=8 11=6 12=8 13=6 14=12 15=8 16=4 17=11 18=1557 19=142471 20=348171 21=7460 22=49 23=28 24=25 25=24 26=23 27=24 28=17 29=22 30=20 31=23 32=19 33=25 34=20 35=27 36=30 37=30 38=24 39=5980 40=275794 41=213747 42=4073 43=29 44=16 45=16 46=18 47=16 48=10 49=9 50=9 51=18 52=4 53=7 54=4 55=3 56=5 57=6 58=1 59=3 60=3 99=4 
temp: 81510
999990
1=2 2=6 3=8 4=6 5=7 6=5 7=9 8=6 9=11 10=8 11=4 12=5 13=7 14=8 15=7 16=6 17=9 18=1261 19=142822 20=349375 21=6235 22=39 23=23 24=20 25=27 26=21 27=24 28=24 29=14 30=22 31=23 32=22 33=20 34=19 35=22 36=18 37=28 38=28 39=5023 40=280350 41=211050 42=3200 43=20 44=16 45=15 46=14 47=12 48=13 49=12 50=12 51=6 52=7 53=15 54=3 55=1 56=3 57=2 58=7 59=1 62=1 99=5 
temp: 82586
999986
1=6 2=6 3=4 4=7 5=6 6=10 7=10 8=8 9=8 10=10 11=9 12=8 13=4 14=8 15=7 16=7 17=10 18=1282 19=144863 20=347410 21=6135 22=33 23=21 24=24 25=18 26=15 27=21 28=19 29=26 30=29 31=20 32=25 33=16 34=14 35=25 36=22 37=20 38=27 39=5142 40=284437 41=206848 42=3165 43=30 44=25 45=13 46=15 47=15 48=13 49=20 50=12 51=6 52=10 53=11 54=5 55=7 56=5 57=2 58=2 59=2 99=7 
temp: 82048
999984
2=11 3=6 4=3 5=10 6=12 7=10 8=7 9=5 10=11 11=10 12=5 13=3 14=5 15=9 16=13 17=6 18=1488 19=142389 20=348742 21=7043 22=55 23=28 24=13 25=29 26=21 27=18 28=23 29=18 30=21 31=22 32=27 33=21 34=26 35=28 36=17 37=24 38=27 39=5750 40=276683 41=213292 42=3851 43=32 44=24 45=20 46=15 47=10 48=10 49=11 50=14 51=6 52=13 53=12 54=9 55=6 56=4 57=6 58=1 99=8 
temp: 61066
999994
2=3 3=7 4=5 5=9 6=5 7=3 8=6 9=4 10=2 11=10 12=5 13=6 14=5 15=6 16=7 17=9 18=1404 19=146924 20=343470 21=7975 22=33 23=22 24=13 25=14 26=13 27=13 28=12 29=15 30=11 31=15 32=13 33=15 34=14 35=10 36=25 37=15 38=38 39=6351 40=282231 41=207630 42=3489 43=22 44=18 45=11 46=12 47=14 48=5 49=8 50=8 51=9 52=4 53=8 54=3 55=4 57=5 58=1 59=1 99=3 
temp: 54072
1000000
2=1 4=1 5=4 6=2 7=2 8=1 9=2 12=2 13=2 15=1 16=1 17=3 18=1537 19=154304 20=333444 21=10660 22=9 23=4 24=5 25=4 26=4 27=3 28=1 29=3 30=3 32=2 33=5 34=7 35=7 36=5 37=1 38=39 39=8196 40=288267 41=200230 42=3209 43=3 44=1 45=2 46=3 47=5 48=2 49=3 50=1 52=3 53=3 54=1 58=1 
temp: 49768
1000000
5=2 6=1 7=1 8=2 9=1 11=1 12=3 13=2 15=2 16=1 17=4 18=1678 19=162416 20=325729 21=10122 22=5 23=6 24=4 25=3 26=6 27=4 28=3 29=7 30=3 31=5 32=6 33=4 34=5 35=4 36=3 37=6 38=60 39=10034 40=301069 41=185879 42=2887 43=6 44=4 45=4 46=5 47=2 48=1 49=2 50=1 51=4 52=2 
temp: 47615
1000000
3=2 4=1 5=3 6=2 7=2 8=1 9=2 10=2 11=3 12=2 14=3 16=2 17=4 18=1653 19=153066 20=333556 21=11671 22=5 23=3 24=2 25=2 26=4 27=3 28=5 29=2 30=2 31=1 32=3 33=4 34=5 35=4 36=2 37=3 38=49 39=8424 40=283099 41=204899 42=3466 43=5 44=8 45=3 46=1 47=3 48=2 49=5 50=2 51=2 52=3 54=1 55=1 57=1 
temp: 46540
1000000
3=1 4=1 5=5 6=3 7=2 8=1 9=2 10=3 12=2 13=1 14=4 15=1 16=1 17=3 18=1711 19=154931 20=331887 21=11413 22=8 23=4 24=2 25=2 26=3 27=4 28=3 29=2 30=2 31=1 32=6 33=3 34=4 35=2 36=4 37=7 38=59 39=8824 40=286051 41=201578 42=3422 43=4 44=4 45=2 46=3 47=3 48=2 49=1 50=3 51=5 52=5 53=1 54=2 56=1 
temp: 45464
1000000
4=1 6=4 7=3 8=3 9=1 10=3 11=2 12=1 13=1 14=1 15=2 17=3 18=1583 19=156384 20=330522 21=11456 22=6 24=1 25=1 26=6 27=4 28=15 29=2 30=4 31=5 32=3 33=2 34=6 35=1 37=3 38=50 39=9328 40=290395 41=197010 42=3153 43=3 44=3 45=4 46=3 47=1 48=2 49=4 50=3 51=3 52=2 53=6 
temp: 40622
1000000
5=1 6=3 7=1 8=3 9=1 10=2 12=1 14=1 15=2 16=2 17=2 18=1668 19=156528 20=330496 21=11259 22=7 23=2 24=1 25=7 26=3 27=2 28=1 29=5 30=8 31=3 32=2 33=5 34=7 35=1 36=1 37=8 38=47 39=9374 40=290767 41=196452 42=3297 43=8 44=1 45=1 46=3 47=6 48=1 49=3 50=2 51=1 52=2 53=1 
temp: 42774
1000000
3=1 4=1 5=2 6=1 7=1 8=4 10=2 12=1 13=1 14=2 15=2 16=3 17=2 18=1724 19=165832 20=321956 21=10430 22=8 23=6 24=4 25=5 26=2 27=4 28=4 29=2 30=3 31=5 32=3 33=3 34=6 35=4 36=6 37=4 38=72 39=10872 40=303526 41=182704 42=2760 43=5 44=3 45=3 46=2 47=3 48=4 49=1 50=1 51=3 52=2 53=2 54=1 56=1 
temp: 43312
1000000
1=1 3=2 6=4 7=2 8=2 9=3 10=1 11=1 12=3 13=1 14=1 15=1 16=2 17=5 18=1693 19=166546 20=322723 21=8980 22=7 23=5 24=3 25=2 26=1 27=4 28=3 29=4 31=7 32=5 33=3 34=2 35=1 36=4 37=8 38=48 39=10378 40=311637 41=175244 42=2626 43=5 44=4 45=2 46=3 47=7 48=3 49=2 50=2 51=1 52=3 53=2 54=2 
temp: 42236
1000000
2=1 4=1 6=2 7=1 8=1 10=3 11=3 13=2 14=1 15=1 16=3 17=5 18=1776 19=164818 20=323043 21=10309 22=5 23=4 24=5 25=3 26=5 27=4 28=3 29=2 30=1 31=6 32=1 33=4 34=5 35=8 36=3 37=4 38=60 39=10688 40=303816 41=182661 42=2713 43=5 44=1 45=2 46=4 47=3 48=2 49=3 50=1 51=1 52=2 53=2 56=1 57=1 
temp: 42236
1000000
3=1 4=3 5=2 6=2 7=1 8=1 9=1 10=2 13=1 16=1 18=1718 19=163023 20=324643 21=10566 22=4 23=4 24=5 25=2 26=3 27=9 28=3 29=5 30=8 31=3 32=7 33=6 34=2 35=2 36=4 37=4 38=52 39=10647 40=302925 41=183464 42=2851 43=3 44=5 47=1 48=2 49=1 50=2 52=1 53=5 55=1 56=2 58=1 
temp: 41160
1000000
2=1 3=2 5=5 6=2 7=3 8=2 9=3 11=1 12=1 13=1 15=1 17=4 18=1707 19=159719 20=327464 21=11060 22=6 23=5 24=1 25=2 26=2 27=3 28=2 29=3 30=2 31=2 32=3 33=2 34=3 35=4 36=2 37=6 38=41 39=9889 40=294950 41=192060 42=2997 43=3 44=3 45=8 46=4 47=7 48=1 49=2 50=1 51=5 52=1 53=2 58=1 
temp: 42236
1000000
4=2 5=4 6=2 9=2 10=1 12=4 13=1 14=2 16=6 17=8 18=1644 19=163705 20=323865 21=10728 22=7 23=3 24=2 25=5 26=3 27=1 28=3 29=1 30=3 31=4 32=1 33=4 34=4 35=5 36=3 37=8 38=61 39=10489 40=300923 41=185536 42=2931 43=2 44=2 45=3 46=3 47=3 48=2 49=1 50=3 51=1 52=1 53=2 54=1 55=2 56=2 
temp: 41160
1000000
5=3 6=4 7=1 8=3 9=1 10=2 11=2 13=1 14=2 15=1 16=1 17=4 18=1669 19=163871 20=323974 21=10438 22=3 23=2 24=1 25=5 26=5 27=4 28=4 29=2 30=2 31=3 32=3 33=4 34=3 35=4 36=3 37=5 38=57 39=10643 40=303659 41=182790 42=2788 43=4 45=6 46=2 47=2 48=1 49=4 50=1 51=4 52=2 53=1 54=3 55=2 
temp: 41160
1000000
1=1 5=3 6=1 7=1 8=1 9=1 10=1 12=3 14=2 15=1 16=2 17=2 18=1675 19=153508 20=332994 21=11773 22=11 23=3 24=3 25=2 26=5 27=4 28=3 29=2 31=4 32=6 33=1 34=3 35=3 36=6 37=8 38=36 39=8759 40=284686 41=203003 42=3452 43=6 44=5 45=2 46=6 49=2 50=3 51=1 52=4 58=1 
temp: 40622
1000000
2=1 5=3 6=1 7=1 8=2 10=1 11=1 14=2 15=3 16=1 17=1 18=1623 19=153626 20=332967 21=11731 22=7 23=4 24=5 25=7 26=4 27=4 28=4 29=2 30=4 31=4 32=2 33=5 34=5 35=5 36=7 37=3 38=44 39=8699 40=284120 41=203655 42=3411 43=8 44=6 45=4 46=4 47=1 48=3 49=1 51=2 52=3 53=1 58=1 
temp: 41160
1000000
4=1 5=6 6=2 7=1 8=2 10=2 11=1 12=2 13=1 14=1 15=2 16=6 18=1688 19=155040 20=331678 21=11545 22=7 23=2 24=1 25=3 26=1 27=3 28=4 29=4 30=2 32=2 33=2 34=3 35=3 36=3 37=4 38=45 39=9090 40=286538 41=200826 42=3441 43=2 44=10 45=3 46=3 47=3 48=2 49=3 50=4 51=2 52=2 53=1 54=1 55=1 
temp: 40084
1000000
3=1 5=4 6=1 7=3 8=2 9=2 10=3 11=1 12=2 13=1 14=1 15=1 16=1 17=2 18=1677 19=155854 20=331198 21=11218 22=6 23=2 24=3 25=2 26=3 27=6 28=3 29=3 30=2 31=5 32=2 33=5 34=3 35=4 36=2 37=2 38=49 39=9286 40=290616 41=196909 42=3082 43=4 44=4 45=2 46=4 47=2 48=2 49=5 50=3 52=2 53=3 55=1 
temp: 40084
1000000
5=1 7=1 8=2 9=1 10=3 13=3 14=1 15=1 16=1 17=5 18=1766 19=156602 20=330114 21=11463 22=8 23=4 24=4 25=1 26=11 27=4 28=4 29=4 30=1 31=2 32=3 33=9 34=3 35=3 36=5 37=6 38=48 39=9344 40=289939 41=197300 42=3307 43=5 44=3 45=3 46=5 47=3 49=3 50=1 51=1 52=1 
temp: 40084
1000000
3=2 4=1 5=1 6=2 7=2 8=1 9=2 11=1 12=4 13=2 14=2 15=2 17=2 18=1712 19=152671 20=333748 21=11816 22=6 23=3 24=4 25=5 26=4 27=2 28=2 29=3 30=4 31=3 33=1 34=5 35=6 36=4 37=5 38=35 39=8703 40=284799 41=203018 42=3384 43=5 44=5 45=2 46=4 47=1 48=3 49=1 50=3 51=3 52=1 53=2 54=1 57=1 
temp: 41160
1000000
5=1 6=4 7=3 8=1 9=2 10=2 12=1 14=3 15=3 17=3 18=1654 19=155514 20=331440 21=11337 22=10 23=4 24=3 25=1 26=3 27=2 28=1 29=4 30=9 31=4 32=2 33=2 34=2 35=2 36=4 37=8 38=34 39=8947 40=285978 41=201583 42=3400 43=6 45=4 46=2 47=4 48=2 49=3 50=1 51=3 53=3 
temp: 40084
1000000
4=1 5=2 6=4 7=1 9=1 10=1 11=1 13=2 14=1 15=1 16=3 17=1 18=1702 19=160491 20=327147 21=10609 22=7 23=3 24=7 25=2 26=3 27=1 28=4 29=5 30=7 31=2 32=5 33=3 34=2 35=5 36=4 37=2 38=59 39=9795 40=297912 41=189222 42=2948 43=9 44=2 45=4 46=3 47=4 48=2 49=2 50=2 51=2 52=1 53=1 55=1 
temp: 39546
1000000
2=1 3=1 5=3 6=2 7=2 9=2 10=1 11=1 12=3 13=4 14=2 15=3 17=1 18=1646 19=156975 20=330139 21=11186 22=8 23=2 24=4 25=3 26=4 27=2 28=1 29=6 30=2 31=4 32=1 33=2 34=4 35=4 36=2 37=3 38=38 39=9068 40=289851 41=197770 42=3215 43=3 44=4 45=4 46=1 47=2 48=5 49=3 50=2 51=2 52=2 53=1 54=3 58=1 
fivdi commented 8 years ago

Starting 160 additional processes is an overkill. 4 is enough.

joan2937 commented 8 years ago

Yes, pigpio will be affected by system load, just like any other program. I haven't tried to quantify the effect. DMA timings are upset by network load. Heavy network load will affect the timing of servo pulses, particularly when the sample rate is set to 1 µs.

It's not really a surprise. Once you have contention for a system resource something has to give.

The temperature may be a mix up of cause and effect. The system being busy causes the system to heat up. Once 80 degrees C is reached the system will throttle back to reduce the risk of damage.

I'd count these sorts of conditions as outside the envelope.

You could try to mitigate by starting pigpio with real time priority and fitting a heat sink so thermal throttling is less likely.

fivdi commented 8 years ago

Here are the results of another test with 20 µs on 40 µs off 500,000 times. For this test the CPU was constantly under heavy load the entire time. It was allowed heat up to 82°C by running four process to stress the CPU before the test program was started.

As can be seen, the results for the first three batches of pulses are not the best. While the third batch was being processed, the CPU was cooled down with a heat sink (a stack of three coins were placed on top of the CPU!) The temperature reduction was enough to result in what I would regard as excellent results for the last three batches of pulses even though the CPU was constantly under heavy load.

version: 48 GPIO=18 temp: 82586 999988 1=3 2=5 3=3 4=6 5=8 6=2 7=9 8=4 9=8 10=7 11=4 12=11 13=7 14=2 15=5 16=4 17=8 18=1152 19=134578 20=357468 21=6545 22=37 23=18 24=13 25=19 26=17 27=17 28=17 29=20 30=23 31=20 32=12 33=20 34=22 35=13 36=20 37=21 38=22 39=4286 40=262271 41=229514 42=3585 43=35 44=12 45=17 46=6 47=19 48=7 49=8 50=8 51=7 52=9 53=5 54=5 55=6 56=3 57=5 58=2 59=1 99=6 temp: 82586 999988 1=2 2=8 3=8 4=4 5=6 6=6 7=3 8=5 9=10 10=8 11=7 12=8 13=10 14=5 15=5 16=3 17=9 18=1202 19=140320 20=351755 21=6467 22=26 23=12 24=19 25=19 26=19 27=22 28=12 29=15 30=12 31=15 32=18 33=21 34=21 35=18 36=22 37=18 38=25 39=4744 40=274226 41=217414 42=3288 43=20 44=11 45=16 46=6 47=12 48=9 49=15 50=8 51=7 52=8 53=4 54=4 55=9 56=4 57=4 58=4 59=2 60=1 99=6 temp: 70212 999996 3=3 4=1 6=3 7=3 8=6 10=3 11=4 12=5 16=7 17=4 18=1237 19=142916 20=349586 21=6178 22=8 23=7 24=3 25=4 26=5 27=6 28=5 29=7 30=4 31=3 32=6 33=7 34=5 35=7 36=4 37=6 38=7 39=4792 40=278133 41=213892 42=3069 43=10 44=4 45=6 46=6 47=7 48=2 49=7 50=2 51=3 52=2 53=2 54=2 55=2 58=2 99=2 temp: 74516 1000000 18=1189 19=140729 20=351927 21=6155 38=2 39=4568 40=275248 41=216894 42=3287 temp: 78282 1000000 18=1202 19=144265 20=348420 21=6113 38=3 39=4831 40=283911 41=208291 42=2963 temp: 74516 1000000 18=1157 19=132558 20=359514 21=6771 38=1 39=4046 40=259904 41=232609 42=3439

I'm going to close this issue now. Thanks for all the feedback and help.