PID-filter routine (2nd try).


Results 1 to 40 of 132

Threaded View

  1. #11
    Join Date
    Aug 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default QUESTION FOR Mr HENRIKOLLSON

    Dear sir thank u for reply.
    My question is that i can get 10 bit resolution of PWM output to control motor speed.
    I use following code.
    CCP1CON = %00001100 ' Set CCP1 to PWM
    T2CON = %00000111 ' Turn on Timer2, Prescale=4
    PR2 = 249 ' Set PR2 to get 1KHz out
    CCP1CON.4 = pid_out.0 ' Store duty to registers as
    CCP1CON.5 = pid_out.1 ' a 10-bit word
    CCPR1L = pid_out >> 2
    It will give 10bit PWM output at 16MHz crystal.
    Now spose pid_Error=+5 then spose after calculation
    pid_Out=100
    pid_out.15=0 'DIRECTION BIT
    same result will be if pid_Error=-5 but
    pid_out.15=1
    With both errors final PWM resolution is same but how can I use direction bit to change PWM output to increase or decrease motor speed according to requirement.?
    If there is any OFFSET which must be used ?
    Last edited by hadiengg; - 7th August 2009 at 14:46.

Similar Threads

  1. Darrel's latest 16 bit averaging routine?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 17th October 2009, 01:57
  2. 2nd order Low-pass passive RC filter on PWM
    By munromh in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th January 2009, 19:03
  3. Atod Digital Filter
    By GeoJoe in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd April 2008, 17:04
  4. PID controller in 16F737
    By joeri in forum mel PIC BASIC
    Replies: 8
    Last Post: - 24th June 2006, 11:39
  5. 2nd Order Digital Filter for 24-bit
    By sefayil in forum mel PIC BASIC
    Replies: 0
    Last Post: - 2nd December 2005, 21:55

Members who have read this thread : 2

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts