element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • 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
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs Rotary Encoders - Part 4: Capturing Input on a Texas Instruments Hercules LaunchPad with eQEP
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 13 Jul 2015 5:32 PM Date Created
  • Views 1465 views
  • Likes 4 likes
  • Comments 3 comments
  • rotary_switch
  • rotary_encoder
  • eqep
  • texas_instruments
  • hercules
  • launchpad
Related
Recommended

Rotary Encoders - Part 4: Capturing Input on a Texas Instruments Hercules LaunchPad with eQEP

Jan Cumps
Jan Cumps
13 Jul 2015

I've removed the rotary encoder from the scroll button of a defect mouse. Let's see how we can use that in a microcontroller design.

In post 1, I wired up the electronics.

In part 2, I'm capturing the encoder's info on a Cypress PSoC4.

In the third blog, I've used an Arduino.

In this one, I'm capturing the encoder's info with the eQEP module of a TI Hercules microcontroller.

 

image

I'm using a Hercules LaunchPad with the RM46x microcontroller, but the approach that I'm showing works with all Hercules controllers that come with an eQEP peripheral. At the end of this post, there's a solution for processors that aren't equipped with this module.

image

Extract from the TI Hercules RM46 TRM

 

The Firmware

 

Just like with my previous two attempts with the Cypress PSoC 4 BLE kit and the Arduino, it is straightforward with the Hercules.

In HALCoGen, you have to configure the eQEP module.

 

image

 

Take care that you set the eQEP pins active in the pin multiplexing tab.

 

image

 

On the eQEP tab, we configure the peripheral.

image

 

 

That's 90% of the work done. Generate the code and switch to Code Composer Studio to write the C code.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

There's really little to do there. We have to initialize the eQEP module and do regular checks to see if a new count is latched into the eQEP registers. The module does all the hard work for us.

 

/* USER CODE BEGIN (1) */
#include "eqep.h"
#include "sys_core.h"
#include <stdio.h>
/* USER CODE END */

// ...
void main(void)
{
/* USER CODE BEGIN (3) */
// uint16 deltaT = 0U;
// float velocity = 0U;
  /* EQEP initialization based on GUI Configuration. */
  QEPInit();


  /* Enable Position Counter */
  eqepEnableCounter(eqepREG1);


  /* Enable Unit Timer. */
  eqepEnableUnitTimer(eqepREG1);


  /* Enable capture timer and capture period latch. */
  eqepEnableCapture(eqepREG1);




  while(1)
  {
  /* Status flag is set to indicate that a new value is latched in the QCPRD register. */
  if((eqepREG1->QEPSTS & 0x80U) !=0U)
  {
  printf("Count %u\n", eqepREG1->QPOSLAT);


  /* Clear the Status flag. */
  eqepREG1->QEPSTS |= 0x80U;
  }
  }
/* USER CODE END */
}

 

Wiring the Hardware

 

Look back at my first post to check how to components are wired up.

Then connect the encoder with the LaunchPad.

Ground to Ground, 3.3V to 3.3V,

PINA to J11.39, PINB to J11.38.

 

image

 

Connect the LaunchPad, execute the program and Look at the CCS console.

The count is logged to the monitor on every spin.

 

 

image

Extract from the TI Hercules RM46 TRM

 

 

For those Hercules controllers that don't have this module, you can always use the generic I/O (GIO) module to capture the quadrature information. My friend martinvalencia has done that successfully.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

Content
Part 1: Electronics
Part 2: Capturing Input on Cypress PSoC4
Part 3: Capturing Input on an Arduino
Part 4: Capturing Input on a Texas Instruments Hercules LaunchPad with eQEP
Part 5: Capturing Input on an FPGA
Real World Application: Hercules LaunchPad and GaN FETs: Control Big Power with a Flimsy Mouse Scroll Wheel
  • Sign in to reply

Top Comments

  • martinvalencia
    martinvalencia over 8 years ago +1
    thank you very much for the reference, I've seen encoders with more output pins, I'm not sure if the Hercules MCU has a module for read or perhaps have to make a game between two modules eQEP . Greetings…
  • Jan Cumps
    Jan Cumps over 4 years ago

    embedded video link fixed

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 8 years ago in reply to martinvalencia

    That may have been an extra index pin. Some encoders have that to give a fixed reference that you can sync to.

    Others are a combination of encoder + push button. That would give one or two extra pins too.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • martinvalencia
    martinvalencia over 8 years ago

    thank you very much for the reference, I've seen encoders with more output pins, I'm not sure if the Hercules MCU has a module for read or perhaps have to make a game between two modules eQEP.

    Greetings and thanks for the help with the program :-)

    • Cancel
    • Vote Up +1 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 © 2023 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