Reading GPIO with microsecond timing.

  • I would like to time the state changes of a GPIO pin (e.g. low for 120us, high for 888us, etc). With a raspberry pi I would use wiringpi2.micros() to do this. What would be the best way (python or c) to do this with an Omega2? Thanks!

  • @Nathanial-Hendler There may not be a solution for this right now.

    To do it right, you would need to monitor the pins with an interrupt, and have a tight ISR check whatever the highest resolution timer is, then report to something that runs more leisurely.

    But it's not clear if interrupts on GPIO are really supported; system components seem to poll them, and the userspace GPIO interface you may be familiar with from the pi does not seem to work (that would probably also be too slow, but if it worked something using the same capability in kernel would be more appropriate).

    A $1 practical solution would be to hang just about any microcontroller on an available serial, I2S, or SPI interface or even the USB, have that time the events, and report the timestamps more leisurely to your Linux-based software. If you use serial or USB, and advantage of this sort of approach is that you can test your whole scheme on a PC without cross compiling for the omega. Meanwhile a potential disadvantage is that while you find out when the events happened with high precision, there's delay of a millisecond or more in that information making it's way to you. So you have great records, but don't quite know about things as they happen.... which may be good or bad, depending on your application need.

Log in to reply

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.