Reading PWM-Signals on Stamp 9G45

Hello out there,

I'm trying to read some acceleration from a sensor whose output is a 100Hz PWM signal. For it is alwasy the same period time, I just need to meassure the high level half wave. First idea was to just check the edges, starting a timer when a rising edge appears and stopping it when the falling edge is detected.

Now, there is some trouble meassuring that time. For testing, I tried with the time between two rising edges and then between two falling edges. The results in both were nearly almost 10ms and fits in the all over period time of the signal. But when I meassure between a rising and then the falling edge, I nearly never get the 5ms I expect, when sensor is not accelerated and theres no tilt over the meassured axis. There are results which are always multiples of 10ms higher than expected what leads me to think, there are several falling edges not detected until the second timestamp appears. I don't think the board is too slow for this and I'm wondering cause the 10ms period is meassured pretty good.

Does anyone have a clue on what that could depend?

My next idea is to try using interrupts on the gpio-pins. Is there a way to use interrupts from userspace applications or setting up my own isr? Or do I have to use something like poll() to wait for an interrupt to appear to use something like a fake isr?

Thanks in advance


Re: Reading PWM-Signals on Stamp 9G45

The 10ms periods result from the multitasking time slices. You achieve finer resolutions by enabling high resolution timer in your kernel.

However, the best solution seems to be to write a kernel driver that uses the Timer/Counter in capture mode to measure signals on TIOA.

Syndicate content