How to get encoder direction and speed / rpm ? ( with DT INT ?)


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52

    Default How to get encoder direction and speed / rpm ? ( with DT INT ?)

    Is there any simple way (minimum code) to get encoder direction and speed / rpm , not position ?

    Encoder is incremental type , output are A,B,Z

    I am thinking about using DT INT , but not sure where to start .

    Could any one point me which direction to go ? Thank you

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: How to get encoder direction and speed / rpm ? ( with DT INT ?)

    Hi,
    Since you're not interested in position one simple way would be to count pulses from one channel for a certain amount of time. The direction could then be determined by polling channel B at the rising edge of channel A - or the other way around. What kind of speeds we're talking about. A couple of 100Hz or several 100kHz or even more? What else is the PIC going to do?

    Which PIC are you using? If you haven't decided on one yet then one option is to have a look at the 18F2431 series, it's got a quadrature encoder interface peripheral.

    /Henrik.

  3. #3
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: How to get encoder direction and speed / rpm ? ( with DT INT ?)

    Thank Henrik !

    I am planning to use 16F88 , but I will look at 18F2431 as your suggestion

    As for the speed , it just 0 - 10 rpm max , with 100 count encoder.

    The pic will then output led indicator direction and speed low - med - high according to rpm , that simple

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: How to get encoder direction and speed / rpm ? ( with DT INT ?)

    Oh, in that case there's no need for the 18F2431, it would be overkill.
    Set one of the PICs timers up as a counter and feed the pulses from one channel to it, then read its value at precise intervals and you have the velocity. Or use the Count command to Count pulses for a certian amount of time. Or, instead of counting pulses, use the capture module to measure the length of ONE pulse. Or use PulsIn to do the same thing, or.....

    /Henrik.

  5. #5
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: How to get encoder direction and speed / rpm ? ( with DT INT ?)

    Hahaha, yes indeed 18F2431 would be overkill

    Okay, the issue with rpm is clearer now, but what about direction ?

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: How to get encoder direction and speed / rpm ? ( with DT INT ?)

    Like I said earlier, read the state of channel B at the rising edge of channel A and you have the direction.

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: How to get encoder direction and speed / rpm ? ( with DT INT ?)

    rotary encoders woes are a common issue have a look at this thread


    http://www.picbasic.co.uk/forum/showthread.php?t=13177

    secondly if your encoder is mechanical type contact bounce is an issue that must be dealt with

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: How to get encoder direction and speed / rpm ? ( with DT INT ?)

    Also at this PIC:

    http://www.microchip.com/wwwproducts...cName=en010291

    It has Qudrature Encoder Interface and hardware filters too!

    Ioannis

Similar Threads

  1. how to measure RPM and SPEED at the same time
    By teeeeee in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th July 2012, 08:34
  2. Using both hardware int and Timer Int together?
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th January 2010, 01:09
  3. Instant Int and encoder (Elect. Gearing)
    By boroko in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 29th November 2009, 02:29
  4. Replies: 0
    Last Post: - 7th August 2008, 09:02
  5. Can someone tell me if I am going in the right direction?
    By MatthewM in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 22nd June 2008, 15:11

Members who have read this thread : 0

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