PID loops or Complementary filter for University project?

In summary: But in summary, the conversation was about the practical differential equations project for the "maths III" course in the university. The project involves describing a practical system that uses differential equations, and the options discussed were PID loops and using a low or high pass filter to combine IMU data. The conversation also touched upon designing a more complex controller for the DC motor and using a motor controller with a transfer function. The conversation also mentioned using root locus to predict stability and solving differential equations using Laplace transforms.
  • #1
Jarfi
384
12
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, preferably 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,
-Jarfi
 
Engineering news on Phys.org
  • #2
Jarfi said:
I need at least one differential equation used, preferably 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
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.
 
  • #3
Hesch said:
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.

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.
 
  • #4
Jarfi said:
So w is the angular speed, V is the speed of the DC motor, and S is the input I presume?
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.
Jarfi said:
I'd also assume that your variables such as 11 and 10 are random
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.
Jarfi said:
Concerning the PID controller, I did not get your equation y(s)/x(s) = k ( s + a ) / ( s + b )
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.
Jarfi said:
I assume that the PID loop would give out an optimal "speed" V the motor should be running at at any given moment.
No, it will calculate the optimal torque needed to satisfy the speed requirements: Too low speed → more positive torque/acceleration.
Jarfi said:
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.
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 )
 
  • Like
Likes Jarfi
  • #5
Hesch said:
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 )
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?
 
  • #6
Jarfi said:
calculate the speed and torque of a motor given initial conditions etc etc and I think I'm good to go.
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.
Jarfi said:
this system is used for high precision motor applications and motor controllers
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.
Jarfi said:
Is this used in robotics?
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:

1. What is a PID loop?

A PID (proportional-integral-derivative) loop is a control algorithm commonly used in engineering and science to regulate a system's output based on its desired setpoint. It calculates an error value by comparing the current output to the setpoint and uses proportional, integral, and derivative terms to adjust the system's input and minimize the error over time.

2. How does a PID loop work?

A PID loop works by continuously calculating the error value and adjusting the system's input based on the proportional, integral, and derivative terms. The proportional term adjusts the input in proportion to the error, the integral term sums up the past errors to correct for any steady-state error, and the derivative term anticipates future errors and helps to prevent overshoot.

3. What are the advantages of using a PID loop?

The advantages of using a PID loop include its ability to handle various system dynamics, robustness to disturbances and noise, and easy implementation. It is also a well-studied and widely used control algorithm, making it easy to find resources and support.

4. What is a complementary filter?

A complementary filter is a data fusion algorithm used to combine data from two or more sensors to obtain a more accurate and reliable estimate of a system's state. It works by filtering the high-frequency noise from one sensor and the low-frequency noise from another sensor, and then combining the filtered signals to obtain a more accurate measurement.

5. How do I choose between a PID loop and a complementary filter for my university project?

The choice between a PID loop and a complementary filter depends on the specific requirements and characteristics of your project. If your project involves controlling a system's output, a PID loop would be a suitable choice. However, if your project requires fusing data from multiple sensors, a complementary filter would be more appropriate. It is best to consult with your project advisor or conduct a thorough analysis of your project's needs to determine the best option.

Similar threads

Replies
9
Views
2K
Replies
5
Views
3K
Replies
6
Views
980
  • Electrical Engineering
Replies
12
Views
2K
  • General Engineering
Replies
2
Views
5K
Replies
8
Views
7K
Replies
4
Views
2K
  • General Engineering
Replies
1
Views
2K
  • Mechanical Engineering
Replies
9
Views
2K
Back
Top