Problem with a program...


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    hawk72501's Avatar
    hawk72501 Guest

    Unhappy Problem with a program...

    I have made the following program:
    INCLUDE "modedefs.bas"

    TRISB=%11111111
    TRISC=%00001010

    W1 VAR WORD
    W2 VAR WORD
    loop:
    Count PORTB.7,3000,W1
    Count PORTB.6,3000,W2

    SerOut2 PORTC.0,84,["TIMES COUNTSa:",DEC W1,13,10]
    SerOut2 PORTC.0,84,["TIMES COUNTSb:",DEC W2,13,10]

    GoTo loop
    In pins B.7 and B.6 i have connected the 2 channels of an incremental quadrate encoder.The problem is that channel A(PortB.7) shows the right pulses but channel B(PortB.6) shows always 0 !I am sure that i have made the right connections .Do you know what goes wrong?

    Thank you in advance.Don't hesitate to answer me.I am desperate!

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


    Did you find this post helpful? Yes | No

    Default

    how you connect the encoder? Pull-up, PUll-down resistor are there??
    Steve

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

  3. #3
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Question

    Are you rotating the encoder for all six seconds? If you only rotate it while counting pulses on PortB.7, you will miss the pulses on portB.6.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Thumbs down With a little help from the manual ...

    You're right, ingvar ...

    as PBP can't do two things at a time ...it reads Portb.7 for 3 seconds and THEN Portb.6 for the 3 following seconds ...

    No hope this way ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    hawk72501's Avatar
    hawk72501 Guest


    Did you find this post helpful? Yes | No

    Default

    Ingavr and acetronics thanks for replying!Have you any idea how to make it working to count simultaneously the 2 channels?

    Mister_e thanks for replying.If i use a pull-up resistor of 2.7K is that ok?Should i turn the internal pull-ups off?

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi Hawk,

    another thread is still open on this subject ... SEARCH function !!!

    11 results ... no less !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Simple program - Strange problem!
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 19th December 2009, 22:52
  2. confused problem with interrupt in a working program
    By illuminator4 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th November 2008, 17:01
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. Problem to compile my program
    By wagner in forum Off Topic
    Replies: 5
    Last Post: - 7th July 2008, 20:17
  5. serial program and sensor problem
    By win_832001 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th April 2006, 04:16

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