encoder port change


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153

    Default encoder port change

    I need some Ideas On how to monitor two pins, which are hooked to a 4 bit encorder, on pin change of state I need to mirror this change of state on two output pins. These output pins are also used to output the state of another input (toggel sw) which is programmed to output a 4 bit state. this is a manual setup where one encoder or one toggel sw(through programming) will output the 4 bit state (not both at the same time) upon pin change. so if they spin the encoder I want that output to be mirrored if they use the toggel sw I want that part of the program to output the state.
    I have the toggle sw working I need to have a second input and which ever one is used takes over the program.

    I hope this makes sense to someone!

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I am sure I am missing something ...

    Assume both input signals are 0 when idle.
    If pinVar1 > 0 then ????
    If pinVar2 > 0 then ?!?!
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default Maybe

    Yea that kindof what I was thinking, but the hard part is that the encorder will not be zeroed It could be in any of 4 places 00,01,11,10 I need a clean quick way of reading change. I can read the port shift left 6 back right 6 and get my two LSB's I need a way to sense change in either bit, or at least encoder direction of change ( this would be best ) then I could feed into my existing program and handle the output. So it would not have to mirror the encorder just give me the direction of movement Left, Right, for each click I would increment my existing program by one, up or down.

    I know I not real clear but I really know what I want!! I think

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Henrik shared some code here that may give you an idea or two.
    http://www.picbasic.co.uk/forum/showthread.php?t=11683
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default encoder

    Thank you I also did a search (dah) of the fourm and found that if I & the two bits it will give direction I will look all this over and repost if I don't get it.

    thanks again

  6. #6
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default encoder

    Just so I don't mess anyone up here,This is what will work for me.

    Using Xor will give direction.

    take the righthand bit of your old value xor it with the lefthand bit of the new value.

    if your xor value is 0 the knob is turning clockwise
    if your xor value is 1 the knob is turning counter_clockwise

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. Change On Interrupt, PIC16F884
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 14th November 2008, 17:25
  3. Using PICBASIC PRO in MPLAB IDE
    By jblackann in forum General
    Replies: 8
    Last Post: - 4th May 2008, 09:20
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  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 : 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