Author Topic: off the shelf PID control IC ?  (Read 19093 times)

0 Members and 1 Guest are viewing this topic.

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
off the shelf PID control IC ?
« on: March 15, 2013, 11:05:06 am »
I've been asked second time around now to make a controler for a servo mechanism that uses a potentiometer for position feedback and takes essentially a voltage input to tell the controller how to drive the motor.

I believe this is nothing new and known as a PID ? Last time i tried to do this I ended up with an MCU messing about with program parameters as I needed the servo to track my input but because of the motor inertial I ended up making a buzzer.

Ideas ?
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4525
  • Country: au
  • Question Everything... Except This Statement
Re: off the shelf PID control IC ?
« Reply #1 on: March 15, 2013, 11:16:14 am »
more often than not its a slew rate dampened op amp, with some hysteresis added, P and I right there,

most servos don't require full blown PID, and in most cases the methods to tune a PID chip don't work at the speeds your loop would be facing...

p = proportional, which is what an op amp naturally does for its inputs,
I = integral, or time based response, where your hysteresis would come in handy as it will slowly over time leak it towards the correct output,
D = derivative, this is effectivly having a capacitor coupling to one of your inputs, it responds to rate of change and unless your loading it oddly would work against you,
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #2 on: March 15, 2013, 11:25:34 am »
hm, I sort of see what you mean, my first attempt was with comparators but I was working with a window comparator setup (the hysteresis bit).

So are you suggesting that basically the opamp output will change based on the difference between required position and actual position so that as the gap closes the drive (voltage) reduces to stop over shoot. I'm not clear on what you mean by capacitve coupling.

Would something like a comparator with hysteresis work ? providing the hysteresis is enough for the motor to stop before overshooting.
 

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 1843
  • Country: fr
    • kripton2035 schematics repository
Re: off the shelf PID control IC ?
« Reply #3 on: March 15, 2013, 11:45:02 am »
good readings :
microchip app note 937 : Implementing a PID Controller Using a PIC18 MCU
explainations about pid : http://projeneering.com/electronics_projects/elec_pid.html
another : http://www.pcbheaven.com/wikipages/PID_Theory/?p=0
pid library for arduino : http://playground.arduino.cc/Code/PIDLibrary

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #4 on: March 15, 2013, 12:00:01 pm »
I'm thinking, possibly not completely straight, what if I have a H bridge, each side controlled by a different comparator using common feedback and reference, it will just drive the motor in the correct direction until it goes over the threshold and stop, this does not need to be super accurate.
 

Offline notsob

  • Frequent Contributor
  • **
  • Posts: 644
  • Country: au
Re: off the shelf PID control IC ?
« Reply #5 on: March 15, 2013, 01:33:21 pm »
Georgios over at pcbheaven has several PIC projects using PID, with some associated theory, may be of interest to you simon

http://www.pcbheaven.com/projectpages/
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: off the shelf PID control IC ?
« Reply #6 on: March 15, 2013, 03:00:27 pm »
Sigh. In the halcyon days of The Analog i spent my youth implementing op amp based PID controllers for heavy industry. You really need only a single op amp, a few caps and resistors and there is your PID controller. Nowadays everyone uses MCUs for that, and why not.
A true analog PID controller takes a setpoint voltage, process feedback voltage, and produces the command signal as a voltage. If you drive a motor a more desirable output may be a pwmn signal or similar, but strictly that is not part of the PID controller. The command signal is the proportional-integral-derivative of the setpoint and actual value difference. Hence PID.

