Rotary encoder help (not 'counting steps)


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2009
    Posts
    19

    Default Rotary encoder help (not 'counting steps)

    Hi all, I'm after a little input as to how i can achieve some speed tracking of 2 axes moving with rotary encoders. Think of these 2 encoders mounted on a movable x,y table. I want to be able to track the speed of the table - direction is ok too but is not needed.

    The table is only moving slow, maybe a max of about 3cm/s. the encoders i have are >1000 pulse/rev but precision is not too important, the table is moved by hand and the speed will be converted to an eight bit value. The actual values i get are not really important. i.e i don't need to know the real world speed just a number that represents that speed.

    My 'theory' was to only use an a or a b output on the encoders and use a simple pulsin function on each but i'm not sure this will do what i want - i think pulsin is more designed for much higher frequencies (but i have never used it). Also, i am not sure if this will work reading 2 sensors.
    I guess i could do fixed time sampling and count pulses in that time too but i don't really know how to do that. interrupts i spose but once again, i've never dealt with interrupts.

    I'm not expecting someone to do this for me, i'm looking for ideas for method of attack. If anyone has a theory on how i can do this, i'd love to hear it.

    Thanks

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    You could use "INTERRUPT ON CHANGE" which uses portB.4 to portB.7. You could connect Chan A of X axes to portB.4 and chan B of same axes to portB.5 while axes Y will use portB.6 and portB.7 in the same way.

    In the interrupt routine you will increment a variable for X axes and one for Y axes. using the timer0 or timer1 overflow you will read the variable and extract the speed, once you have done that you will zero both variable for the next reading.

    Since you will count both channels you will be able to detect also the direction setting a direction flag in function of the channel sequence.

    As far as interrupt on change, is concerned you could take advantages from Darrel Taylor instant interrupt routine, simple to use and very relaible indeed.

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Sep 2009
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Excellent, Thanks Al! that's exactly the headstart i needed. Time to get coding... (and checking out how these interrupts work...)

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    SteveB might have something for you that goes along with arrati's suggestion ...

    http://www.picbasic.co.uk/forum/show...5396#post25396
    <br>
    DT

  5. #5
    Join Date
    Sep 2009
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Thanks DT, that's pretty darn close to what i need.
    Last edited by Elnino; - 26th October 2009 at 22:31.

Similar Threads

  1. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 14:45
  2. Calculate Distance Using Rotary Encoder
    By guanerrr in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 4th May 2012, 16:40
  3. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 21:56
  4. Farnell's Rotary Encoder 733-726
    By crematory in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th October 2005, 13:51
  5. Automotive quality rotary encoder
    By d1camero in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th October 2004, 15:46

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts