Documents

How to Use a Quadrature Encoder _ Let's Make Robots!

Description
encoder datasheet
Categories
Published
of 6
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
  How to use a quadrature encoder Login or register to post comments  by OddBot Collected by 49 users sensor, rover, rotation, Encoder, quadrature, measure Tip/walkthrough By OddBot@ January 3, 2011measures speed / distanceA quadrature encoder, also known as an incremental rotary encoder measures the speed and direction of a rotating shaft. Quadratureencoders can use different types of sensors, optical and hall effect are both commonly used. The photo shows inside of a Rover 5gearbox. There are two IR sensors on the PCB that look at the black and white pattern on one of the gears. No matter what type ofsensors are used the output is typically two square waveforms 90°out of phase as shown below.Start HereRulesTopTipsRobotsSomething elseBlogsReviews3D print clubChallengesForumsRecentAboutMy AccountMy stuffHome SearchUser login Username: *Password: * Create new accountRequest new passwordLog in using OpenID Recent blog posts super fast robotic arm!Using the Arduino PIDLibrary for preciseposition control of X andY axis on RepScrapprinterA simple HTTPcommunication protocolbetween wifi and ArduinoFurther Progress onframing my RepScrap3D printer.Arduissimo: MultiCoreArduino indiegogoprojectYahmez Goodies!Robots Ready toRumble!Xinjiang, robots andbombs!My Repscrap: DCmotors and rotaryencoders for Z-Axis too?Why I Respect my RobotEldersmore Recently submittedlinks: RC Tank ChassisCrawler IntelligentBarrowload TractorObstacle CaterpillarWall-e InfraredUltrasonic Patrol2D Ruben tubeControl Your Robot WithNode.js - Raspberry PI How to use a quadrature encoder | Let's Make Robots!http://letsmakerobots.com/node/240311 of 65/15/2014 2:24 AM  If you only wish to monitor the speed of rotation then you can use either output and simply measure the frequency. The reason forhaving two outputs is that you can also determine the direction of shaft rotation by looking at the pattern of binary numbers generatedby the two outputs.Depending on the direction of rotation you will get either: 00 = 0 01 = 1 11 = 3 10 = 2or 00 = 0 10 = 2 11 = 3 01 = 1By feeding both outputs into an XOR gate (exclusive OR) you will get a square wave with twice the frequency regardless of direction.This can be useful as it allows one interrupt pin to monitor both encoder inputs.and ArduinoPoppy Project - OpenSource Humanoid robotRoboRium - The RobotEmporiumHackaday in ShanghaiKickstarter: MicroView:Chip-sized Arduino withbuilt-in OLED Display!A comprehensivepath-finding library. (linksto python and javascriptsource)Conductive Ink ... is yourBath Sponge SafeFoxyTronics Who's online There are currently 27 users  and 21 guests   online. Online users Polar VortexmintveltDan MDuane Degnlamorak24unix_gurulazdHackgarhoff70gamborgkariloyHaZZaRoxanna77fritsllukeyes jscottbLadvienGromerbirdmunPhotolongTinHeadbstaghoff70ossipeeLadvienmogulwebmaster Quick links LMR on Google+LMR on FacebookLMR on FlickerLMR on TwitterLMR ScrapbookUser listUnread postsRSS feedsSpam Control How to use a quadrature encoder | Let's Make Robots!http://letsmakerobots.com/node/240312 of 65/15/2014 2:24 AM  I was looking at how to write efficient code to convert these binary inputs into a simple forward or backward output. I ended up witha 2 dimensional array (matrix) that made the code quick and easy.The binary values above convert to 0,1,3,2 or 0,2,3,1 depending on the direction. This pattern repeats continuously. By using thecurrent value from the encoder to index one dimension of the array and the previous value to index the other dimension you canquickly get a -1, 0, or +1 output. My array looks like this.As you can see, if the value has not changed then the output is 0.The sequence of 0, 1, 3, 2 gives an output of -1.The sequence of 0, 2, 3, 1 gives an output of +1.X represents a disallowed state and would most likely occur if the encoder outputs are changing too quickly for your code to keep up.Normally this should not happen. In my code I put a 2 here. When I get an output of 2 I know that I got an error, perhaps due toelectrical noise or my code being too slow. If you replace X with 0 then the disallowed state will be ignored.In my Arduino code I make this a 1 dimensional array. that looks like this: How to use a quadrature encoder | Let's Make Robots!http://letsmakerobots.com/node/240313 of 65/15/2014 2:24 AM  int QEM [16] = {0,-1,1,2,1,0,2,-1,-1,2,0,1,2,1,-1,0}; // Quadrature Encoder Matrix To read the array my index is: Old * 4 + NewSo my code reads like this:Old = New;New = digitalRead (inputA) * 2 + digitalRead (inputB); // Convert binary input to decimal valueOut = QEM [Old * 4 + New];Good luck and enjoy. Comment viewing options  Select your preferred way to display the comments and click Save settings to activate your changes.By Hyvok@ Tue, 2012-07-10 15:03 Tool for creating optical encoder discs Login or register to post comments Thanks for the tutorial! If someone wants a simple way to make encoder discs check out my post about an extension that I wrote forInkscape: http://www.dgkelectronics.com/inkscape-extension-for-creating-optical-rotary-encoder-discs/ You can make single- and dual-track (quadrature) encoders with it, in any size/number of segments.By chrisc@ Sun, 2012-05-20 12:51 thx for the help! Login or register to post comments I've been building my own quadrature encoder and this was awesome! Thanks OddBot! Info is here if anyone wants a look - it covers building the encoder and then uses the work OddBot did above to read it:http://robotblogging.blogspot.co.uk/2012/05/quadrature-encoder.htmlBy afeibig@ Mon, 2012-02-20 03:59 Im I allowed to use the article elsewhere? Login or register to post comments Hi, I'm new in the site, and i like to use some parts of this article to write another one, about my own encoders for a personalprojecto, obviously respecting you as the owner. Thanks in advice. By OddBot@ Mon, 2012-02-20 12:55 No problem. The information Login or register to post comments No problem. The information is posted here for everyone to learn from.By Anas@ Sun, 2012-01-08 16:56 How to use a quadrature encoder | Let's Make Robots!http://letsmakerobots.com/node/240314 of 65/15/2014 2:24 AM
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x