go_away

Author Topic: Quadrature encoder library writing  (Read 729 times)

0 Members and 1 Guest are viewing this topic.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 357
  • Helpful? 10
Quadrature encoder library writing
« on: April 13, 2012, 07:26:36 AM »
Howdy,

I'm writing my own quadrature encoder functions as part of a software library (you have NO idea how much I'd rather just use webbot, but I'm doing this on an ARM Cortex and no in in the world has ever written lucid code that I can copy for the cortex :-P )

I've got it ticking and reading on interrupts, which is great, but I'm only getting 1/2 the number of ticks per revolution that I expect.  The basic algorithm is:

ON INTERRUPT
     If: DIRECTION_PIN == 1
            EncoderTicks++
     ELSE
            EncoderTicks--
END

Am I supposed to just add twice?  Or...do BOTH pins act as interrupts?

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline joe61

  • Supreme Robot
  • *****
  • Posts: 417
  • Helpful? 16
Re: Quadrature encoder library writing
« Reply #1 on: April 13, 2012, 08:25:44 AM »
I don't know what processor specifically you're using, but you might need to set it up to get an interrupt on both the rising and falling edges. Just a guess.

Joe

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 357
  • Helpful? 10
Re: Quadrature encoder library writing
« Reply #2 on: April 13, 2012, 11:43:25 AM »
Hm, maybe?  Is that how things normally work with quadrature encoders?
Current project: tactile sensing systems for multifingered robot hands

Offline joe61

  • Supreme Robot
  • *****
  • Posts: 417
  • Helpful? 16
Re: Quadrature encoder library writing
« Reply #3 on: April 13, 2012, 12:02:53 PM »
I've only used the Pololu wheel encoders, and that was a long time ago. Each encoder has two sensors 90 degrees out of phase to tell direction. There are two external interrupt pins per encoder, which I think are setup to count both rising and falling edges, but it's been a long time since I used them.

I guess it depends on the encoders you're using.

Not much help I guess, sorry.

Joe

Offline joe61

  • Supreme Robot
  • *****
  • Posts: 417
  • Helpful? 16
Re: Quadrature encoder library writing
« Reply #4 on: April 13, 2012, 03:19:25 PM »
Out of curiosity, what processor are you using?

Joe

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 357
  • Helpful? 10
Re: Quadrature encoder library writing
« Reply #5 on: April 13, 2012, 06:26:49 PM »
It's an ARM Cortex M3 based processor, the STMP103...something or other by ST Microelectronics.  It's a neat little thing, but for the most part I have to do everything from scratch (except PWM, although it's horrifying how complex the code to someone who is used to webbotlib :-P)

On the upside, 1/2 of the counts is all I need, really, since position control can be inaccurate.  I've heard tales of the STM* controllers having encoder inputs on them, although I haven't the foggiest clue of how to use them.  They are, shall we say, poorly documented :-)

MIKE 
Current project: tactile sensing systems for multifingered robot hands

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
4891 Views
Last post January 18, 2009, 01:12:36 AM
by krich
15 Replies
2221 Views
Last post June 21, 2010, 10:25:04 AM
by Webbot
2 Replies
887 Views
Last post March 02, 2011, 08:31:26 AM
by waltr
3 Replies
1163 Views
Last post February 13, 2012, 03:58:09 PM
by galannthegreat


Get Your Ad Here