The key challenge is not at all in implementing the controller, practically anyone can cobble together the circuit or the source code. The trick is in correctly tuning the controller. There is no real shortcut, you need to know at least the bare rudiments of control theory to be able to accomplish anything by design as opposed to chance. This is where the math bogeyman enters. Ideally, you would characterize the "plant" i.e. your system that needs controlling. The full expression of said characterization would be to write the plant transfer function from which you can then extract the poles and zeros and position them in s-coordinate plane for examination. Or if you do the PID using a discrete time system such as a MCU, you would need to perform the z transform to extract the discrete time response of the system.
In practice you really need to be an actual trained control engineer to be able to do this consistently. I wrote above that there is no real shortcut and that is true in a sense, but you don't have to tune a PID the hard way every time. You will get a long way by just doing a rudimentary frequency response analysis, and actually your buzzer will function as one. The first task is to get an idea of the resonant frequency of the plant+controller loop. Most anything you will encounter will count as a LTI or Linear Time-Invariant system, or as close as makes no difference. That means that the internal signal transport delays in the system are more or less constant and that in turn means that the resonant frequency will stay more or less in one place regardless how you fiddle the system (provided you do not change the loop topology in a significant way). So, after finding out that your dandy control system is actually a poor man's oscillator, the next task is to find the frequency of oscillation. Once you have an idea about that, check that your controller time constants (the derivation and integration times) are roughly in the same ballpark. Once there you know that you can position transfer function poles and zeros somewhere around the resonant frequency.
There are different methods of tuning a PID controller. Many of those start by first finding the maximum proportional gain that the system tolerates and then tuning the integral and derivative terms. It is important to understand that the function of the integral term is to provide "infinite" DC gain, thus removing any static operating point offset remaining after the P term is done. The derivative term in turn gives an enhanced control response to rapid variations in either setpoint or actual value. Both should be set to 0 when tuning the proportional term.
After this it gets more complicated - hopefully the Interweb has something to say about it.
Like i wrote, i have played with those things all my life so ask away if there are details you want to clarify.

Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2025
  • Country: au
Re: off the shelf PID control IC ?
« Reply #7 on: March 15, 2013, 04:22:33 pm »
As Kremmen has already stated a PID control loop is easy to build, it’s the tuning of it that can be a PITA. I’ve often been called to plants where they have changed out a PID controller or some peanut has fiddled with the set points and they can’t get a stable output anymore.

The methods I’ve used are exactly as Kremmen has stated. Turn Integral and Derivative off. Then adjust Proportional to give you the desired rate of change in the output for an error. This can be seen as the gain but on some controllers they blur it in with the set point. It can also be a little confusing because adjusting P, I and D can also be called adjusting the gain of the PID terms. The bottom line is that the output is proportional to the error input

Integral is the area under the curve graphed by the output over time. As the output ramps up from off, the area under the curve increases essentially giving “weight” to the control. This is used to prevent over or undershoot once the proportional part has reached or is reaching its set point.

Imagine that what you are controlling is sitting exactly where you want it. As you plot this over time and take the area under that plot for a give unit of time then this is exactly what you want. The integral part of the controller will have no error. In the situation described above, where you have just started, the output starts ramping up towards the set point and the area under the curve is growing so slowly the integral part is winding back its output. As it approaches the set point the proportional is still trying to drive the output the integral will start subtracting from the output, essentially killing any proportional output. Too much integral and you end up with an overdamped response to little and you’ll get ringing, or a slight oscillation upon reaching the set point.

Normally for the stuff I’ve dealt with that’s about it, rarely do the systems I have worked with need any derivative namely because they have used PID to mitigate slow response systems where once the output is ramping up, simply turning it off doesn’t immediately halt the ramp due to inertia.

Derivative is the gradient or slope of the feedback curve at the current point in time.  Say for example the output shoots away from the set point for some reason. It looks at the slope of the deviation and applies more feedback if it is steep or less feedback if it isn’t. Derivative can be tricky on some systems, too little and the system is slow to respond, too much and the system “hunts” or oscillates.

I hope I haven’t stuffed anything up in my explanation

 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #8 on: March 15, 2013, 05:11:46 pm »
Well I don't need full blown control here. I just need a motor position (given by a pot it drives) to mirror that set on a manual potentiomter.

Now immediately i need to have 3 settings as is a motor controlling a flap so open, closed and mid point is all they want, I can do that with a window comparator for the middle position and a single comparator for upper and lower positions.

But i know that we have water valves operating in the same way. And it would be good to be able to control those too. The PWM idea is good, this would slow the motor down as it approaches the the desired point so that it does not overshoot. I guess a minimum duty must be maintained to carry the motor into the "hysterisis" zone where it can rest. An opamp can make a triangle wave and another can be used with a DC voltage from the main oopamp as a comparator to generate the PWM impulses.
 

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 1843
  • Country: fr
    • kripton2035 schematics repository
Re: off the shelf PID control IC ?
« Reply #9 on: March 15, 2013, 05:32:46 pm »
isnt it how a servo works ?
so sparkfun has a ready made open source module : http://www.sparkfun.com/products/9014/
also a schematic with a M51660L integrated circuit : http://corsair.flugmodellbau.de/files/elektron/225215~1.PDF

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #10 on: March 15, 2013, 05:55:09 pm »
yea, that is all i want, a servo circuit
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #11 on: March 15, 2013, 06:05:05 pm »
what a pity the M51660L is "unobtainium" i had the same problem with another similar chip.
 

Offline qno

  • Frequent Contributor
  • **
  • Posts: 422
  • Country: nl
Re: off the shelf PID control IC ?
« Reply #12 on: March 15, 2013, 07:07:50 pm »

Go play with it, you will learn the most.

You will find out that a P controller will never reach the setpoint because then the difference is 0 and your motor will stop.
To reach te set point you will need an Intergator.

If you need only open and close and close a valve you can use to end switches to indicate full open and fully closed.
Why spend money I don't have on things I don't need to impress people I don't like?
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #13 on: March 15, 2013, 07:13:51 pm »
I need some intermediate points. At the moment only one midpoint so i could do it with a window comparator, but i need something that will do any position too.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: off the shelf PID control IC ?
« Reply #14 on: March 15, 2013, 07:18:23 pm »
If you actually want an off the shelf solution, as in "no design required" then your best bet is a small PLC with a PID function.
And just to avoid confusion: a "servo" is by nature a control loop so it is a "full blown" control. If it isn't then it isn't a servo either.

Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #15 on: March 15, 2013, 07:21:12 pm »
well it's definitely a servo, motor drives a pot circuit compares motor driven pot to user pot and commands motor accordingly
 


Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #17 on: March 15, 2013, 07:26:58 pm »
hm may or not be what my work want. they will probably want a more reliable source. but why are these only available from china ? don't we use them in europe any more ?
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #18 on: March 15, 2013, 07:39:52 pm »
i'M THINKING SOMETHING ALONG THE LINES OF THE ATTACHED
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #19 on: March 15, 2013, 07:58:55 pm »
I found the TLE4206 at RS which looks good.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: off the shelf PID control IC ?
« Reply #20 on: March 15, 2013, 08:25:09 pm »
i'M THINKING SOMETHING ALONG THE LINES OF THE ATTACHED
Won't work, i am afraid. That is an oscillator, not to mention that i have serious doubts about the circuit itself.
You are obviously trying to take shortcuts that won't result in a working system.

I found the TLE4206 at RS which looks good.
That looks better, if you can get it. DK at least says "non-stocked"
« Last Edit: March 15, 2013, 08:29:41 pm by Kremmen »
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #21 on: March 15, 2013, 08:31:33 pm »
yea that was meant to be quick and nasty.

I'm guessing a proper system will need a diff amp to give a value of how far apart what you have and what you want is and that needs to be fed into a pwm circuit (triangle wave gen + comparator) that also needs some way of differentiating direction. Hysteresis is needed and a minimum value of PWM must be maintained to get you into the hysterysis region so that's added circuitry and i have no idea of how to put in a bidirectional hysteresis.

I'm hoping that chip from RS will do it, they say it's for things like headlighht alignment and that is similar to what we want.
 

Offline Cones

  • Regular Contributor
  • *
  • Posts: 62
  • Country: gb
Re: off the shelf PID control IC ?
« Reply #22 on: March 15, 2013, 08:32:43 pm »
Is something like this any good?

http://www.pololu.com/docs/0J38/1.a

I've used the standard servo controller they make before, for small self contained operation without a model Receiver. The above board has built in PID and a software interface to tune it.

Mark
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #23 on: March 15, 2013, 08:34:26 pm »
this needs to be cheap and not require any "programming" unless I just go for an MCU and to be fair i did once and nearly nailed it.
 

Offline Cones

  • Regular Contributor
  • *
  • Posts: 62
  • Country: gb
Re: off the shelf PID control IC ?
« Reply #24 on: March 15, 2013, 08:35:13 pm »
They make this BIG servo that is driven with the above board.

http://www.pololu.com/catalog/product/1391

HTH

Mark
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2025
  • Country: au
Re: off the shelf PID control IC ?
« Reply #25 on: March 15, 2013, 11:45:56 pm »
How much torque is required to move the flap? Maybe you can go old school and use a couple of selsyn's, nothing but a couple of synchro motors and some AC. These are also known as resolvers.

 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: off the shelf PID control IC ?
