emulator quadrature encoder


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Posts
    32

    Default emulator quadrature encoder

    Hi,

    you can generate two square waves with a PIC 1000 Hz out of phase with each other in advance or delay of 90 degrees?

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: emulator quadrature encoder

    Yes, you can use, just use timer1 and DT interrupt.

    Assuming you will use the internal oscillator @ 8 MHz, timer1 should be set with prescaler at 1 tmr1h =252 and tmr1l = 24. This will give you the right timing.

    Use the following array:

    Chan VAR byte [4]
    A0 VAR byte
    Forward VAR bit

    chan[0]=0
    chan[1]=1
    Chan[2]=3
    Chan[3]=2


    Within the ISR I will call overflow as an example you will write the following code:

    Overflow:

    If forward = true then

    A0 = A0 + 1

    If A0>3 then A0 = 0

    Else

    A0=A0 - 1

    If A0>200 then A0 = 3

    Endif

    PortB = Chan[A0]

    @Return

    You will use portB.0 and portB.1 as your output. Set flag Forward to true (1) for channel A high prior of channel B, set flag to False (0) to reverse.

    Cheers

    Al.
    Last edited by aratti; - 13th August 2012 at 15:56.
    All progress began with an idea

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