Reading incremental encoder interupt


Closed Thread
Results 1 to 9 of 9
  1. #1

    Default Reading incremental encoder interupt

    Hi

    I would like to make a small project to read an incremental encoder
    with differencial A/B outputs and send its position on request via RS232

    I need to count the pulses, determinate if it is going CW or CCW
    on a serial request I need to send the number of counted pulses via RS232

    Which way shall I go:

    Use I/O ports for the A & B pulses and use a Hardware UART to handle the incoming request of the encoder (the request command is only 2 bytes)

    Or count the pulses of the encoder with an interupt based routine ?

    Any idea's are welcome

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


    Did you find this post helpful? Yes | No

    Default

    I need to count the pulses, determinate if it is going CW or CCW
    I would use the one HCTL2000 quadrature decoder/counter interface.

    See details on datasheet @ http://www.datasheetcatalog.org/data.../HCTL-2000.pdf

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default

    What type of frequency are we talking about here? If it's rather low frequency, like a knob used to navigate a user interface etc then perhaps using the 'Change-on-PortB' interrupt and decode and keep count in software. If we're talking higher frequencies, like for motorcontrol etc then you might want to look at the 18F24x1 series PICs as they have a QEI-module on board. In any case - use the USART for comms.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Last edited by Archangel; - 14th July 2009 at 07:56.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Thank you

    maximum frequency will be around 1000 Pulses/sec

    Quote Originally Posted by HenrikOlsson View Post
    What type of frequency are we talking about here? If it's rather low frequency, like a knob used to navigate a user interface etc then perhaps using the 'Change-on-PortB' interrupt and decode and keep count in software. If we're talking higher frequencies, like for motorcontrol etc then you might want to look at the 18F24x1 series PICs as they have a QEI-module on board. In any case - use the USART for comms.

  6. #6


    Did you find this post helpful? Yes | No

    Default

    I found some devices who can handle differential A/B quadrature encoders
    and give a Direction out and CLK out LS7184
    http://www.opticalencoders.com/asset...atasheet_1.pdf


    I think this device can make the job easier

    If I use this device and the USART on RB1/RB2 of an 16F628 i think I can
    use a normal I/O pin to count the clk from the LS7184
    Or should it be better to use RB0/INT as an interupt from the CLK signal
    from the LS7184 pulse counter ?

  7. #7
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default

    Hi ,
    i wrote a picbasic program to read an optical incremental encoder : it used in my DDS frequency generator ( not finished at the moment ) But the encoder piece of program works very well .
    Please note that I am not a software engineer and so the program is not optimized at all.
    Comments are in italian but it is easy to find out the encoder piece that you need.
    Pls: let me know ...
    Ambrogio
    IW2FVO
    North Italy



    Quote Originally Posted by RFsolution View Post
    Hi

    I would like to make a small project to read an incremental encoder
    with differencial A/B outputs and send its position on request via RS232

    I need to count the pulses, determinate if it is going CW or CCW
    on a serial request I need to send the number of counted pulses via RS232

    Which way shall I go:

    Use I/O ports for the A & B pulses and use a Hardware UART to handle the incoming request of the encoder (the request command is only 2 bytes)

    Or count the pulses of the encoder with an interupt based routine ?

    Any idea's are welcome
    Attached Files Attached Files

  8. #8
    Join Date
    Oct 2013
    Posts
    9


    Did you find this post helpful? Yes | No

    Default Re: Reading incremental encoder interupt

    Hi I have a problem with interrupts code in pbp.I want to count encoder ticks in both directions,I have done the code without interrupt routine and it works fine but it is to slow for greater speeds.So I tryed with INT on port B.0 but it is not working.I am useing PIC 16F877A, compiler 2.5. Here is the code which is not working.Where was I wrong?
    proba.txt

  9. #9
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: Reading incremental encoder interupt

    I used the interrupt for my low cost mechanical encoder to control my power supply.
    You can find the whole code in the attachement.
    The interrupt service routin is the following:
    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:
    if EB=0 then INC_DEC=2
    IF EB=1 THEN INC_DEC=1
    @ INT_RETURN

    Thanks to Darrel Taylor work.

    Bye
    Ambrogio
    Iw2fvo
    Attached Files Attached Files

Similar Threads

  1. decoding quadrature encoders
    By ice in forum mel PIC BASIC Pro
    Replies: 93
    Last Post: - 28th February 2017, 10:02
  2. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 15:45
  3. Instant Int and encoder (Elect. Gearing)
    By boroko in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 29th November 2009, 03:29
  4. encoder HEDL 5540
    By kutsi in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th June 2007, 15:00
  5. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 22:56

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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