« Reply #26 on: March 16, 2013, 07:29:37 am »
this needs to be cheap and not require any "programming" unless I just go for an MCU and to be fair i did once and nearly nailed it.
So do i understand correctly, that your application is controlling a flap (ventilation, maybe?). In that case you hardly need a true servo system, because the point of a servo is that it has dynamics, i.e. it can follow a (rapidly) moving setpoint. Think of industrial robots, the ultimate servomechanisms.
If i had to implement this kind of system, i would keep it simple: limit switches at both ends of travel, plus a system to get a position between. Control by a 3 position switch: open-set-closed. The "set" would then be adjusted with a setpoint pot. To actuate the setpoint you need a window comparator or 2. A wider window to indicate close proximity of the flap to the setpoint. This slows the motor down. Secondly a tighter window to indicate arrival in position and end of cycle. Additionally you need the motor drive circuit. Why not make life simple and do it using a direction relay and simple one fet pwm speed control? Absolutely jellybean components only, and everything is replaceable by whatever you can find. If it was me, i would grab my favorite puny MCU, the ATMega328 and spend an hour or 2 implementing the window comparators and pwm driver. Or you can do it with Arduino if you are not keen on making a board of your own. I wouldn't though, beacuse Arduino is anything but industrial in its implementation.
Really, this is how i would do it and i know for a fact that it would work just nicely.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #27 on: March 16, 2013, 08:19:26 am »
No I don't need fast reaction times. I have two scenarios, one where it is the ventilation flap and just needs a mid point, this is simple enough with a window comparator, we don't need to be too acurate so a big window is fine giving the motor time to stop before overshooting.

The other scenario is a water valve that controls hot water (engine coolant) into the system to control the temperature, this will need a few "points" so pretty much fluid control to any position, in reality the hysteresis will limit the infinity of positions to roughly "total scale"/"hysteresis gap"
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: off the shelf PID control IC ?
« Reply #28 on: March 16, 2013, 09:59:55 am »
No I don't need fast reaction times. I have two scenarios, one where it is the ventilation flap and just needs a mid point, this is simple enough with a window comparator, we don't need to be too acurate so a big window is fine giving the motor time to stop before overshooting.
So the simple system either with a single or dual window would be OK for the flap thing.
Quote

The other scenario is a water valve that controls hot water (engine coolant) into the system to control the temperature, this will need a few "points" so pretty much fluid control to any position, in reality the hysteresis will limit the infinity of positions to roughly "total scale"/"hysteresis gap"
Here you will want a simple PI controller. Issues i would look into (and you will have to, as well):

- firstly, in your plans, keep the motor driver separate from the controller (unless you end up doing everything with one ready-made chip).

Controller:
- a simple one op amp circuit will manage the PI controller. The traditional way is to provide (say) +/- 15V supply and to things bipolar. That way you avoid the hassle of messing with offsets here and offsets there. Doing it this way, the traditional scaling is for the setpoint to be a +/- 10 V signal, positive being the nominal "forward" direction, whatever "forward" means in a particular app. The feedback from the plant is then the opposite, i.e. -/+ 10V with negative voltage in the "forward" direction. That way the voltages cancel each other when everything is in balance.

- the error signal that the controller acts upon is created simpy by summing the setpoint and feedback signals in an inverting amp's inputs; that amp is the actual controller as well. Lets call the signal input resistors Ri. Both should have the same value if you want the controller to behave symmetrically in respect to setpoint and actual values. The difference of the input currents through the input resistors is the error signal to the controller

- The control laws are created by the amp feedback (in this case). In a PI controller you have a cap and resistor in series. Lets call the feedback resistor Rf and the cap Cf. Now the proportional gain is simply Rf/Ri as we know from op amp theory. The integrator time constant is Ri*Cf and the corresponding corner frequency is f = 1/(2 * pi * Ri * Cf). You can easily visualize the time constant when you know that the controller output will slew the amount of the input voltage differential per each time constant. To clarify: say you have a pure integrator to keep it simple. Lets make it a slow one and specify 1 k input resistors and a 100 uF feedback cap. So Ri = 1kohm and Cf = 100 uF. Now the time constant will be 1k * 100u = 100ms. Next lets assume we are in the middle of running the thing and everything is perfectly balanced with the setpoint at +5V and the actual value at -5V, summed at the amp input over the Ri resistors, 1k each. Now both signals will cause an input curent of 500 uA to the virtual ground point at the amp inverting input. But since they are of opposing signs, they cancel out and everyone is happy. Now let's assume the operator turns the setpoint pot to increase the signal to 6V. Immediately the input currents are no longer balanced when the setpoint voltage causes 600 uA current and thus +100uA net current into the virtual ground point. The amp output starts slewing down to compensate, pulling the current into a charge in the feedback cap Cf. We had 1V imbalance in the inputs and with 100ms time constant, the output starts slewing 1V per 100ms, ie 10 volts per second until the actual value increases to again balance the amp, or the signal hits a rail.

