To test the RPi GPIO delays I used this short code
#include <pigpio.h>
int main(void)
{
gpioInitialise();
gpioSetMode(2, PI_OUTPUT);
for (int i = 0; i < 10000000; i++)
{
gpioWrite(2, 1);
gpioWrite(2, 0);
}
return 0;
}
The compiled program ran on Pi Zero with no other programs on the background. Output was captured with the logic analyzer and it doesn't look so good
I ran the parser on the captured output writing precise timings to a file, this snipper shows average output
time: 0.125000 µs, state: 0
time: 1.000000 µs, state: 1
time: 0.125000 µs, state: 0
time: 0.250000 µs, state: 1
time: 0.125000 µs, state: 0
time: 0.250000 µs, state: 1
time: 0.125000 µs, state: 0
time: 0.250000 µs, state: 1
time: 0.125000 µs, state: 0
time: 0.125000 µs, state: 1
time: 0.250000 µs, state: 0
time: 0.125000 µs, state: 1
time: 0.250000 µs, state: 0
time: 0.125000 µs, state: 1
time: 0.250000 µs, state: 0
time: 0.125000 µs, state: 1
time: 0.250000 µs, state: 0
time: 0.125000 µs, state: 1
time: 0.250000 µs, state: 0
time: 0.125000 µs, state: 1
time: 0.250000 µs, state: 0
time: 0.125000 µs, state: 1
time: 0.250000 µs, state: 0
This doesn't look so bad. But when sorting the output you'll start to notice that the output is not stable. At most the delay is about 4300 times more than expected.
$ cat capture.txt | awk '{if ($2 > 100) {print $2}}' | sort -n 101.000000 104.125000 105.875000 107.125000 108.375000 109.250000 109.500000 110.500000 110.875000 112.750000 114.625000 114.750000 115.250000 115.625000 117.750000 120.250000 121.500000 122.000000 122.750000 123.500000 133.375000 142.125000 146.875000 148.625000 149.250000 149.375000 149.875000 194.250000 200.625000 207.625000 230.625000 236.125000 236.500000 269.875000 351.750000 445.500000 451.500000 538.625000
And this is on an idle Pi Zero (load avg 0.09), imagine the delays on a Pi with more load. It could work sometimes, but I need to trust that the remote works without failures more than 99% of time. Looks like the remote needs a separate microcontroller.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.