encoder wowes


Closed Thread
Results 1 to 17 of 17

Thread: encoder wowes

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    wallaby, First place these declarations at the top of your program:

    ' LCD SETUP DEFINES
    DEFINE LCD_DREG PORTA ' set LCD data port
    DEFINE LCD_DBIT 0 ' set starting bit ( 0 or 4 ) if 4 bit bus
    DEFINE LCD_RSREG PORTA ' set LCD register select port
    DEFINE LCD_RSBIT 4 ' set LCD register select bit
    DEFINE LCD_EREG PORTA ' set LCD enable port
    DEFINE LCD_EBIT 5 ' set LCD enable bit
    DEFINE LCD_BITS 4 ' set LCD bus size ( 4 or 8 bits )
    DEFINE LCD_LINES 2 ' set number of lines on LCD
    DEFINE LCD_COMMANDUS 2000 ' set command delay time in us
    DEFINE LCD_DATAUS 50 ' set data delay time in us

    '******** DEFINE VARIABLES **********
    OFS VAR BYTE 'ENCODER + or - COUNT
    TEMP1 VAR BYTE 'ENCODER SCRATCH VARIABLE
    TEMP2 VAR BYTE 'ENCODER SCRATCH VARIABLE
    KNOBLIM VAR WORD 'UP-DOWN COUNTER LIMIT
    UP_DOWN VAR WORD 'COUNTER PASS VARIABLE
    MULTIPLY VAR BYTE 'KNOB MULTIPLIER FOR SPEED

    '*********** INITIALIZE VARIABLES ************
    Multiply = 1 'set multiplier to 1
    Variable = 100 'set variable initially to value of 100
    Knoblim = 1000 'set maximum rollover to occur at 1000
    TEMP1 = (PORTB & %00000011) << 2 'only executed once to preload temp1


    Next, run this code and then rotate the encoder
    to see the action. By the way don't forget the A and B outputs from the rotary encoder are wired to PORTB pins 0 and 1 respectively.

    loop:'
    UP_DOWN = Variable 'make current position equal to value of variable
    GOSUB ENCOD 'READ ENCODER
    Variable = UP_DOWN 'add up/down count to variable
    lcdout $FE,$02,DEC5 Variable
    goto loop


    '*************************************************
    ENCOD: 'READ ROTARY ENCODER POSITION SUBROUTINE
    '*************************************************
    TEMP2 = TEMP1 | (PORTB & %00000011)
    LOOKUP TEMP2,[2,3,1,2,1,2,2,3,3,2,2,1,2,1,3,2],OFS
    TEMP1 = (TEMP2 << 2) & %00001100
    UP_DOWN = UP_DOWN + ((OFS * MULTIPLY) - (2 * MULTIPLY))
    IF UP_DOWN = (KNOBLIM + MULTIPLY) THEN UP_DOWN = 0
    IF UP_DOWN > KNOBLIM THEN UP_DOWN = KNOBLIM
    MULTIPLY = 1
    RETURN

    Dave Purola,
    N8NTA

  2. #2
    Join Date
    Jul 2005
    Posts
    11


    Did you find this post helpful? Yes | No

    Default reply to dave

    Thanks Dave, I owe you a beer! Will try this out and post results. The 2 metre receiver works a treat, better than .2uv for 12 db sinad and the frontend tracks nicely. It will cover 108 to 161 Mhz.

    Cheers from Oz

    Nigel Andrews

  3. #3
    Join Date
    Jul 2005
    Posts
    11


    Did you find this post helpful? Yes | No

    Default Reply to Dave 2

    Dave,

    I tried it out and it is counting nicely, but still in increments of 2! It seems to think that the encoder has transitioned twice ( both going high, albeit one in front of the other ) so it goes up by 2. If you carefully half turn the encoder and make one input go up on its own, it then goes up by one. As soon as you let go and the other goes up, it counts up by one again.

    If you can give me a mailing address in the US I will post one off to you free, they are quite a nice encoder and I have a few spare. If you like you can email me direct at [email protected] with your address and I will send it. Might come in handy for a project of yours in the future.

    Otherwise I will keep playing around with the test one here.

    Cheers

    Nigel

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Thanks Nigel, I just emailed you my address.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    wallaby, I just received the encoder yesterday and it sure looks cool... You didn't tell me that it had a pushbutton on it as well. I'll hook it up this weekend and get back to you on Monday. Once again thanks....

    Dave Purola,
    N8NTA

  6. #6
    Join Date
    Jul 2005
    Posts
    11


    Did you find this post helpful? Yes | No

    Default encoder

    O.K , glad to see it arrived safely.

    Cheers

    Nigel

  7. #7
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Nigel, After hooking up the encoder you sent me and looking at it with a scope I found it is working as advertised. I went to the ALPS website and lo & behold the documentation says it has detents on every other (2 of the 4 states) of the encoder output. That is why the encoder seems to be counting by 2 because it actually is. Attached is the waveform for the output of the encoder at the detents. The suggested connection is 5 volts thru a 10k to the switch. Then a 10k from the switch in series with a .01uF to ground with the connection of the 10k and the .01uF going to the processor. This provides a filter mechanism to counter act any switch bounce that may occure due to the nature of the rotary switch. Once again, Thanks Nigel....

    Dave Purola,
    N8NTA
    Attached Images Attached Images  

Similar Threads

  1. Reading incremental encoder interupt
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 1st March 2017, 12:50
  2. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 14:45
  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. Reset timer / encoder transition
    By DJEE in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 22nd June 2007, 14:37
  5. encoder HEDL 5540
    By kutsi in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th June 2007, 14:00

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