- Adding the proportional feedback resistor Rf to the above just creates a step response to signal changes.


In practice you need a number of enhancements, the most important of which are:

- Usually you want the "forward" command signal from the controller to be positive voltage, and decoupled of any load to keep the controller accurate. In that case just add another inverting amp stage with gain of 1.

- It is a good idea to be able to "disable" the controller when you are not actually running the system. That is easiest done with a relay or maybe jfet across the feedback components. That way you short circuit the feedback which keeps the amp happy producing 0 voltage to any input. In any case you need to be careful to avoid windup in the feedback cap so take measures to be able to reset it when appropriate.


Once you have your controller, you can start designing the actual motor driver. Again, for a modestly dynamic system such as a valve control motor, i would use the KISS principle. A comparator to detect direction (for direction relay control) and a simple signal magnitude based pwm control for a fet would appear simplest. Of course if you need to constantly fiddle with the valve position, then a H bridge may be appropriate. Whatever you do, create a clear interface between the controller and the motor driver, with well defined signaling between.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #29 on: March 16, 2013, 10:24:09 am »
thats helpful but I'm not an opamp wizkid so lets see if I am getting this right.

Your suggesting i use a summing amplifier and make setpoint and feedback voltage "directions" opposite so that the system naturally tends to nullify itself and so stop the motor where it is needed. so far so good, what exactly is the capacitor in the feedback loop for?, my understanding of integrators is that they "add over time" the input voltage, or will this do the opposite ? subtract from the top down so that the drive reduces to stop overstoot ?

I will have only a fixed 12V supply so a +/- supply will just mean adding extra circuitry, would i be safe with a virtual ground and +/-6V ?

maybe time to get the breadboard out
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #30 on: March 16, 2013, 10:50:02 am »
Attached is what I think you mean, I do have though a thought.

What is i used the summing amp system, that would supply an output voltage that is positive or negative (to the virtual earth) in proportion to the difference in desired position and actual position. so what if that gets fed into a window comparator ? each comparator will represent the direction to motor must move in to correct the "error" and can command the correct side of a "H" bridge. the "window" would be the hysteresis / accepted position error that would allow the motor to stop in before going into buzzer mode.

A variation on this could be that the voltage from the controller is fed to a PWM generator that will drive the bridge "proportionally" to the error to correct and the window comparator would select the correct direction.
 

Offline ignator

  • Regular Contributor
  • *
  • Posts: 205
  • Country: us
Re: off the shelf PID control IC ?
« Reply #31 on: March 16, 2013, 11:34:10 am »
Attached is what I think you mean, I do have though a thought.

What is i used the summing amp system, that would supply an output voltage that is positive or negative (to the virtual earth) in proportion to the difference in desired position and actual position. so what if that gets fed into a window comparator ? each comparator will represent the direction to motor must move in to correct the "error" and can command the correct side of a "H" bridge. the "window" would be the hysteresis / accepted position error that would allow the motor to stop in before going into buzzer mode.

