ModalAI Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    RPM PI control structure

    ESCs
    2
    4
    230
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MChehadeh
      last edited by

      Hi,
      May I know the structure of the PI controller used for control of RPM governor? this would help with tuning. For example, does the error get multiplied by Kp and Ki and then the results get summed-up together to produce the control action? or is it some other arrangement?

      Thanks,,,

      Alex KushleyevA 1 Reply Last reply Reply Quote 0
      • Alex KushleyevA
        Alex Kushleyev ModalAI Team @MChehadeh
        last edited by Alex Kushleyev

        @MChehadeh

        Here is how the RPM controller works (without going into too much detail...). It is a basic PI controller with feed-forward. This should clarify the formula and how the ESC parameters are used in RPM control mode

        #RPM controller is running on each ESC at 10Khz update rate
        
        #duty_cycle is between 0 and 999 (999 = 100% duty cycle). This is duty cycle of pwm applied to motor
        duty_cycle = ff_term + p_term + i_term  
        
        #explanation of the terms:
        
        #cap the rpm setpoint using actual rpm + max_rpm_delta to prevent very large transitions 
        #desired_rpm is rpm sent from flight controller
        setpoint_rpm = min(desired_rpm, actual_rpm + params.max_rpm_delta) 
        
        ff_term = compute the feed-forward term based on the setpoint_rpm, ESC calibration params a0, a1, a2 and measured voltage
        
        error_rpm = setpoint_rpm - actual_rpm #note the rpm_error term is capped, since setpoint is capped
        
        p_term = params.kp * error_rpm / 1024      #scale the result to get to units that make sense
        i_term += params.ki * error_rpm / 1048576   #scale the result to get to units that make sense. this term persists
        
        bound p_term using params.max_kpe
        bound i_term using params.max_kie
        

        Note that there are actually two caps, one that produces setpoint_rpm, but also p and i terms are capped separately. This can help bound different terms.

        You can also zero out p or i terms by setting either the gains to zero or the max_kpe / kie to zero.

        If you don't want the setpoint to be limited by params.max_rpm_delta, you can set max_rpm_delta to a large value that is greater than your max rpm, but you could have very aggressive response if you command a large rpm transition.

        M 1 Reply Last reply Reply Quote 0
        • M
          MChehadeh @Alex Kushleyev
          last edited by

          @Alex-Kushleyev Thanks for the response.

          What I understood is that there is a constant ratio between p_term and i_term, i.e. 1024/1048576=9.76x10^-4. Is that right?

          Alex KushleyevA 1 Reply Last reply Reply Quote 0
          • Alex KushleyevA
            Alex Kushleyev ModalAI Team @MChehadeh
            last edited by

            @MChehadeh yeah it is simply 1/1024. Powers of 2 for faster calculations

            Integral is scaled down a lot because it accumulates fast at 10khz update rate

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB | Contributors