2

I have a Raspberry Pi 2 Model B and want sample the GPIO 27 with 14400 samples per second. GPIO 27 is a pin with no Uart and no other before implemented funktions, i need the samples as single line.

The Problem is that linux gives my application ever few miliseconds time slice(e.g. every 15 ms or 20ms (i didn´t know it exactly)) but my application should sample the GPIO 27 ever 70µs. The Problem is now that while Linux do something other i miss 285 samples. Know someone a driver oder some other solution witch can help me to rise up the time slice for my application?

With frindly wishes sniffi

sniffi
  • 49
  • 1
  • 8

1 Answers1

2

Actually thinking about this it is potentially fairly trivial.

With pigpio you could just set up a callback on GPIO 27 (C, Python).

That will give you a stream of time-stamped level changes. You can just interpolate between the level changes to work out the intermediate sample values.

E.g. if the last level change was at time 1678000 microseconds and the level becomes 1 at time 16788543 then you know that any samples due between 1678000 and 16788542 were at level 0.

This is pretty much the same technique used by pigpio to bit bang incoming serial data on arbitrary GPIO.

joan
  • 71,852
  • 5
  • 76
  • 108