A variation on this could be that the voltage from the controller is fed to a PWM generator that will drive the bridge "proportionally" to the error to correct and the window comparator would select the correct direction.
I'm late in seeing this post.  Your way over thinking this.  This is what's known as a bang-bang control system, basically it's off or on (closed or on).  You added a middle position requirement.  I've not read in detail all the helpful posts you've received, but what I see missing is a feed back sensor that tells your controller where the flap location is.  This is needed if you want the half open selection.  As this is NOT a PID system, with human input that's not being tracked real time.  Just a "P". How cheep do you need this to be?  The expensive part will be the motor drive and feedback sensor, which can be as simple as a microswitch.  The motor could be a spring return to the closed position.  How big is the flap, i.e. how much torque do you need.  If small enough a very small gear motor, with spring return to closed, a micro switch on the link to the flap, for half open, and the motor stalling at full open, so current limiting (maybe intrinsic to the motor windings).  The controller is a 3 position switch, off, half, (the micro switch will interrupt this, then oscillate on off holding this position, and full, driving the motor to the end of the flap travel and stalling.
How many of these is planned to be produced?  Is this high end, or as cheep as possible?  But from what I see this does not need a closed loop control system.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #32 on: March 16, 2013, 11:42:05 am »
As i said somewhere we have the motor drive with built in position pot, and we use water valves using a similar system. I just need to control it. I have no idea how many are required.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: off the shelf PID control IC ?
« Reply #33 on: March 16, 2013, 01:46:33 pm »
thats helpful but I'm not an opamp wizkid so lets see if I am getting this right.

Your suggesting i use a summing amplifier and make setpoint and feedback voltage "directions" opposite so that the system naturally tends to nullify itself and so stop the motor where it is needed. so far so good, what exactly is the capacitor in the feedback loop for?, my understanding of integrators is that they "add over time" the input voltage, or will this do the opposite ? subtract from the top down so that the drive reduces to stop overstoot ?

I will have only a fixed 12V supply so a +/- supply will just mean adding extra circuitry, would i be safe with a virtual ground and +/-6V ?

maybe time to get the breadboard out

The feedback cap _is_ the integrator. You know from basic circuit theory, that if you drive a current into a cap, the voltage of the cap rises. That is the definition of capacitance: C = As/V of ampere-seconds per volt. So a whopping 1 farad cap would show a 1V increase in voltage for every second you drive a 1 amp current into it.
Google for inverting amplifier and you will get explanation for the way this works. But the idea is simple: assuming a symmetrical bipolar case where the non-inverting input is grounded , an inverting amp will create a virtual ground on the inverting input. The output will act so as to drive the inverting input to match the non-inverting one. Think of it this way: the inverting input will stay at the same voltage as the non-inverting one. If you present a voltage via a resistor to the inverting input, a current will flow since the other end of the resistor is at "ground" potential (the virtual ground). That current has to go somewhere and it isn't going to go into the amp input, as these are real high impedance. But there is the feedback path from virtual ground to amp output. The current can go there. The amplifier drives the output to sink or source this current as needed, and the resulting output voltage is then subject to the impedance of the feedback path. A simple example: +/- supply, amp positive input is grounded. input resistor is 1 kohm and feedback resistor is 10 kohm. You feed in + 1V via the input resistor. Now a 1 mA current starts flowing into the virtual ground and the amp inputs are no longer in balance. This imbalance drives the output to the negative direction (your positive signal went into the negative input). Now the input current continues from virtual ground to amp output through the 10kohm feedback resistor. To achieve balance again, and recalling Ohm's law U=RI, the output must swing all the way to -1mA*10kohm = -10 volts.

If you replace the resistor with a cap, the difference is that instead of U=RI, you get U=It/C. Now you have the quantity of time as part of the output voltage equation and that is a sign of either integrating or differentiating action. Using the same numbers as before, a 1mA current into the virtual ground, and a 100uF cap from virtual ground to output, the amp output would slew 10 V/s. This is exactly what an integrator does.

I can draw you a simple schematic in a minute, to illustrate better.
Edit: schematic attached.
This is the general idea. Can be implemented by any reasonable quad op amp, such as the ubiquitous LM324 - dirt cheap. No component values indicated, that will be your homework. If you do this, then make sure e.g. trimpot R6 is good quality cermet or similar, that _won't_ break its slide connection after a few years. Or else.


As this is NOT a PID system, with human input that's not being tracked real time.
It is not clear which of the 2 systems you are talking about. The flap control can be just a simple positioning loop with target window control. The valve controller on the other hand is (a PID loop), although there is hardly need for the D term. The fact that there is human input has nothing to do with the nature of the controller, that is entirely a different choice and issue.
Quote

Just a "P".
Again, sorry no. With P term only, you always get a static error. Whether that matters or not, is another thing but a valve, especially a sticky one, presents a relatively big static friction load rendering pure P law control inefficient. If you tune the P term high enough to break the friction in a bad case, you will get an oscillator. Sometimes an integrator is a bit difficult to tune to avoid oscillation, and in that case a measured dose of setpoint feedforward usually does the trick.
But the point is that the process determines what control terms are desirable, not the nature of the entity that controls the setpoint.

As i said somewhere we have the motor drive with built in position pot, and we use water valves using a similar system. I just need to control it. I have no idea how many are required.
My reply was targeted to this alternative.
« Last Edit: March 16, 2013, 02:50:22 pm by Kremmen »
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline ignator

  • Regular Contributor
  • *
  • Posts: 205
  • Country: us
Re: off the shelf PID control IC ?
« Reply #34 on: March 16, 2013, 03:21:14 pm »
As i said somewhere we have the motor drive with built in position pot, and we use water valves using a similar system. I just need to control it. I have no idea how many are required.
Sorry, I did not read through the whole post.  As I was trying to filter the unneeded PID information.  PID is used when you have dynamic feedback situations, like the autopilot for the aircraft.  In this case there's the servo amplifier loop, to make it stable, these come in several varieties, but the position type is what I spent the most time with, but you also can have torque command, as well velocity.  For flight control they have the innerloop, this is to fly the aircraft in a stable way, so it just keeps the aircraft airframe from going unstable.  Then there's the outer loop, which is your external navigation command, which can be many things, both lateral and vertical.  Note autopilots are typically 3 axis.  The yaw axis is mainly for yaw damping (YD), as to reduce drag, you end up with the tail wagging, which makes the passengers "sea sick" without a YD.  The AP has the elevator and aileron axis control. These are typically underdamped, unless your in a fighter jet mode of wanting real "crisp" operation.

OK I recalled a circuit from magazine I used to subscribe too.  Model engineers workshop 100th issue August/September 2004.  A guy wanted a pedal controller for his TIG welder and came up with the following:
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: off the shelf PID control IC ?
« Reply #35 on: March 16, 2013, 03:38:25 pm »
Yep, that is a bang-bang controller. It could work allright for the valve as well, provided the dead zone window can be tuned to work. Too narrow and overshooting will create an oscillator - too wide and it will not settle close to the setpoint. As long as those constraints don't clash, it can be made to work.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #36 on: March 16, 2013, 03:42:20 pm »
Yes I'm not looking for full blown pid just a feedback loop system to control the position.

I'm still a bit confused about the integration bit. Is it to do with the mecahnical inertia of the motor that needs dealing with or is it some sort of signal conditioning that is characteristic of PID's ?
 

Offline ignator

  • Regular Contributor
  • *
  • Posts: 205
  • Country: us
Re: off the shelf PID control IC ?
« Reply #37 on: March 16, 2013, 03:43:20 pm »
It looks like D2 is intended for the crossover hysteresis.
 

Offline ignator

  • Regular Contributor
  • *
  • Posts: 205
  • Country: us
Re: off the shelf PID control IC ?
« Reply #38 on: March 16, 2013, 03:44:07 pm »
Yes I'm not looking for full blown pid just a feedback loop system to control the position.

I'm still a bit confused about the integration bit. Is it to do with the mecahnical inertia of the motor that needs dealing with or is it some sort of signal conditioning that is characteristic of PID's ?
Integration is used to get the long term error to zero.  It integrates any error at the summing junction, which then becomes a correction command.
The derivative part is used to overcome (correct for) inertia, depending on if it's motor loop, or the inner loop of the thing your trying to control.
« Last Edit: March 16, 2013, 03:47:32 pm by ignator »
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #39 on: March 16, 2013, 03:46:53 pm »
Yep, that is a bang-bang controller. It could work allright for the valve as well, provided the dead zone window can be tuned to work. Too narrow and overshooting will create an oscillator - too wide and it will not settle close to the setpoint. As long as those constraints don't clash, it can be made to work.

that is what I've been trying to do, it seems I don't know what a pid is. My software solution when i made an attempt with a pic was to check the difference and when it became under a certain point I started using pulses to drive and was rechecking after each pulse. I thunk the valve i had was a bit crap and you could see (and here) the mechanism going up and down hunting for the right point (but not buzzing). The other problem is mechanical hysteresis, there is play in the mechanism that can foul the software if your not careful
 

Offline ignator

  • Regular Contributor
  • *
  • Posts: 205
  • Country: us
Re: off the shelf PID control IC ?
« Reply #40 on: March 16, 2013, 03:49:17 pm »
Getting hysteresis in the bang-bang controller will be key.  You just need to have a dead band window where you do nothing to move the motor.
With your software you have an iteration rate, how short of a time pulse can you put on the motor?  You  need to address this so the motor does not move beyond the dead band window with the shortest pulse you  can make.
« Last Edit: March 16, 2013, 03:52:16 pm by ignator »
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #41 on: March 16, 2013, 03:51:35 pm »
Yes I'm not looking for full blown pid just a feedback loop system to control the position.

I'm still a bit confused about the integration bit. Is it to do with the mecahnical inertia of the motor that needs dealing with or is it some sort of signal conditioning that is characteristic of PID's ?
Integration is used to get the long term error to zero.

Well I don't mind some error, it does not need to be 0 so am I swapping integration for hysteresis window ? I'm happy with having 10-20 positions, at the end of the day the water valve control will be used in a lager pid/tracker system that wants to track temperature so as other system factors change the valve regulating hot wter into the heater so not nailing the position is not an issue if say the position is changed every minute or so so effectively swapping between pos1 and pos2 out of 10 will be giving an average of pos1.5, this is fine because the "frequency" of the system will be very very slow as the temperature will be allowed to vary over a few degrees in a period of minutes.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14491
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: off the shelf PID control IC ?
« Reply #42 on: March 16, 2013, 03:54:16 pm »
Getting hysteresis in the bang-bang controller will be key.  You just need to have a dead band window where you do nothing to move the motor.

yup, trick is going to be keeping it small, that is why if i end up needing a larger window I'd have to reprocess the voltage from the controller and use it to drive a PWM drive so that the motor slows down as it enters the dead zone and does not overshoot. I did this before with software and one pulse duty under a certain error
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2094
Re: off the shelf PID control IC ?
« Reply #43 on: March 16, 2013, 05:53:50 pm »

Go play with it, you will learn the most.

You will find out that a P controller will never reach the setpoint because then the difference is 0 and your motor will stop.
To reach te set point you will need an Intergator.

In this application velocity is controlled and position is fed back so the system is inherently an integrator.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: off the shelf PID control IC ?
« Reply #44 on: March 16, 2013, 06:01:04 pm »

Go play with it, you will learn the most.

You will find out that a P controller will never reach the setpoint because then the difference is 0 and your motor will stop.
To reach te set point you will need an Intergator.

In this application velocity is controlled and position is fed back so the system is inherently an integrator.
Nope. The setpoint and actual values are positions, so that is what is controlled. The command signal is for velocity, but that is _not_ controlled. One just hopes the plant responds as requested. And there is no guarantee that it actually does.
The controller output commands a velocity and below some limit it most likely happens that the command signal is too low to actually move the motor. The I term takes care of that, and you need it in the position loop.

To fully implement a positioning control, you need 3 nested, actually controlled loops; position, velocity, torque. You can do with less but then you won't achieve the best possible dynamics. Of course that is not always needed or wanted, as in this case.

Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline mintsanesta

  • Newbie
  • Posts: 1
Re: off the shelf PID control IC ?
« Reply #45 on: May 30, 2013, 08:27:20 am »
Hi kremmen and others .
I have a concern a pic that I could use to build my PID,  16f877 ,16f84A, 18f2520 or 18LF4550. Where could I get some diagram? Can I use flowcode because I don't know C programming. Thanks to all
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4525
  • Country: au
  • Question Everything... Except This Statement
Re: off the shelf PID control IC ?
« Reply #46 on: May 30, 2013, 08:36:31 am »
that would rely on anyone here who knows C understanding how to use flowcode, which i'm going to guess as rare,
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: off the shelf PID control IC ?
« Reply #47 on: May 30, 2013, 06:41:58 pm »
Hi kremmen and others .
I have a concern a pic that I could use to build my PID,  16f877 ,16f84A, 18f2520 or 18LF4550. Where could I get some diagram? Can I use flowcode because I don't know C programming. Thanks to all
Unfortunately i am unfamiliar with both flowcode and PICs.
By diagram i assume you mean for the PID controller? If so, then Wikipedia to the rescue: http://en.wikipedia.org/wiki/PID_controller

I don't want to discourage, but in my opinion your best and only bet is to learn C if you want to experiment with digital signal processing implementations of any kind. It is all done in C these days or if not, it is the rare exception. With C you will have all the help in the Internet-world and with anything else you will find yourself pretty much alone.

Implementing the basic PID algorithm is "easy" (in C!) but properly applying it may not necessarily be so. I have no idea of your skill level in this topic but from the question i assume it is novice. In that case i recommend at least some study of elementary control systems in general because otherwise you will not get anywhere, or only with blind luck. Even simple feedback systems can exhibit dynamics that will confuse the uninitiated, as we have seen from certain recent discussions on this site too. Mastering those has nothing to do with programming and everything to do with understanding systems consisting of plants and controllers; the dynamics of their transfer functions and stability of the feedback loops.
So, the proper order of things would be for you to first model the system to obtain the overall control strategy and its initial parameters, and only then start worrying about the actual implementation.
Nothing sings like a kilovolt.
Dr W. Bishop
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf