Author Topic: Axon: Interfacing Quadrature Encoders  (Read 3364 times)

0 Members and 1 Guest are viewing this topic.

Offline klove1Topic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Axon: Interfacing Quadrature Encoders
« on: November 15, 2009, 04:39:43 AM »
I just got my encoders and my Axon this week WooHoo!

I am brand new with robotics, but have a little programming and electrical knowledge.

I am trying to come up with a program that will count the number of encoder clicks from these quadrature shaft encoders
http://www.robotshop.us/PDF/rbsol01_manual.pdf
mounted on the rear shaft of these motors.
http://www.robotshop.us/PDF/rbsol02_manual.pdf

I have checked the Avr encoder library and it says it uses one of the encoder outs as the clock for sampling the other i don't want to do this as it defeats the purpose of using quadrature encoders in the first place for bidirectional data also it needs an external clock input which i don't see on the axon although i haven't really looked

the biggest issue i have is not knowing how to sample the input and how to do this constantly while still running a motor control algorithm
do i need a separate processor or chip? and then just retrieve the count from it? or can i do this all on one inside my control algorithm or with a timer somehow?

I am pretty ignorant of the hardware

my current idea is to sample the input and look for state changes then increment or decrement a count based on the state change from low to high.

here is my pseudo code for getting the data

set a=0,b=0,count=0
while(1)
{   
   sample porta and portb(how?)
   if porta!=a
      if(a=0)
         a=1
            if a>b
               inc count
            else
               dec count
      else
         a=0
   if portb!=b
      if b=0
         b=1
            if b>a
               dec count
            else
               inc count
      else
         b=0
}
   
also at the same time

Control Motor Function()
{
while(1)
   {
   Get count
   calculate stuff
   move a bit
   }
}

I also need to find some wire connectors to conect to the Axon pins if someone could point me in the right direction

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: Axon: Interfacing Quadrature Encoders
« Reply #1 on: November 15, 2009, 05:11:51 AM »
this is just one of hundreds.

http://www.futurlec.com/ConnHead.shtml

You will need some header connectors and some female headerpins, for now you can use wires to crimp them but if you plan to do this stuff alot a crimping tool is much easier.

Other places are Digikey.com and mouser electronics - google them to find the site.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,704
  • Helpful? 173
    • Society of Robots
Re: Axon: Interfacing Quadrature Encoders
« Reply #2 on: November 15, 2009, 08:43:48 PM »
For a beginner, you definitely didn't choose an easy project!

Ok, I'll give you a bunch of things to chew on and read up on, and hopefully it'll get you to the next step.

AVRlib has a quad encoder library. I haven't tried it myself, but you might be able to use that directly.

To detect encoder pulses efficiently, the best way to do it is using external interrupts. The Axon has 8 external interrupts. If you look at the pinout gif in the datasheet, you'll find 8 pins that have 'INT#' next to it. UART 1 doubles as an external interrupt, for example. You then use the timer to measure the time between external interrupt pulses (probably the clock which you read about).

WebbotLib also has code to support what you need. Look at the manual under the Encoders section for instructions.

Lastly, do reading on how to do PID with encoders.

hope that helps!

Offline klove1Topic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: Axon: Interfacing Quadrature Encoders
« Reply #3 on: November 16, 2009, 01:16:11 AM »
thank you both for the feedback. I'm gonna go check the datasheet and learn how to use the external interrupts and buy some headers.
For a beginner, you definitely didn't choose an easy project!

I agree i tried to convince my professor of that too heh

Thanks again

Kyle

Offline klove1Topic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: Axon: Interfacing Quadrature Encoders
« Reply #4 on: November 18, 2009, 04:41:13 PM »
The best method I came across for doing this is using a separate IC up/down encoder click counter with a serial output. I have heard these exist, but I have been unable to find one can anyone point me in the right direction.
« Last Edit: December 03, 2009, 05:58:33 AM by klove1 »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,704
  • Helpful? 173
    • Society of Robots
Re: Axon: Interfacing Quadrature Encoders
« Reply #5 on: November 18, 2009, 09:25:17 PM »
The best method I come across for doing this is using a separate IC up/down encoder click counter with a serial output. I have heard these exist, but I have been unable to find one can anyone point me in the right direction.
The old way is to use a counter IC:
http://www.mouser.com/Semiconductors/Integrated-Circuits-ICs/Counter-ICs/_/N-6j74p?Keyword=counter+ic&FS=True

I'm sure there is a new way, some encoder counter IC available if you google around . . .

 

SMF spam blocked by CleanTalk