Author Topic: position tracker with op amp  (Read 11966 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
position tracker with op amp
« on: July 21, 2011, 08:47:03 pm »
Right, here is the deal. I have a water valve with an incorporated potentiometer to feedback the valves position (open/close or partly)

Now I've been asked to design a circuit to control the valve with a potentiometer, so if I turn the control pot up the valve will open more and the circuit will determine when to stop driving the motor when the feedback pot is basically sending back the same voltage as the voltage set by the control pot.

So I assumed this was a comparator job. I started with two comparators both taking the same signal on the inverting and non inverting inputs but with the inputs switched. So theoretically when one is has a H output the other is L. I'm using an LM339 and naturally our good friend offset came along and there is a state where both outputs are on. This means that as I'm driving the motor that opens and closes the valve with a H-bridge one almighty BANG !

So I experimented and put a fixed potential divider on the output of the control pot so that there is another control output at 99% of the value set by the control pot. So now each op amp gets a slightly different control signal and I get some window where both outputs are off.

Now I'm feeling really pleased with myself until I realized that my gap between the control pot output and the secondary output off the fixed divider at 99% has to be at least the offset voltage or twice it maybe and that the lower i go the smaller the actual voltage "window", so with a 2% value on the control pot I'm back to square one ! but the position pot only goes down as far as 7.7% anyway and a trial at 4.6% seems reassuring.

Have i found the simplest method of doing this or am I missing something obvious. ? Are there comparators with very good offset specs that don't cost the planet ?

I could use a micro controller and program in as much hysteresis as I want, but I'd rather not or at least know i have an analogue solution up my sleeve.
« Last Edit: July 21, 2011, 08:54:28 pm by Simon »
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: us
Re: position tracker with op amp
« Reply #1 on: July 21, 2011, 09:18:28 pm »
How about using a single comparator as a direction controller, and an absolute value circuit followed by a comparator as an enable control for dead-band control.  The first comparator always says 'open' if the valve is too closed and vice versa, but the second comparator disabled the bridge completely if the absolute value of the error is less than 0.1 volt or something.  That should let you separately control the setpoint and the deadband
 

Offline gregariz

  • Frequent Contributor
  • **
  • Posts: 545
  • Country: us
Re: position tracker with op amp
« Reply #2 on: July 21, 2011, 09:25:40 pm »
Hmm... double ganged potentiometers... maybe a second channel into a second comparitor with a known offset when they are 'close' that you can use as a 'close' indicator.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #3 on: July 21, 2011, 09:26:40 pm »

ejeffry

that's an interesting possibility, so basically I'd have to work out the difference between the two pot outputs and if over a certain value let the valve operate. The only thing is it would have to work with both polarities, I'd need a differential amplifier to get the difference and then compare that to my absolute "offset"
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #4 on: July 21, 2011, 09:27:45 pm »
Hmm... double ganged potentiometers... maybe a second channel into a second comparitor with a known offset when they are 'close' that you can use as a 'close' indicator.

i did think of that but assumed that the cost of a dual pot might be prohibitive but then I have not looked, might be the most robust solution
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #5 on: July 21, 2011, 09:35:05 pm »
yea, looking at prices, they are not bad, I can get a dual pot for under £2.00 although a single pot is as low as £1.00
 

Offline gregariz

  • Frequent Contributor
  • **
  • Posts: 545
  • Country: us
Re: position tracker with op amp
« Reply #6 on: July 21, 2011, 09:38:22 pm »
Maybe you could just take your position signal from the single channel pot and split it 2 ways.... one way to your position comparator... and another way through a diode or 2 with known drop for the 'close' indicator.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #7 on: July 22, 2011, 05:21:20 am »
I thought of that but 700mV is a lot of window on 5V range, but maybe a diode drop at low current is much less ?
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: us
Re: position tracker with op amp
« Reply #8 on: July 22, 2011, 07:24:31 am »
Diodes do have lower forward drop at very low current, but it is difficult to reliably operate them as such.  A diode will have a few 25-40 mV forward drop when operated at a forward current equal to its reverse leakage: usually nanoamps, and very temperature dependent.  In this regime, the input bias current of your op-amp/comparators will have a big affect on your offset voltage.  You could use a schottky diode with its lower ~200 mV forward drop if that is low enough.

Another option is to use a op-amp voltage adder to generate a second trip voltage a fixed voltage above the potentiometer's set-point.  The problem here is that voltage adders are inverting circuits.  You will have to invert twice to get the signal back to the same polarity as the original.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #9 on: July 22, 2011, 08:24:03 am »
yes a voltage adder sounds more reliable and as all opamps come 2 in a DIP8 that will only add one IC, I need 50mV offset idealy over the whole range. unfortunately I seem stuck with 5v in. If i could increase it, it would make the offset less of a problem
 

Offline tecman

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: us
Re: position tracker with op amp
« Reply #10 on: July 22, 2011, 02:05:38 pm »
You are trying to build a closed loop control system.

You need to do three things:

Your H bridge clearly can have cross conduction.  You should either add some logic or a transistor or two to prevent cross conduction.  The H bridge transistors should be fast enough that a fast switching input will be slower than the transistors, so you will not kill anything with a fast input change.

Next you should use an op-amp to generate the error (command-actual) and then follow that signal with some gain.  The amount of gain is a calculable number, but beyond the scope of this post.  Too much gain and you will oscillate, or chatter, around setpoint.  Low gain will end up with greater and greater error.  Put in an amp stage with 1-10 gain and a pot to adjust the amount.  The output of the gain stage can drive the comparitors, or you can use op-amps as simple comparitors to drive transistors.

Last is is likely you will need some compensation if you need higher accuracy.  This is because when you tell the motor to stop, it will still move a bit due to inertia.  Most common scheme is to add a lead term (derivative) in the signal from the error amp to the gain stage.  This lead term will sum with the error and result in slightly more error, "anticipating" the final set point and cutting off  the motor a bit early, and if set correctly the motor will coast into position.  This is known as a PD controller.

Using these schemes, accuracies better than 1% can be achieved.  The greatest source of error may then be variations in load on the motor which will cause the "over run" due to inertia to vary when you cut off the power to the motor.  Higher gains and more accuracy also mean that you will be more sensitive to noise, power supply variations, etc.

paul
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #11 on: July 22, 2011, 02:53:14 pm »
well I have just tried my design out with a real valve. And yes there are problems as anticipated. The top end is not too bad but hard to control and the bottom end keeps oscillating, so clearly not enough hysterysis on the bottom and too much at the top.

I will attempt the micro controller method. This will also allow me to identify the real top and bottom of the range as it is about 7.7-82% not the full 0-100%
 

Uncle Vernon

  • Guest
Re: position tracker with op amp
« Reply #12 on: July 22, 2011, 10:11:55 pm »
Cloded loop control indeed,  DIY is very much reinventing the wheel when eBay will be littered with sub $50 PID/PI controllers that will solve your problem.

If you want to understand the operation a google search of PID or PID circuits should find lots of results. (hint: you wont want/need the "D" in your application).
 

Offline tecman

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: us
Re: position tracker with op amp
« Reply #13 on: July 22, 2011, 10:41:57 pm »

If you want to understand the operation a google search of PID or PID circuits should find lots of results. (hint: you wont want/need the "D" in your application).

Actually you do not want I in the control.  Simple I will always be unstable in a positioning control.  D is what is needed.  Since this is a discrete output control, the D can compensate for lag time associated with switching and inertia.  Switching time is a non-linear delay time, which if consistent, can be compensated.  Motor inertia is also well compensated for by a lead term.

paul
 

Uncle Vernon

  • Guest
Re: position tracker with op amp
« Reply #14 on: July 22, 2011, 10:57:42 pm »
Simple I? do elaborate.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #15 on: July 23, 2011, 11:25:11 am »
the pid units on ebay are all for temperature and large units. My intention is to produce a valve controller that will be part of a vechicle heating/cooling system so a large unit with a display is out of the question
 

Uncle Vernon

  • Guest
Re: position tracker with op amp
« Reply #16 on: July 23, 2011, 12:24:00 pm »
the pid units on ebay are all for temperature and large units. My intention is to produce a valve controller that will be part of a vehicle heating/cooling system so a large unit with a display is out of the question

Wouldn't temperature be the parameter you would need to regulate with a heating/cooling system?
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11714
  • Country: my
  • reassessing directives...
Re: position tracker with op amp
« Reply #17 on: July 23, 2011, 01:39:37 pm »
how about failsafe? you may solve alot of your problem with a micro with adc. here's one suggestion for you... atTiny10! cost only few cents :P
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline tecman

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: us
Re: position tracker with op amp
« Reply #18 on: July 23, 2011, 01:59:31 pm »
Simple I? do elaborate.

By simple I i refer to an integrator that is a fixed value and always on.  Typical of many controllers, especially older designs.  In a positioning system, an integrator can be used, but only when it is a switched term.  The I can be enabled only very close to the setpoint where a number of non-linearities can effect the system.  Typically within 1% or less error.

If you analyze a typical positioning system, you have a position command and position feedback.  The error is position, but most control devices provide a velocity output, such as a motor.  This makes the control an integrating system.  The position error provides a velocity output, or in other terms the error is the integral of the output.  If you add another integral term in the loop, you have two cascaded integrators.  Add an overall loop gain of more than 1 and you have an oscillator.  90 deg from each integrator plus 180 deg from the feedback (negative feedback which is by definition opposite of the output, or 180 deg).  This is 360 deg total.  Add gain and it is a classic phase shift oscillator.

In most controls, near setpoint, the system becomes non-integrating.  This is generally due to friction in the system.  If you think about it, voltage to the motor at very low values will not cause it to spin, but only "wind up" or move slightly against friction and load.  In this region an integrator will help push closer to the setpoint.  So you can apply an integrator only if it is switched on in this region around setpoint.

paul
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #19 on: July 23, 2011, 02:08:15 pm »
the pid units on ebay are all for temperature and large units. My intention is to produce a valve controller that will be part of a vehicle heating/cooling system so a large unit with a display is out of the question

Wouldn't temperature be the parameter you would need to regulate with a heating/cooling system?

yes but I have no been asked for a dispaly or anything but just the controller to be integrated with the rest of the system. The control will be a potentiometer. Sounds a bit odd but that is what I've been asked for. The engineer in charge is a bit dippy about electronics though. I'll do as told and then offer suggestions as i get more information about the whole system
 

Uncle Vernon

  • Guest
Re: position tracker with op amp
« Reply #20 on: July 24, 2011, 08:21:36 am »
By simple I i refer to an integrator that is a fixed value and always on.  Typical of many controllers, especially older designs.

I see what you are getting at. Error correction applied that way is not really integral control.


Quote
In a positioning system, an integrator can be used, but only when it is a switched term.  The I can be enabled only very close to the setpoint where a number of non-linearities can effect the system.  Typically within 1% or less error.

But control of a heating/cooling valve isn't like a positioning system the Process Variable - Temperature is not going to change at a rate matching the valves position.  More often than not, a well tuned loop will have a large P band and will increment via a slowly ramping I percentage.

Quote
If you analyze a typical positioning system, you have a position command and position feedback. ........ If you add another integral term in the loop, you have two cascaded integrators.

Again I don't disagree I think we were assuming two different problems based on the information Simon provided.  Given what Simon has written subsequently I think he is way off the mark, he only requires open loop control.
« Last Edit: July 24, 2011, 08:24:35 am by Uncle Vernon »
 

Uncle Vernon

  • Guest
Re: position tracker with op amp
« Reply #21 on: July 24, 2011, 08:38:15 am »
yes but I have no been asked for a display or anything but just the controller to be integrated with the rest of the system. The control will be a potentiometer. Sounds a bit odd but that is what I've been asked for.

Not that odd of a request at all, almost every basic automotive temperaturesystem works that way. The vehicles occupants are the feedback. It's open loop control. I'd forget the motor's pot it will just complicate your design.

What configuration is the motor that you want to use single wound reversible or double wound? A spring return proportional actuator would be the simplest option, use your control pot to PWM a positioning signal.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #22 on: July 24, 2011, 08:46:12 am »
no I need the pot in the motor to tell me the valve position or i won't knoe if it is open or closed. my control pot is to tell the system where I want the valve to be.

I've opted for an mcu design and am getting better results except that I'm having overshoot problems now even though I've set a "dead window" To make it near viable the dead window has to be so large that it becomes sluggish.

The motor is a simple 24V motor and you have to reverse polarity to drive it the other way, I'm using a H bridge control
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 12542
  • Country: us
Re: position tracker with op amp
« Reply #23 on: July 24, 2011, 09:11:41 am »
If I understand correctly the positioning motor is either "on" or "off" in either direction and you can't regulate it's speed? But possibly you could use PWM to adjust the power fed to the motor? Overshoot is going to be a problem unless you can reduce the power to the motor as the position gets close to the set point.

As has been pointed out above in the thread, the place to start would be simple proportional control action with a gain to be determined. You apply power to the motor in the right direction in proportion to the position error. Once the error is greater than a certain percentage you will likely be applying full power to the motor, but that is fine. It will just cause the motor to track as fast as it can when the error is large.

With a simple proportional control scheme you will likely find that stiction causes the motor to stop entirely before it actually reaches the set point. This will limit your positioning accuracy. You can either increase the gain and risk overshoot, or introduce a little integral action to help wind out the positioning error. A really good positioning system might include derivative action, but that is hard to tune and I would tend to leave it out unless you know how to set it up. The main advantage of derivative action would be faster control action without overshoot and I doubt that is critical in your application.

You don't want to include a dead band or hysteresis in your system as that will just reduce the positioning accuracy. But you do of course want to include a lockout system so you don't activate both forward and reverse drive at the same time. You will want to hard wire this lockout in the drive electronics as a fail safe system and not try to include it in your control logic.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18118
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: position tracker with op amp
« Reply #24 on: July 24, 2011, 09:22:16 am »
yes the power control option looks like the way to move towards.

I have found that the manufacturers spec of min position @ 7.7% and max position @ 82.5% is rubbish. it is actually min 20% and max 50% so I've been fine tuning the control potentiometer range with fixed resistors and this is helping. Some dead window is surely necessary as you get a +/-1 bit error at least from the ADC so I need to "filter out" small fluctuations that mean nothing ?

So using power control basically I'd use the value that defines the different between control and position pot as a rough PWM power figure so that the speed drops drastically as the correct position is nearly attained.

Well the PIC12F615 that I'm using has a PWM in it but direction control then becomes a problem, unfortunately there is only one channel, perhaps I can implement a second channel using logic gates so that 2 enable lines decide which side of the H bridge to run. I'll have to see if I can do it with diodes and save on an IC
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf