David Bender 28 Posted June 14, 2015 Share Posted June 14, 2015 I had a lack of digital input pins for a pushbutton rotary encoder switch so I used an analog input. I wrote up my results here: https://analog10.com/posts/rotary_encoder_analog_input.html It works pretty well except for an occasional reverse tick but that's probably a flaw in my code. timotet 1 Quote Link to post Share on other sites
roadrunner84 466 Posted June 15, 2015 Share Posted June 15, 2015 Alternative: use a one-wire I/O expander and make a software library for that Quote Link to post Share on other sites
timotet 44 Posted June 15, 2015 Share Posted June 15, 2015 Great idea! Good thing your 1 left over pin was an ADC pin! Quote Link to post Share on other sites
dubnet 238 Posted June 15, 2015 Share Posted June 15, 2015 Made the Hackaday blog.... Quote Link to post Share on other sites
greeeg 460 Posted June 16, 2015 Share Posted June 16, 2015 It works pretty well except for an occasional reverse tick but that's probably a flaw in my code. The reverse ticks might be due to a "blocking" part of your code when it calls "begin_lcd_write". (Blocking probably isn't the right word.) But while your main loop is inside this function it could miss an update from the ISR. I'm probably wrong. Just a thought. I've found whenever I used rotary encoders I had to proccess the transitions quickly because there was a fair amount of phantom transitions, I was probably using very cheap rotary encoders too. Quote Link to post Share on other sites
David Bender 28 Posted June 16, 2015 Author Share Posted June 16, 2015 begin_lcd_write() just buffers data and initializes the TA0.1 IE. The LCD data are clocked in the timer interrupt handler so there really isn't any blocking. I think an improvement would be to supersample 8 times, average and then use the change in value as a determination of how far the encoder turned, rather than only comparing discrete levels. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.