View topic - quadrature encoder counting problem

quadrature encoder counting problem

anything that doesn't fit to other groups.

quadrature encoder counting problem

Postby davy » Sun Mar 28, 2010 9:32 pm

I am trying to track the position of a quadrature encoder using edge-triggered (rising & falling) interrupts on the gpio pins of the beagleboard. At the moment, it counts fine if the encoder rotates slowly. If the change is fast, the count "skips" or the interrupts get "stuck". My estimate for the speed of interrupts is roughly 10kHz. So that's about 10us between interrupts for the handler to process. I am not exactly sure what the problem is... I suspect that there is too much overheard in scheduling the handler or there is not enough time for the handler to finish before the next interrupt or both.

In system profiler, I can see that the time for the ISR and handler to complete is about 40us. Is this normal?
davy
New Member
 
Posts: 5
Joined: Sun Mar 28, 2010 11:12 am

RE: quadrature encoder counting problem

Postby juanplacco » Mon Mar 29, 2010 2:25 am

That's too long... some things to verify comes up to my mind:

1) Check de priority of your adquisitor process. (it has to be grater that any other non critical process.. such as graphics or other stuffs ?)

2) Your ISR has to be AS SHORT AS you can. Check the docs.

3) Check the granularity of your configuration (ticksize), BTW, wich version of QNX are you using?

4) I don't know your hardware but I'm sure you can handle that pulses train...

I remember that I did that kind of things many years ago (4.25)... and you can be sure it was faster than that.

Regards,
JM
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

RE: quadrature encoder counting problem

Postby maschoen » Mon Mar 29, 2010 5:01 pm

I agree, something is wrong. Interrupts have a priority too. If you have another driver that is not well written, you want your interrupt to be at a higher priority. I don't think you will have this problem with anything written by QNX. I don't recall how you choose the highest priority interrupt with QNX 6, but I'm sure it is documented somewhere. It is probably a parameter to proc.
maschoen
QNX Master
 
Posts: 2715
Joined: Wed Jun 25, 2003 5:18 pm

RE: quadrature encoder counting problem

Postby mario » Mon Mar 29, 2010 7:49 pm

Heu 10kh is 100us not 10us.

If you ISR last 40us the interrupt will take about 50% of the cpu usage. I find 40us to be a very long time to spend in the ISR, but then again you aren't talking about a fast machine. 10000 interrupts a seconds is a lot to ask for such a machine.

Warning: crazy idea : Find a way to transform the encoder input into an audio signal and use DMA to record audio. I am assuming that audio recording is done via DMA.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

RE: quadrature encoder counting problem

Postby davy » Mon Apr 12, 2010 10:28 am

Thanks for all the suggestions.

I have decided to use a dedicated microcontroller for counting.
davy
New Member
 
Posts: 5
Joined: Sun Mar 28, 2010 11:12 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 3 guests