New Rotary Encoder Library

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

New Rotary Encoder Library

Postby GreyGnome » Sun Sep 04, 2011 6:27 am

Hi,
I've created a library for small rotary encoders. You can read all about it, and download it, here:

http://code.google.com/p/adaencoder

It differs from most other code by being interrupt-driven and easy to use on any pair of Arduino pins (with caveats that the pins must share an ATmega PORT [see the source code for more info]).
Enjoy!
- GreyGnome
GreyGnome
 
Posts: 5
Joined: Sat Jul 02, 2011 12:26 am

Re: New Rotary Encoder Library

Postby adafruit » Tue Sep 06, 2011 6:40 pm

thanks we'll check this out!
User avatar
adafruit
 
Posts: 10554
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: New Rotary Encoder Library

Postby GreyGnome » Fri Sep 09, 2011 7:28 am

...Version 0.2 is now up, along with some documentation tweaks in the Wiki.
GreyGnome
 
Posts: 5
Joined: Sat Jul 02, 2011 12:26 am

Re: New Rotary Encoder Library

Postby tronixstuff » Tue Sep 13, 2011 9:08 am

You must be some sort of mind reader, someone was nagging me to help them with rotary encoders last week.
Thank you for sharing your efforts! :)
electronics, Arduino and DIY blog http://tronixstuff.wordpress.com and http://youtube.com/tronixstuff
Preorder my new book at http://www.arduinoworkshop.com
User avatar
tronixstuff
 
Posts: 47
Joined: Sat Mar 20, 2010 8:59 am
Location: Melbourne, Australia

Re: New Rotary Encoder Library

Postby tyggerjai » Wed Sep 14, 2011 11:30 pm

I second the vote for mindreader - haven't had a chance to play with it yet, but the rotary encoders are on my list for things to play with this weekend, and this should help immensely. Thanks!
tyggerjai
 
Posts: 33
Joined: Mon May 26, 2008 6:47 am

Re: New Rotary Encoder Library

Postby GreyGnome » Wed Sep 21, 2011 7:34 am

Thanks, I just finished my Arduino-based ESP hat recently. I was hoping it worked... doesn't seem to help with my wife, though :-).

Let me know how it works for you. I think the basic theory is sound but I'm a little unsure because of the missed positions I get every once in a while. The only thing I can think of is that the bouncing prevents proper registration of a full detent-to-detent click. I would be interested to know if its reliability is adequate for you.
GreyGnome
 
Posts: 5
Joined: Sat Jul 02, 2011 12:26 am

Re: New Rotary Encoder Library - v 0.3 to be posted SOON

Postby GreyGnome » Thu Sep 22, 2011 10:05 pm

...annnd, a bug. What would programmers do without bugs? Sleep, I guess.

I didn't know I needed to save and restore SREG when doing a cli(). This bit of code will be inserted and version 0.3 will be out as soon as I'm done testing.
GreyGnome
 
Posts: 5
Joined: Sat Jul 02, 2011 12:26 am

Re: New Rotary Encoder Library

Postby GreyGnome » Sat Dec 03, 2011 10:51 am

I just uploaded version 0.3.1, which now includes a PinChangeInt library aligned with the official version, and includes a bugfix in PinChangeInt.
GreyGnome
 
Posts: 5
Joined: Sat Jul 02, 2011 12:26 am

Re: New Rotary Encoder Library

Postby marmil » Wed Feb 01, 2012 4:03 am

Hi GreyGnome. I'd like to try using this under the new Arduino 1.0 software. Any plan for updated library files?
Thanks
User avatar
marmil
 
Posts: 8
Joined: Tue Feb 22, 2011 1:13 am
Location: Los Angeles

Re: New Rotary Encoder Library

Postby ranger9 » Sat Feb 04, 2012 11:45 pm

Has anyone found a way either to make GreyGnome's library compatible with Arduino 1.0, or a clean alternative solution for working with a rotary encoder?

GreyGnome's example code won't compile under 1.0, and nobody else seems to have a consensus on the best way to work with encoders; most of the solutions I've found in searches either don't work or give messy output.

I just want to use an encoder for user interfacing, not robotics.
ranger9
 
Posts: 21
Joined: Tue Nov 23, 2010 7:05 pm

Re: New Rotary Encoder Library

Postby chicago wire guy » Tue Nov 20, 2012 9:13 pm

Hi All

Happy Thanksgiving!

I am using the latest version of AdaEncoder.h w/PinchangeInt.h

I am running a DC Motor w/encoder pololu 131:1 gear motor, 64CPR item#1447 with pololu motor shield VNH5019 on a Duemilanove 328.

Basically I have the user input the perameters that set the number of revolutions needed for a run and the number of total runs needed for a batch. My problem is that after the first loop counting steps (works fine, testing by hand, not powering the motor at speed), when the loop is to be repeated the encoder steps outputs a starting point of 4294967294 instead of 0. I'v tried both the easy method and the "you like to sweat" methode on the adaencoder.h wiki. I try to set int8_t clicks back to 0 at the start of each loop but it doesn't seem to flow back to the library I guess?

Currently I am reading the outputs on the Adafruit I2C LCD (which is great and so easy to use)

I will only be running in one direction at relatively low speeds with just one motor and 1 encoder.

I can post my ugly code if anyone thinks it will help, but the problem seems to be in the reinitializing the starting point on the encoder since it works fine on the first pass through
chicago wire guy
 
Posts: 9
Joined: Wed Oct 10, 2012 11:06 pm

Re: New Rotary Encoder Library

Postby chicago wire guy » Tue Nov 20, 2012 9:22 pm

Sorry All

I found my mistake in my coding. Posting coding is really a good idea when asking for help!

I did not reset my counter inside my loop :oops:

Once I clean up my code a little, though I know it will not be as efficent as it should be, it might help someone else.
chicago wire guy
 
Posts: 9
Joined: Wed Oct 10, 2012 11:06 pm


Return to Arduino

Who is online

Users browsing this forum: No registered users and 10 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [113]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
BeagleBone[23]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]