Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Opamp PID help (current control)

Status
Not open for further replies.

kblnig

New Member
Hi i am making a PID controller for some current control on a DC motor (might just end up with a P or A PI controller this is just as an example)

I designed the controller as a PID with the open loop transferfunction: 16s+16/(s+6)

When i then implement this in an open loop function in LTspice everthing is good (the step response from matlab and ltspice looks the same)

However when i close my loop i get some nasty opamp oscillations.. I tried placing some capacitors in parrallel with the feedback resistor and a capacitor to ground which helped a little on this matter.. This however made my system quite slow. Is there another way of removing the oscillations? am i doing something wrong? and can the motor current control be implemented via some sort of IC instead :)?

Thank you

https://sperbits.ch/PID.asc
 
How did you arrive at that particular value for the transfer function?

Have you done a Bode plot analysis to observe the loop phase margin, or determine the locations of the poles and zeros to determine the stability of the loop? A closed-loop system must be analyzed by one of these techniques to determine its stability. Otherwise you are just guessing.

Any analog IC to do this function will require similar PID compensation and analysis.

One option to a PID loop is to use Fuzzy Logic in a microprocessor. Fuzzy Logic is not as well known but it's rather intuitive for implementing a control loop. It works well to handle non-linear components such as a motor and is easy to tweak to fine-tune its performance. The Fuzzy Logic program consists basically of a series of IF-Then-Else commands so does not require a lot of processing power for a typical control loop.
 
Your design/simulation is not realistic. Normally, the feedback is taken from a current sensor in series with the motor. Where is that in your simulation? In other words, closing the feedback loop the way you did it is totally non-physical.

The goal of a PID design should be to create a system which exhibits the best possible response (step response, slew rate, overshoot, ringing) BASED on the dynamics of the mechanics being controlled. You cannot just design an open loop transfer and expect that a mechanical system will follow. Instead you have to start with the mechanical system, figure out how it behaves instrinsically, and then design a feedback network which will (hopefully) get the best possible response from the mechanics...
 
Last edited:
Thank you for your answers.. of cause i know that this is not realistic :) - but the loop should still be stable if the closed loop transfer function is examined... the closed loop transfer function (with a unity feedback gain) gives (16s+16)/(17s+22).. I will of cause add the motor but at first i would like to understand why the opamps are behaving like this.. :(
 
Hello there,

What is that the equation of? I ask because it does not look complete with reference to a motor drive. The motor has both inductance and rotational inertia and both of these show up in the denominator (yours only shows one or the other) and both of these may affect the response. Maybe your equation only shows the rotational inertia of the system? That's usually good, but maybe not enough in this case.
Also, all of the control theories out there go to pot if you dont check your response limits, theoretical vs actually attainable.
Maybe you could tell us how you got to that equation, in detail.
 
Last edited:
Maybe you could read this.

Would this inspire you? **broken link removed**
 
Okay i clearly stated my question wrong :D - i know how to design a PID controller, but i have never toyed much around with analog electronics.. I then had to make a analog feedback loop for a DC motor but in order to do that i wanted to play around with ltspice to see if any troubles would arise.. The open loop controller i showed you is actually from taken from a book ;) If you take the open loop controller and spice it and then take the transfer function of the open loop controller and apply a step in matlab the system responses looks alike. If i however close the loop in matlab (by using the feedback(transferfunction)) the response from matlab and the response from the spice simulation are way off.. No matter how i do this i get some sort of oscillations in spice but not in matlab... What is causing that? I was thinking of testing it with the ideal opamp instead of the powered opamp but when i try to implement the ideal opamp in ltspice it gives some sort of "unknown subcircuit called in".. how do i solve this?

And finally.. could someone perhaps show me a place where i can find an analog implmenteation of a closed loop current control?

Thank you for your help so far!
 
I've had situations were an ideal op amp gives no oscillations, but a non-ideal one does. The non-ideal one adds a small amount of phase shift which triggers the oscillation. The non-ideal one is likely how it will operate in the real world.

To use the ideal op amp in LTspice you need to add a .include function for the op amp model. The ideal model is located in the model library.
 
Last edited:
According to my simulation the transfer function (s+16)/(s+6) has 8.5db of low frequency gain and 24dB of high frequency gain, thus the transfer function has active (gain) components. If you put a transfer function with gain inside an op amp loop with more gain then you likely will get oscillations. Normally the transfer function used in an op amp feedback loop is passive and has a gain of less than one.
 
Thank you for the answers and for your time ;)

the transfer function should be (16s+16)/(s+6). But what you are saying about the opamps are that you should never magnify the have a gain less than one? (i btw managed to remove most of the oscillations by simply removing the I and D term... i dont know why that helped seen from a mathematical point of view, but i guess i can live with that ;)).. Another concern i am dealing with when designing the motor current control circuit is that i want control the motor with a signal going from -5v to 5v.. In order to control the H-bridge that i have found (LMD18200) i must supply it with bot a direction signal and and a PWM signal in the range of 0-55v.. Is it possible to get a chip that extract the sign of the signal and the magnitude of the signal or even better a chip that bot converts the signal into a pwm signal and a sign/direction signal? i have been looking at the drv102 in order to generate the pwm signal. Is this chip recomendable for the purpose :)
 
the transfer function should be (16s+16)/(s+6). But what you are saying about the opamps are that you should never magnify the have a gain less than one?
Yes that was a typo in my reply, I used (16s+16)/(s+6) in my simulation.

Don't understand what you are saying about opamps. Opamps have a very high open loop gain, and the closed loop gain is determined by the feedback network, which normally is a passive network with a gain less than one. If the feedback network has a gain greater than one, the circuit may oscillate.

I suggest you read a tutorial on opamps, such as this, to better understand their operation. Also you might read this on Bode plots which can be used to determine the stability of a closed loop system.
 
Hi kblnig
Did you get your PID stability figured out? I am also having trouble getting stability in my PID circuit.
 
Hi kblnig
Did you get your PID stability figured out? I am also having trouble getting stability in my PID circuit.
Instability is a common problem in PID loops.

What are you controlling?

What type of instability are you seeing?
 
Maybe I'm missing something but why on earth do you need PID? :eek:

Current control has no time constant dependant on motor speed or load characteristics so all you need to do is drive the motor with an electronic "constant current source" and the current will remain constant. The constant current source will resond in real time in uS (possibly nS) and it is irrelevant what the motor or load is doing at the time...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top