1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

PID loops or Complementary filter for University project?

  1. Oct 4, 2015 #1
    I am studying "maths III" in my university. And the course has this project you have to do called "Practical differential equations". You are basically supposed to describe some practical system that uses differential equations.

    My thought was PID loops, but I'm not sure if they use differential equations? I really wanted to use them though because I have used them before in a DIY project, although they use integrals and derivatives I'm not sure there is a differential equation.

    My second possibility was using a low or high pass filter, or even a khalmann filter. In regards to combining IMU data(gyro and accelerometer) to form angle measurments. But I don't quite remember a solid differential equation from there, just a lot of usage of integrals and derivatives.

    I need at least one differential equation used, preferrably some of the more complex ones, like Laplace transforms or the delta functions, or something like Linear differential equations. I'm basically not sure weather PID loops cut the criteria. The System I planned on using for the PID loop was a DC motor controlling a simple raft with another object on it, this DC motor controlled the placement of the raft using a PID loop to regulate the current or force used to push this raft

    Thank you in advance,
  2. jcsd
  3. Oct 4, 2015 #2


    User Avatar
    Gold Member

    The DC motor could have a transfer function like:

    ω(s)/V(s) = 5 / ( s2 + 11s + 10 )

    That's a 2. order differential equation, formulated in the Laplace domain.

    Now inserting a PID controller, which could be formulated: y(s)/x(s) = k ( s + a ) / ( s + b ), you multiply by a 1. order transfer function, giving a product of 3. order.
    By means of root locus, you can predict when the controlled motor will be stable/unstable/robust, varying k, a, b.

    That's "Practical differential equations".

    If it's too easy, you can just design a more complex controller, e.g. to (velocity)control the DC-motor so that it will run with no following error at any speed and any load.
  4. Oct 5, 2015 #3
    This seems good. I am currently using a motor controller, But I presume that when I showcase the project I can just explain how a motor controller might have a transfer function like the one you described. Do you have sources on what you are explaining? I'd be great to have something to work with... So w is the angular speed, V is the speed of the DC motor, and S is the input I presume? I'd also assume that your variables such as 11 and 10 are random, and you'd f.ex set a / ( s2 + bs + c ). Where a, b, c are real numbers.

    Concerning the PID controller, I did not get your equation y(s)/x(s) = k ( s + a ) / ( s + b ) but I assume that the PID loop would give out an optimal "speed" V the motor should be running at at any given moment. For reaching the command state, you use laplace transforms and solve the differential equation, getting the input S which can be a valid current output controlled by a microcontroller. Am I getting this correctly? This seems like a great way for say a turbine to reach a set-speed, seems practical.

    If you were assuming the purpose of the PID loop I used was to reach an optimal velocity of the motor, that is not what it was. Which is still fine, as long as I have a useful differential equation to look into. The system I created was a PID loop to place the raft controlled by the motor to a certain position ranging from say +/- 20cm. I did this without even calculating the speed of the motor, but using a PID loop to decide where the output should be from Maximum power+/-(255) to minimum power(0) based on the three variables(location, speed, and acceleration). And then calibrating the variables. An encoder was used to measure rotation.
  5. Oct 5, 2015 #4


    User Avatar
    Gold Member

    No, ω is the angular speed, V is the supplied voltage to the motor, s is the Laplace variable ( complex variable ), like t is the variable in the time domain.
    They are constants, describing the behavior of the tranfer function. If you write: s2 + 11s + 10 = 0, you will have the characteristic equation, which will tell you the time constant/oscillation frequency/damping ratio.
    A PID filter contains one zero ( at s = -a ) and one pole ( at s = -b ). It's a 1. order filter. k is the amplification.
    No, it will calculate the optimal torque needed to satisfy the speed requirements: Too low speed → more positive torque/acceleration.
    By analysing the closed PID loop with root locus, I determine the optimal values of the k, a, b in the PID filter. Then the PID filter will solve:

    y(s)/x(s) = k(s+a)/(s+b) →
    y(s) = ( x(s)*k*(s+a) - s*y(s) ) / b

    This is normally implemented by an electronic analog circuit. ( opamp + RC-network ).

    If a microcontroller is to be used, you should use z-transform ( difference equations ) instead of Laplace transform ( differential equation ). That's because a μ-controller have to do the control by discrete samples with time-delays in between, thus the dx/dt operator will be changed to a Δx/Δt operator, which the z-transform handles, regarding these time-delays. The z-transform transfer function of a "PID" filter has the same structure as the Laplace transform, but the z-domain is completely different from the s-domain. So the significance of the location of roots/zeroes/poles is different in the two domains.

    The three variables: acceleration/velocity/position are accomplished:

    Time domain: a(t) = k , v(t) = k*∫a(t) , p(t) = k*∫v(t).
    Laplace domain: a(s) = k , v(s) = k/s , p(s) = k/s2
    z-domain: a(z) = k , v(z) = k*z / ( z-1 ) , p(z) = k*z2/( z2 - 2z + 1 )
  6. Oct 6, 2015 #5

    Thank you so much. I've been watching this series on LT System analysis and how to calculate the speed and torque of a motor given initial conditions etc etc and I think I'm good to go.

    Am I safe to say in the presentation, that this system is used for high precision motor applications and motor controllers... Is this used in robotics?
  7. Oct 7, 2015 #6


    User Avatar
    Gold Member

    Within mathematics, these initial conditions are a must, but in practical applications, as for a DC-motor, you normally set these conditions to zero ( a=0, v=0, p=0 ). I mean that when you switch on the application, this will normally be true. If you switch on your controller and the velocity of the motor at this instance = 2077√3/π [RPM] ( just an example ), how should the controller react? Well, if the set velocity = 0, the controller should bring the motor to a halt, but it should always do that, no matter what this initial condition might be.
    It is used to control motors/applications ( what is "high precision"? ). Remember that in an analog controller you are using components ( resistors, capacitors ) with some tolerances, thus it's not "high precision". But by digital control, using integer constants/calculations ( no rounding errors ) e.g. the velocity could be made exact, measured in encoder-counts per sample, and could be made with no following error ( ±1 count ) as said in #2.
    Yes, digital control is preferred as robots must be accurate. Say you want to bring the robot to a halt, you must by analog control measure that the robot is halted by means of a tacho generator or a D/A-converter. But if there is an offset in your measurements ( which there is ), the motor will drift ( 1 RPM ). By digital control, using an encoder, 1 count = 1 count, and integer calculation will take care of that and will bring the robot back to correct position, even if the motor is velocity controlled.
    Last edited: Oct 7, 2015
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook