Les's Amicus18 PID output inversion question


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,707
    Thumbs Up
    Received: 48
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Les's Amicus18 PID output inversion question

    Hi

    I'm playing with Les's integer PID routine. It seems to be working on a sim level apart from the output is inverted.

    My mosfet is drive high to turn on a fan but the code sends the duty high when turning down. This is turn on my fan more

    I tried a simple output = 1023 - output but then the max and min settings get screwed.

    I have tried trying to figure out whats going on in the code to see if I can invert it but the place were I can invert it is before crucial calcs for corrections

    So does anyone know how to modify it or how to config the HPWM port to invert its output?

    Thanks

    PS I can post Les's code if need be.
    Tim

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,532
    Thumbs Up
    Received: 75
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default Re: Les's Amicus18 PID output inversion question

    Les,

    To reverse the input you should use output = 1023 - input, not output - 1023 - output. Sorry for the stupid question, but you are not using a P-Channel MOSFET, correct?

    I used Les PID routine and hadn't this issue. At the beginning I had a problem but I forgot what it was but I know that it solved itself after I initiated the PID SETUP every time I invoked the PID_Compute. i.e.: -

    Code:
    PID_Seq: 
    
    ' Setup the PID parameters
    ' (pKP, pKI, pKD, pMaxCorrection, pMaxError, pMinOutput, pMaxOutput)
    PID_Setup(4 , 1 , 0 , PW_Cor , 1 , 0 , 1023)
    
    ' PID loop
    ' RPM_Real = RPM from sensor
    ' RPM_Req = Required 
    ' RPM from throttle pot
    
    PID_Compute(RPM_Real, RPM_Req, Str_PWM) ' Compute PID
    HPWM2_Duty(Str_PWM)                     ' Set PWM for starter
    DelayMS 3                               ' A small delay
    Regards

    Joseph

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Senior Member
    Join Date
    Jan 2014
    Posts
    406
    Thumbs Up
    Received: 19
    Given: 35
    Total Downloaded
    192.60 MB

    0 Not allowed!

    Default Re: Les's Amicus18 PID output inversion question

    Well if PWM = 0 then the ^ PWM = 255, and if PWM = 1 ^ PWM = 254 and so on (read ^ as invert).
    So if you invert the PWM value then you have the correct value.
    Maybe this help;
    Code:
    pwm = ~pwm
    I never test this with PWM, but only to toggle ON/OFF

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,707
    Thumbs Up
    Received: 48
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: Les's Amicus18 PID output inversion question

    The trouble with PWM = ~PWM is that it's a 10 bit value so inverting it 1023 makes it a big number. Perhaps as writing it the regs you mask out the > 1023 bits.

    I will give it a try.

    Thanks
    Tim

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Senior Member
    Join Date
    Jan 2014
    Posts
    406
    Thumbs Up
    Received: 19
    Given: 35
    Total Downloaded
    192.60 MB

    0 Not allowed!

    Default Re: Les's Amicus18 PID output inversion question

    Tim,
    Please read this one, if you have not read it before;
    http://www.protonbasic.co.uk/showthr...l=1#post502202

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Question for Les Johnson.
    By Gerard in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 3rd November 2014, 16:13
  2. Using Les his PID inc routine in BLDC driver
    By basparky in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 5th June 2013, 07:39
  3. Question to Les or Dave
    By johngb in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 11th January 2013, 09:27
  4. An Amicus18 question but I guess it applies to PDS as well.
    By johngb in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 14th January 2012, 12:24
  5. [SOLVED !] PID question
    By bcans in forum Proton Plus Compiler v3
    Replies: 22
    Last Post: 24th May 2009, 08:03

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