Encoder pin out question


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2007
    Posts
    56

    Default Encoder pin out question

    Hi,

    I just got an incremental encoder, Bourns type PEC 11 ( 2 bit gray code ) and I'd like to experiment with it , but I never see an encoder before

    It has 3 legs marked A,C,B ( on datasheet ) ,could anyone kindly tell me how to connect it ?

    Thank you,

    Johan

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


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Connect A & B to your PIC inputs and pull them low with, say between 1k & 10k. Connect C to Vdd and you should be in good shape. Here's a datasheet for it.

    /Henrik Olsson.

  3. #3
    Join Date
    Jun 2007
    Posts
    56


    Did you find this post helpful? Yes | No

    Default

    Thank you Hendrik,

    I have done as you suggest, but I could not get result with my code below.

    I found the code somewhere , and I tried to port to PBP, I am not sure if it is correct
    I use PIC 18F4431



    DEFINE OSC 16 ' Oscilator HS
    clear
    TRISA = %00000000 ' Set PORTA to all output
    TRISB = %00000011 ' Set PORTB.2 -7 to output
    TRISC = %00000000 ' Set PORTC to all input
    TRISD = %00000000 ' Set PORTD to all output
    TRISE = %00000000 ' Set PORTE to all output

    ANSEL0= %00000000 ' Analog channel AN0-AN7 off
    ANSEL1= %00000000 ' Analog channel AN8 off

    'PROGRAM TO DETERMINE DIRECTION OF QUADRATURE ENCODER

    portb_old var BYTE

    'RULE FOR A 2-BIT (QUADRATURE SYSTEM):
    'CLOCKWISE = LOW BIT OF OLD VALUE IS ALWAYS EQUAL TO HIGH BIT OF NEW VALUE
    'COUNTERCLOCKWISE = LOW BIT OF OLD VALUE DOES NOT EQUAL HIGH BIT OF NEW VALUE

    main:



    PORTA = 0 'RA0 LED will indicate CW; RA1 LED will indicate CCW
    PORTB = 0 'RB0 and RB1 as inputs for encoder A & B

    portb_old = 0

    my_direction:

    IF PORTB XOR portb_old <> 0 THEN
    PORTA = ((PORTB.1 XOR (portb_old AND 1)) + 1) 'cw = 1; ccw = 2
    ENDIF

    portb_old = PORTB

    GOTO my_direction

    end
    Last edited by Johan; - 26th July 2007 at 02:57.

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. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  5. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 21:56

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