Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse
Brand Logo

ModalAI Forum

  1. ModalAI Support Forum
  2. ESCs
  3. RPM PI control structure

RPM PI control structure

Scheduled Pinned Locked Moved ESCs
4 Posts 2 Posters 700 Views 1 Watching
  • 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 Offline
    M Offline
    MChehadeh
    wrote on last edited by
    #1

    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
    0
    • M MChehadeh

      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 Offline
      Alex KushleyevA Offline
      Alex Kushleyev
      ModalAI Team
      wrote on last edited by Alex Kushleyev
      #2

      @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
      0
      • Alex KushleyevA 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 Offline
        M Offline
        MChehadeh
        wrote on last edited by
        #3

        @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
        0
        • M MChehadeh

          @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 Offline
          Alex KushleyevA Offline
          Alex Kushleyev
          ModalAI Team
          wrote on last edited by
          #4

          @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
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          ModalAI
          Categories Recent Tags ModalAI.com Docs
          © 2026 ModalAI® · Accelerating autonomy for smaller, smarter, safer drones · Powered by NodeBB
          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups