PMDC SERVO MOTOR WITH quadrature encoder DRIVE ?


Closed Thread
Results 1 to 38 of 38

Hybrid View

  1. #1
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit and Henrik,
    My PIC is 18F4431
    I have success with 20MHz XTAL and define osc 20 , fuse HS.
    I found motor with encoder with INDEX pin and little modific Hanrik code.
    Result is 16 bit counter but I must find calculation becouse my encoder is 500 pulse per full rev of motor shaft.
    Henrik you was give me good way for start with 18F4431..thanks man again.
    Last edited by phoenix_1; - 1st September 2009 at 08:55.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by phoenix_1 View Post
    Hi mackrackit,
    My PIC is 18F4431
    I have success with 20MHz XTAL and define osc 20 , fuse HS.
    Mine works fine with 20Mhz HS also. It is when I try to run at 40Mhz HSPLL the problem starts. Maybe I have some bad 10s that are running a bit fast???
    I have some new 10Mhz on order, find out then.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Again, you don't have to use the index channel, it'll work fine without it. If you set up the QEI module to reset on index (as in my example) and the encoder doesn't have an index channel the counter will simply roll over from $FFFF to $0000 or from $0000 to $FFFF depending on direction. Carefully read the section of the datasheet, play with it a bit and read the datasheet again, you'll figure it out ;-)

    /Henrik.

  4. #4
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Again, you don't have to use the index channel, it'll work fine without it. If you set up the QEI module to reset on index (as in my example) and the encoder doesn't have an index channel the counter will simply roll over from $FFFF to $0000 or from $0000 to $FFFF depending on direction. Carefully read the section of the datasheet, play with it a bit and read the datasheet again, you'll figure it out ;-)

    /Henrik.
    Yes I was read that part a couple of time and again and again...
    How I see that full 18F4431 is extra MCU and most of you must do is to set
    tons of nibbles on config registers but!
    If you do that right you will have pleasure to use many finished hardware periferials without to much programing...inside 18F4431 is so many good things...

    Regards Robert

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Again, you don't have to use the index channel, it'll work fine without it. If you set up the QEI module to reset on index (as in my example) and the encoder doesn't have an index channel the counter will simply roll over from $FFFF to $0000 or from $0000 to $FFFF depending on direction. Carefully read the section of the datasheet, play with it a bit and read the datasheet again, you'll figure it out ;-)

    /Henrik.
    Hi Henrik,
    I do not have an encoder to play with but I might some day
    Reading through all of this I am not seeing how the count will go up or down depending on the direction.

    Would you mind enlightening me?
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default

    Hi,
    The encoder outputs channels which has a 90° phase shift between them.

    The QEI-module can be set to 2X or 4X mode (X4 is the most common) but the easiest to understand is the 1X mode....

    Simply, if the B channel is high on the rising edge of the A channel then you count up, if the B channel is low on the rising edge of the A channel then you count down. In 2X mode you "trig" on the rising edge of both channels (giving you a resolution of 2X the line count of the encoder) and it 4X mode you trig on the rising AND falling edge of BOTH channels (giving you a resolution of 4X the line count of the encoder).

    If you look up incremental or quadrature encoder on Wikipedia you'll find more details.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default

    Thanks Henrik,

    I understand now.
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Unhappy New question is start for next stage of project

    Now I am probe on many ways to do next but I cant to image how.
    1. I was setup count for QEI with friends from these forum to count from 0 - 12500 - becous my motor have gear 6.25:1 and 6.25*2000 = 12500(reding of one turn of motor shaft with 500 lines encoder) give me full 360' of output shaft range.That work extra.
    Next : If I want to move for example 1mm on my mechanic I need one turn of output shaft that give me easi to control position of count from CW 0-12500 or CCW 12500 to 0.That is all in 16bit counter.
    But what if I need to move more then 16bit counter ?
    OK I can use PBPL and define 32bit variable - I was probe and it work 100%.
    I can easy set to se if X VAR LONG number 25000000 that give me 25000000/12500 = 2000mm - inpresive!
    But how I can my software variable defined as LONG from 0 - 25000000 to increment or decrement from hardware COUNT buffer wich count in circle from 0-12500 and vice verse ?
    Is any idea becouse all what I was probe give me garbage of result.

    Regards Robert
    Last edited by phoenix_1; - 8th September 2009 at 17:09.

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. Best quadrature encoder for buck?
    By jrprogrammer in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd June 2009, 13:58
  3. More Servo Woes
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 13th May 2009, 08:40
  4. saving RCREG to word
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th September 2008, 13:51
  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