18F2431 QEI in Velocity mode


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2005
    Posts
    42

    Default 18F2431 QEI in Velocity mode

    Has anyone succesfully got the QEI on the 18F2431 working successfully.

    The position counter was easy enough and brilliant for making sure you have the encoder sensor lined up correctly, but struggling with the velocity mode.

    Set myself the goal of first just using the INDEX pin of the Encoder wheel, which is on the CAP1 to measure RPM, by reading the time it takes for each revolution. Then when happy with that I wanted to start sampling the time say 64 times per revolution etc etc. And eventually logging the Pulse Width between say every 16 pulses.

    But small steps and after jumping back and forth over the 18F2431 data sheet I sort of concluded the following:


    I have set

    QEI:

    Bit7 0=Velocity mode enabled
    Bit6 0=No overflow or underflow
    Bit5 0 UP/DOWN: Direction of Rotation Status bit
    Bits4-2 001=QEI enabled in 2x Update mode; INDX resets the position counter
    bits1-0 00=1:1 Velocity Pulse Reduction Ratio

    QEICON = %0 0 0 001 00

    Then CAP1CON to

    CAP1:

    Bits 7-4 not used for QEI
    Bit 3-0 Special Event trigger mode, every rising edge of cap1

    CAP1CON=%0000 1111


    And Timer5 to

    Timer5:

    Bit7 0=Timer Disabled during sleep
    Bit6 1=Special Event Trigger Reset is disabled (not used on 2431)
    Bit5 0=Continous Count mode
    Bit4-3 Timer5 Prescale 00=1:1
    Bit2 0=Sync with external clock
    Bit1 0=Internal clock source
    Bit0 1=Timer 5 enabled

    T5CON=%0 1 0 00 0 0 1

    I was foolishly thinking I could simply read the VELR values that should get updated every revolution.

    Read VELRH and VELRL and joing them to get word value.

    But instead of the VELR buffer getting updated each revolution, it is getting updated every pulse.

    Any help or code examples appreciatted.

    Cheers

    Sean.
    *********************
    http://www.cncdudez.co.uk
    *********************

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 18F2431 QEI in Velocity mode

    Just curious, isn't it better to have the update every pulse?, much more resolution that way. Also if you want less resolution, you could just get the value every X counts. Since you know the number of pulses per rev, the speed is pulse speed*number of pulses.

    Maybe I just don't understand the question. It sounds like YOU have got it to operate successfully
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 1

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