element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Smarter Life
  • Challenges & Projects
  • Design Challenges
  • Smarter Life
  • More
  • Cancel
Smarter Life
Blog Smarter Life Challenge - Reading an Encoder
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: PaulMakesThings
  • Date Created: 18 Nov 2013 4:17 AM Date Created
  • Views 676 views
  • Likes 2 likes
  • Comments 5 comments
  • psoc4
  • smarter_life_challenge
  • smarter_life
  • auto_barista
Related
Recommended

Smarter Life Challenge - Reading an Encoder

PaulMakesThings
PaulMakesThings
18 Nov 2013

Implementing Encoders

 

This part is basically an amalgam of existing bits I got from example code. I've tested out that I can get it to read my encoders. It looks good as long as I don't need to use this method with more than one encoder at once. To start I just set up a UART connection, which I read with PuTTY. Getting the encoder to read was surprisingly simple. My project is attached, this is highly based on existing example code from cypress. Once I set the pins in the .cysch tab and plugged in the appropriate wires from the encoder data sheet, it started giving me counts. The clock feeding into QuadDec1 mainly determines how fast you can get away with spinning the encoder. There is a hardware interrupt driven encoder tutorial that solves the limitation on the number of encoders and improves the pulse rate it can handle here, I may try it next.

image

Here's the info I collected for the encoder I was using copied from the PITTMAN datasheet. My encoder was without an index (incremental), so listing each connection from encoder to pioneer board it was Ground(1) to GND, Channel A(3) to P2(0)-QuadA, Channel B(5) to P2(1)-QuadB, Vcc(4) to 5V+. If you aren't familiar with the process, I made P2(0) match QuadA by naming an input QuadA in the schematic, then assigning it to P2(0) in the pin diagram by choosing it in the menu at the right.

 

image

One other thing I should note is that for the UART bridge you have to add a pair of jumpers. The whole communication part of this is just a copy of the USB-UART tutorial found here. It's just modified to read out my encoder variable. Once it's running you just need to go to PuTTY, hyperterminal or another serial communication app and set it to serial, 9600 baud (unless you change it by clicking on the UART object), and setting the port to whatever it says in your device manager under Ports (COM & LPT) > KitProg USB-UART. Here's the readout I got spinning the motor, I set it up to roll over at 1 revolution.

 

image

Next up: Some of my hardware should come in next week so I can start building mechanical parts, and some of the off board circuitry. I'm considering making a burr grinder since they are so expensive and I have the tools. I'll see how feasible that turns out to be. As I mentioned before I'm controlling some things other than the grinding and brewing of coffee, so I'll be implementing a humidity sensor as well.

Attachments:
EnoderTest.zip
  • Sign in to reply
  • juanes.pazj
    juanes.pazj over 11 years ago in reply to PaulMakesThings

    I got the same trouble! the thing was that the itoa function has to be included in the code it was not included in the libraries

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • PaulMakesThings
    PaulMakesThings over 11 years ago in reply to juanes.pazj

    I'm mainly using this here because it worked quickly, I got some errors when I tried itoa, I included stdio and stdlib, but it said it was an unknown function. I'm sure it's an easy fix, but this worked first.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • juanes.pazj
    juanes.pazj over 11 years ago in reply to vsluiter

    You have 4UDBs that could be one full Quadrature Decoder (A,B,I)I believe, but then there are 4 TCPWM Quadrature Decoders as well

    Paul I worked with UART as well but the problem I found out was that when you work with sprintf() you consume too much memory try working with atoi and itoa for a lighter code!

    nice example some how I cant seem to read my encoders I'll give this code a shot.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • vsluiter
    vsluiter over 11 years ago

    Nice demo, and thanks for attaching the code. Having dealt with encoders myself, I'm very happy to see encoder components embedded in microcontrollers! Not missing pulses anymore is very benificial for control algorithms.

    How many of these quadrature decoders can you place in one PSOC4 / PSOC5?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 11 years ago

    Hi Paul,

     

    Good update.  Its good to see that the quad decoder circuit on the PSOC works as advertised.

     

    I first encountered the quad encoding back in 1972 when we interfaced three stepper motors to build a 6 Dof gimbal for testing optical devices.

    We used those old TTL circuits to decode the direction and movement.  It was a fun little project.

     

    Thanks

    DAB


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube