Alexander Hiam   Jason Kridner :

@Alex_Hiam @Jason_Kridner : Any idea how to use timer interrupts from Python on the BBB?
I am trying to create a PID loop to drive some motors and was using Adafruit for the initial coding. I am stuck on a point where I would like to use Timer Interrupts to execute certain functions at fixed intervals
https://forums.adafruit.com/viewtopic.php?f=49&t=86332

You shouldn’t use interrupts from userspace. See http://man7.org/linux/man-pages/man7/time.7.html and clock_nanosleep. You can use these from Python via ctypes.

Have you thought about making a PID kernel driver? I’m surprised I haven’t seen it done and maybe I’ve just missed it or missed why it is a bad idea. It seems you could make GPIOs and PWMs selectable for common DC motor drivers and use kernel-level interfaces to the eQEP or other feedback mechanisms. I think @Dronecode_Project is doing everything in userspace or with the PRUs, but much of it seems like it should go in the kernel to me. Perhaps @Andrew_Tridgell might have something to say about where a PID loop should go in a Linux system? I know @James_Strawson (https://github.com/StrawsonDesign/Robotics_Cape_Installer) also performs a PID loop in userspace.

Anyway, what @Jan_Lubbe says about using the Linux timers probably makes sense, unless you were going to make a parallel executive (ie., not Linux). Introducing more interrupts to Linux probably just slows things down.

@Jason_Kridner interesting idea!