Quad encoder problems


Closed Thread
Results 1 to 40 of 52

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    OK, I found an error in the interrupt setup. Make the change highlighted in red.

    Code:
    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
              INT_Handler RBC_INT, _Rot_Encoder, PBP, yes
         endm
         INT_CREATE ; Creates the interrupt processor
         INT_ENABLE RBC_INT ;RB Port Change Interrupt
    ENDASM
    I tried this out on a 16F877a (since I don't have your model). Worked fine with the one encoder I have available hooked to Rot1. Don't see any reason it wouldn't work with both hooked up.

    Steve

  2. #2
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default One other thing...

    Since you are using a serial LCD and software based serial routine, the interrupts will be disrupting the timing of the serial output. I would recommend using HSEROUT. The timing won't be affected with the interrupts.

    EDIT:
    Here is how you can do this:

    1) Switch your serial cable to RB2 (pin 8)

    3) Setup the HSER defines:
    Code:
    'Setup for 9600 baud 
    ' Set transmit register to TXEN =1 (TX enabled) and BRGH = 1
         DEFINE HSER_TXSTA	24h
    ' Set baud rate
         DEFINE HSER_BAUD	9600
    3) Change your SEROUT2 commands to HSEROUT.
    Code:
    HSEROUT [254, 88] 'Clear LCD
    
    and
    
    HSEROUT [254, 71, 1, 1, "ROT1:", DEC2 RotEnc1_val," ROT2:", DEC2 RotEnc2_val]


    Steve
    Last edited by SteveB; - 30th September 2006 at 18:35.

  3. #3
    Join Date
    Sep 2006
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    I think someone dosnt want this to work
    I did the hserout just as you said and still got garbage. I then checked the pbp manual and double checked the define's. all ok. Wait a sec, the 16f876a has the usart tx on pin c6! Right? So I moved the lcd serial line to c6 and still got garbage! What is going on! So then I programed a simple code into the pic to just do a hserout to print to the lcd. I used the proper define's and still got garbage. At this point I am thinking what the heck is going on. So then went back to a simple program to print on the lcd with the serout2 command just to check the lcd. And sure enough garbage! Is the lcd bad? Well I then hooked it to the pc and ran a program that tests it and sure enough the lcd is shot! Not sure what happened. I never hooked it up reverse polarity. Is it possible that with the initial garbage coming out of the pic it sent something to the lcd that screwed something up? I am totaly scratching my head. LOL
    The only thing that I might have done is connect the serial line going to the lcd to 5v. Would that kill it?
    I am going to try the my old parallel lcd and see what happens.

    Thank you for putting up with me this long. I will get this thing running if it kills me! LOL

    Smitty

  4. #4
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    In your first post in the thread, you said you were using the following:
    Quote Originally Posted by smitty505000
    Qty 2 quad encoders with 36 slots each
    Pic 16F628-20p
    parallel lcd
    So, I figured you opted for a serial LCD to save on I/O lines with an 18 pin pic. So my last post was geared to the 16F628.
    Quote Originally Posted by smitty505000
    Wait a sec, the 16f876a has the usart tx on pin c6! Right?
    Seems you switched PIC as well. Guess I could have been more generic and just said to hook up the serial out to the TX pin.

    Quote Originally Posted by smitty505000
    Is it possible that with the initial garbage coming out of the pic it sent something to the lcd that screwed something up?
    Not likely. But worth a query to the distributor/manufacturer.

    Quote Originally Posted by smitty505000
    I will get this thing running if it kills me!
    Well, I am sure it won't come to that. But this is one of those things that most of us have been through at least once (often multiple times), where we learn more than we expected going into it.

    Steve

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=639&d=1133445289">
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Sep 2006
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    I looked just like that guy! LOL

    Well I just hooked up my old parallel LCD and got it working! The program with interupts is better but still loses count. I wonder if it is because the encoders do not have detents and can change direction in between?

    A little more background on what I want to do with these in case someone has an alternative or any other input.

    I have the two encoders set up so they are perpendicular to each other. Each has a small weight on one side so they stay oriented to gravity. One is for pitch and one is for roll. The numbers returned will be converted into degrees and then sent to a BOB-4 video module. For those who do not know, the bob-4 is a video overlay module and it supports vector graphics! I am setting it up to display a HUD for my RC plane. This HUD will have Altitude, heading, air speed, artificial horizon, temperature, miliamp hour meter, and some other nifty stuff. All viewed on the ground via a monitor or my video glasses.

    Smitty

  7. #7
    Join Date
    Sep 2006
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    Oh yea, these encoders obviously will be in constant motion and I plan on using a dedicated pic to keep track of them.

    Smitty

Similar Threads

  1. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 15:45
  2. Instant Int and encoder (Elect. Gearing)
    By boroko in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 29th November 2009, 03:29
  3. encoder HEDL 5540
    By kutsi in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th June 2007, 15:00
  4. quad encoders
    By cpayne in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 13th March 2007, 18:49
  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 : 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