Re: bitx and ubitx encoder replacement / Software Issues (too slow)
toggle quoted messageShow quoted text
Keep in mind that the delay() function is a blocking function. That it, it uses its own interrupt service routine so if you're using an ISR for your encoder and it calls delay(), all kinds of weird things can happen, all usually bad. This is while I wrote MyDelay() which is constructed from non-blocking calls.
On Friday, August 23, 2019, 8:37:39 PM EDT, Sascha Bohnet | DL5SMB via Groups.Io <saschabohnet@...> wrote:
So, I played some more and found a simple solution that works for me.
As I could not figure out, why the new library was not working, i rewired the encoder to the analog inputs
and reloaded the original code - but, based on my earlier findings, made two changes:
Within the enc_read() function, I changed both delay(1) commands to delayMicroseconds(1),
so the function looks like this.
With this change of code I seem to get my 100 pulses per rotation - though the faster I go the more pulses get swallowed.
But I think this workaround is bearable :-)
I also tried fiddling around with the millis(), exchanging them for micros(), but this was more pain than it was worth,
though maybe I just tried the wrong values (I tried 1 and 500 instead of the default 50).
Maybe this helps someone - I just wanted to document what I found for everyone else who does not have too much experience in programming.
Join BITX20@groups.io to automatically receive all group messages.