Whats faster LCD or Serial Leds for interrupt counting?

General discussion on mikroPascal.
Post Reply
Author
Message
Briansw
Posts: 82
Joined: 28 Jul 2008 16:25

Whats faster LCD or Serial Leds for interrupt counting?

#1 Post by Briansw » 08 Feb 2009 20:48

Hate to bring this up but I took some time off writing code and now I'm back at it again. Still working on my encoder project using interrupts. It now appears to me that problems may exist when using an LCD display to display a changing frequency (longint count) when using interrupts to to detect encoder changes. What I appear to be noticing is the delays the LCD needs is affecting my encoder counting. On every count change (up and down) I have to display the update to the LCD. Throwing that into the loop seems to have adverse effects(missing or false counts). So, I'm thinking what about a Serial to Led display? Would that be much faster then an LCD? Or is my thinking totally off here. Whats your opinion?

Counting is very accurate as long as I don't spin the encoder knob really fast. If too fast what happens is the comparision between old and new bit patterns seems to get messed up where I can just do a single click on the encoder and the count will not update. But if I continue another click in the same direction it will update +1 for instance. And if I turn in the opposite direction one click there is no update but continuing one more click it will update -1 count for instance. So what it looks like is this.
10 10 11 12 13 13 12 11 10 10 9 8 7...... Now again this only happens after I start spinning the encoder really fast for a few seconds then slow way down to may one click per second.
Again,you think the LCD could be causing a problem because it can't update fast enough to keep up with the higher speed of the interrupts?
And would an LED display be better for displaying the count and maybe just use the LCD for other information like application settings and such.

Thanks,
Bryan

arcom
Posts: 271
Joined: 07 Dec 2007 17:00
Location: Rijeka/Croatia
Contact:

#2 Post by arcom » 08 Feb 2009 21:47

Move the code that displays count to LCD into the MAIN section instead of ISR. ISR should be as fast as possible, free from all kind of delays and further data processing. You should just increment the count variable inside the ISR and then do the processing somewhere else in the code, either in MAIN or another SUB/FUNCTION.

Briansw
Posts: 82
Joined: 28 Jul 2008 16:25

#3 Post by Briansw » 09 Feb 2009 03:27

Actually the Lcd routines(updating) is outside the ISR. Think I found the problem though. As you also said other processing occurs in the ISR. Basically count processing where I either check if 4 counts occured then increment the lcd count. This is because the encoder triggers the ISR 4 times between each click. I just want to increment my variable once per click. So some simple checking is done in the ISR that maybe slowing it down I guessing. As when I rotate the encoder fast the 0 to 4 count gets messed up. This is done for either direction of the turn. Hope I'm explaining this good. There are two variables involved that involve counting in the ISR one to count 4 interrupts between clicks and the other to either increment or decrement my main count that is displayed on the LCD. Thought you cannot pass variables to another function or procedure from an ISR? Is that right?

Thanks,
Brian

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#4 Post by piort » 09 Feb 2009 04:25

Briansw wrote:Thought you cannot pass variables to another function or procedure from an ISR? Is that right?
that the purpose of global variable ;-)

arcom
Posts: 271
Joined: 07 Dec 2007 17:00
Location: Rijeka/Croatia
Contact:

#5 Post by arcom » 09 Feb 2009 11:22

What's the PIC speed?
Can you post the code? Just the ISR part.

Briansw
Posts: 82
Joined: 28 Jul 2008 16:25

#6 Post by Briansw » 10 Feb 2009 02:15

I'll get back to you on this as I've made some changes in the ISR and still testing it. It's working faster now but maybe too fast as It's very sensitive to noise or overshooting the detent(click) position. Even just tapping on the encoder now will produce an interrupt at times. I've got an idea I want to try out. Sending the encoder outputs to an optocoupler then to Pic.

Brian

Post Reply

Return to “mikroPascal General”