18F4431 Quaduature Encoder


Closed Thread
Results 1 to 29 of 29

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce,
    Thank you for info regarding RE3/MCLR as input.

    It sure is a cool device. Using Darrel's interupt routines I managed to get motor controller for my robot working, with PID filter and all. Very fun project.

    However.....I never managed to get QEI module going in velocity mode. I made a few attempts to begin with but could never quite figure it out so I went for my own velocity calcs (newPos-oldPos). Any pointers?

    Thanks!
    /Henrik Olsson.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Henrik,

    I haven't messed with QEI yet, but if I do get something going, I'll port it from C to PBP and post it here.

    My primary interest in this one was the new high-speed A/D, and motion feedback module for background pulse & freq measurements.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Default

    Bruce,
    I see. Thanks anyway!

    /Henrik Olsson.

  4. #4
    Join Date
    Jun 2006
    Posts
    37


    Did you find this post helpful? Yes | No

    Default 18F4431 PPWM setup and operation

    Hi!
    i got hold of Microchip PICDEm MC LV board with 3-phase BLDC motor.It has a CD that conatins source code in assembly. I was wondering if someone has done same thing in pic basic i.e used power PWM module of 18F4431.I tried according to application note but to no avail. Here is my code.could someone point me out in right direction.some code snipet would be appreciated.
    thanks

    while true
    PTCON0=00000000 'page 8,step 1
    PTPERL=$37 'a guess
    PTPERH=$01
    PWMCON0=01001111 'step 3
    PWMCON1=00000001 'step 4
    DTCON=00000000 ' a guess
    OVDCOND=00000000 'step 6
    OVDCONS=00000000
    FLTCONFIG=00000000
    'POVD=00000000
    'SEVTCMP=$0000
    'step 8
    SEVTCMPL=$00
    SEVTCMPH=$00
    PDC0L=$00
    PDC0H=$00
    PDC1L=$00
    PDC1H=$00
    PDC2L=$00
    PDC2H=$00
    PDC3L=$00
    PDC3H=$00


    TRISC.0=1
    PTCON1=10000000 'or PTCON1.7=1
    wend

  5. #5
    Join Date
    Jun 2006
    Posts
    37


    Did you find this post helpful? Yes | No

    Default PPWM setup and operation setup and operation

    Hi!
    i got hold of Microchip PICDEm MC LV board with 3-phase BLDC motor.It has a CD that conatins source code in assembly. I was wondering if someone has done same thing in pic basic i.e used power PWM module of 18F4431.I tried according to application note but to no avail. Here is my code.could someone point me out in right direction.some code snipet would be appreciated.
    thanks

    while true
    PTCON0=00000000 'page 8,step 1
    PTPERL=$37 'a guess
    PTPERH=$01
    PWMCON0=01001111 'step 3
    PWMCON1=00000001 'step 4
    DTCON=00000000 ' a guess
    OVDCOND=00000000 'step 6
    OVDCONS=00000000
    FLTCONFIG=00000000
    'POVD=00000000
    'SEVTCMP=$0000
    'step 8
    SEVTCMPL=$00
    SEVTCMPH=$00
    PDC0L=$00
    PDC0H=$00
    PDC1L=$00
    PDC1H=$00
    PDC2L=$00
    PDC2H=$00
    PDC3L=$00
    PDC3H=$00


    TRISC.0=1
    PTCON1=10000000 'or PTCON1.7=1
    wend

  6. #6
    Join Date
    Jan 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    I wish I could help but I am using the 18F4431 in a completely
    different manner.
    Richard

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I don't have the 18F4431 or Microchip motor control board, but this works
    on the 18F2431. It outputs PWM on RB0,RB1,RB2,RB3,RB4 and RB5 with a
    varying duty cycle. Ramps up, then down.

    It should be at least enough to get you started.
    Code:
        DEFINE OSC 20
        
        Duty VAR WORD
        PORTB = $FF
        TRISB = 0
        
        PTCON0=$00 'page 8,step 1
        PTPERL=$A0      ' $01A0 = 12kHz
        PTPERH=$01
        PWMCON0=%01011110 'would be %01011111 for the 18F4431
        PWMCON1=%00000001 'step 4
        DTCON=$00
        ;OVDCOND=$00 'step 6  ; May want to un-comment these based on your PIC & board.
        ;OVDCONS=$00
        ;FLTCONFIG=%10110011
        ;POVD=00000000
        ;SEVTCMP=$0000
        ;step 8
        SEVTCMPL=$00
        SEVTCMPH=$00
        PDC0L=$00
        PDC0H=$00
        PDC1L=$00
        PDC1H=$00
        PDC2L=$00
        PDC2H=$00
        ;PDC3L=$FF ; un-comment for 18F4431
        ;PDC3H=$00
        PTCON1=%10000000
        
    Main:
        FOR Duty = 50 TO $500 STEP 4
            ASM
            bsf   PWMCON1,UDIS	    ;Disable the PWM buffer update
            MOVFF _Duty,PDC0L
            MOVFF _Duty+1,PDC0H
            MOVFF _Duty,PDC1L
            MOVFF _Duty+1,PDC1H
            MOVFF _Duty,PDC2L
            MOVFF _Duty+1,PDC2H
            ;MOVFF _Duty,PDC3L      ;un-comment for 18F4431
            ;MOVFF _Duty+1,PDC3H
            bcf	  PWMCON1,UDIS	    ;Enable the PWM buffer update
            ENDASM
            PAUSE 50
        NEXT Duty
        FOR Duty = $500 TO 50 STEP-4
            ASM
            bsf	  PWMCON1,UDIS	    ;Disable the PWM buffer update
            MOVFF _Duty,PDC0L
            MOVFF _Duty+1,PDC0H
            MOVFF _Duty,PDC1L
            MOVFF _Duty+1,PDC1H
            MOVFF _Duty,PDC2L
            MOVFF _Duty+1,PDC2H
            ;MOVFF _Duty,PDC3L      ;un-comment for 18F4431
            ;MOVFF _Duty+1,PDC3H
            bcf	  PWMCON1,UDIS	    ;Enable the PWM buffer update
            ENDASM
            PAUSE 50
        NEXT Duty
        GOTO Main
        
        END
    This is just a slight modification to what you posted before. To work with the
    18F2431. I haven't done much beyond this with the PCPWM module. Not yet
    at least..;o}

    HTH
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Smile

    I'm using the 18F2431 too.
    And I begun with the PICDEm MC LV board...

    It's a great uC ! (UART, I2C, fast AD, 3-times PWM...)
    I use it as a PI(D)-Controller for a BLDC-Motor.
    And I use it for his fast AD-Converters in a CR-Tuning-Box.

    The Quadrature-Encoder isn't very strange ... the whole business with this chip is to use the right timers for the right tasks and use the right prescalers !!

    ;-)
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

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. Reset timer / encoder transition
    By DJEE in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 22nd June 2007, 15:37
  4. encoder HEDL 5540
    By kutsi in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th June 2007, 15:00
  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 : 3

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