Inverting a linear signal

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
John Abel
Posts: 31
Joined: Sat Feb 26, 2005 1:01 am
Location: San Luis Obispo, CA
Contact:

Inverting a linear signal

Post by John Abel » Fri Apr 08, 2005 6:16 pm

If I have a voltage output that varies linearly from 5VDC to 0VDC and I want a simultaneous output that varies inversely, from 0VDC to 5VDC, what circuitry can I add to the original output to achieve this? That is, how do I achieve output B, so that when output A is +5 output B is 0, and when output A is 0 output B is +5, and every step in-between in a linear fashion?

jimandy
Posts: 570
Joined: Sat Dec 04, 2004 1:01 am
Location: Birmingham AL USA
Contact:

Re: Inverting a linear signal

Post by jimandy » Fri Apr 08, 2005 9:03 pm

I will naively suggest a simple inverter using an opamp (like the LM324). <p>Plenty of circuits on the web. Try Googling.
"if it's not another it's one thing."

rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Inverting a linear signal

Post by rshayes » Fri Apr 08, 2005 9:19 pm

A simple inverter wil give you 0 to -5V for a 0 to +5V input. An additional offset needs to be added.<p>This can be done by biasing the non-inverting input of the op amp at +2.5V. This can be a voltage divider from any convenient and stable (probably not the power supply) voltage source. A bypass capacitor to ground is usually a good idea on the non-inverting input. Any noise here gets added directly to the output with a gain of 2.<p>A stable reference can be obtained from a low voltage power supply using a programmable shunt regulator such as the TL431C or one of its relatives. You may want a trimmer on the output, since these parts are only accurate to 1 or 2 percent before resistor tolerances are considered.<p>An alternate approach is to ground the non-inverting input and add the offset to the inverting input of the inverter with a resistor to a negative voltage. If filtering is needed the resistor can be split into two sections with a capacitor to ground at the mid-point. The value of the resistor depends on the value of the negative voltage reference.

User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Re: Inverting a linear signal

Post by MrAl » Sat Apr 09, 2005 5:43 am

Hi there,<p>Before i say anything i'd like to ask what
kind of bandwidth you'll need, or what this
circuit will be used for. Some applications
require high bandwidth op amps and some can
use common run of the mill parts.<p>Take care,
Al
LEDs vs Bulbs, LEDs are winning.

John Abel
Posts: 31
Joined: Sat Feb 26, 2005 1:01 am
Location: San Luis Obispo, CA
Contact:

Re: Inverting a linear signal

Post by John Abel » Sun Apr 10, 2005 2:14 pm

The project that this circuit will modify is for an electromagnetic levitator that I have built from a schematic I found in the Encyclopedia of Electronic Circuits, if you happen to have that book. If not, a very similar project is shown at:
http://www.oz.net/~coilgun/levitation/home.htm
I am hoping to expand on the project by incorporating a second electromagnet that is located below the first, so that a magnet, or a ferrous object, suspended between the two will be subjected to a pulling force from each electromagnet. To accomplish this, a circuit is needed that will provide an opposite signal to that of which is controlling the first electromagnet. So that when the signal from the sensor detects more light due to a falling magnet, the current will increase to the top coil. Conversely, when the magnet begins to rise, the circuit that I hope to design will provide more current to the lower magnet so that the suspended magnet begins to fall again. Equilibrium between the two electromagnets and gravity should eventually be achieved, so that the suspended magnet will float in midair. My hopes are that the second electromagnet will allow for more stability and perhaps more controllability to the original project.
The original project uses a LM358 dual opamp. My knowledge of opamps is very limited, but I believe one of the two is used for amplifying the signal derived from the sensors. The resultant output is from –2.5V to 0 volts. The second seems to invert and amplify this signal to a 0 to +5 volt level, which it applies to a power transistor, which controls the coil. However, both seem to be connected to use their non-inverting input, so I don’t know how the signal is inverted.
I can also tell you that I am powering this circuit from a variable Bench power supply that is set at 12 volts. This voltage is applied to the electromagnet in its entirety, but a LM78L09 chip limits it to +9volts, which powers the opamps and the rest of the circuitry.
I hope this tells you what you need to know, and thank you for your help.

bridgen
Posts: 196
Joined: Sun Aug 25, 2002 1:01 am
Location: Camberley, United Kingdom
Contact:

Re: Inverting a linear signal

Post by bridgen » Sun Apr 10, 2005 4:53 pm

If you want zero volts you will need a dual supply. A so-called "rail to rail" op-amp won't put its output quite at zero volts, only "near enough" for some applications. <p>Stephen's posting tells you how to apply the necessary 2.V offset.

John Abel
Posts: 31
Joined: Sat Feb 26, 2005 1:01 am
Location: San Luis Obispo, CA
Contact:

Re: Inverting a linear signal

Post by John Abel » Sun Apr 10, 2005 10:03 pm

I think "near enough" will suffice, the output never really needs to be at 0V, because that would equate to no current being supplied to the electromagnet. Also, I think the before mentioned application would require the two outputs to be approximately in step with each other, not exactly.

Ron H
Posts: 360
Joined: Tue Dec 18, 2001 1:01 am
Location: Boise, ID
Contact:

Re: Inverting a linear signal

Post by Ron H » Mon Apr 11, 2005 7:26 pm

Connect your two electromagnets in series. Connect the other end of the first one to +V, and the other end of the second one to GND. Drive the center point with your control signal. You'll get the desired result, and you don't need any more op amps. Keep in mind that if you disconnect the drive voltage (the op amp), both magnets will be energized at half strength.<p>[ April 11, 2005: Message edited by: RonH ]</p>

redrocker
Posts: 87
Joined: Fri Oct 29, 2004 1:01 am
Location: Pennsylvania
Contact:

Re: Inverting a linear signal

Post by redrocker » Tue Apr 12, 2005 5:31 am

Notwithstanding the good advice already dispensed by RonH et al, but to answer the original question by way of a schematic that I poached from another forum, just in case the OP is still interested:
Image

John Abel
Posts: 31
Joined: Sat Feb 26, 2005 1:01 am
Location: San Luis Obispo, CA
Contact:

Re: Inverting a linear signal

Post by John Abel » Wed Apr 13, 2005 4:37 pm

Thanks RonH for your help. I now have the project up and running. However, the suspended magnet is very unstable; much more so then the original design. That is, the magnet begins to oscillate until it falls or sticks to the top coil. In the original design, it would remain steady for at least a minute, whereas now it immediately begins to oscillate and will only stay suspended for a few seconds. Therefore, either my idea is fundamentally flawed, or there is something wrong in the design. I plan to build the circuit supplied by Beaker, so I can adjust the gain of the OpAmp(s) to see if that helps. Or perhaps the problem is the position sensor. If any of you have any suggestions to help with the stability that would be great. Otherwise, thanks for the help all of you have already given me.

rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Inverting a linear signal

Post by rshayes » Wed Apr 13, 2005 8:48 pm

You are now at the black magic part of your project.<p>This is a servo loop with a couple of nasty features.<p>The force exerted by an electromagnetic depends on the distance to the suspended object as well as on the coil current. This makes the suspension system non-linear, which means that the small signal gain of the feedback loop depends on where the suspended object is relative to the magnet poles. It will be lowest in the middle and increase as you move toward either pole.<p>Your sensor is likely to be linear over a small range, and then show no change as the suspended object either totally blocks your light source or totally exposes it. I suspect that the linear range of your sensor is probably about 1/8 inch or so.<p>The coil driver shown in the schematic that you referenced is also non-linear. It depends on the transistor current gain, which may be a function of current, and also has a threshold, due to the base-emitter voltage of the transistor. Current gain is also a function of the transistor temperature.<p>The mass of the suspended object also changes the feedback loop characteristics, both as far as gain and also transient response.<p>Calculating what should happen is probably a futile exercise in these circumstances. This leaves a cut and try proceedure.<p>Your starting point is fairly close. When you added the second coil and driver, you effectively doubled the gain in the system. You see a few cycles of oscillation, so you are probably not very far into the unstable region.<p>The first step would be to reduce the overall loop gain and see if the system becomes stable. I would try a factor of 2 to 4 of gain reduction. In the schematic that you referenced, this could be done by decreasing either R5 (100K) or R9 (370K) by a factor of two.<p>Once you have a stable system, you can try changing C3 to see if different values will allow you to increase the gain and still remain stable.

John Abel
Posts: 31
Joined: Sat Feb 26, 2005 1:01 am
Location: San Luis Obispo, CA
Contact:

Re: Inverting a linear signal

Post by John Abel » Wed Apr 13, 2005 9:07 pm

Never mind… I have found out that the instability was caused from my current limited power supply, which was not giving the circuit enough current to operate correctly. After switching to a more powerful supply the project seems to work well. The two electromagnets seem to eliminate the before mentioned oscillation, and the magnet can now float indefinitely. However, the two-electromagnet configuration makes adjustment finicky, the IR sensor has to be placed at just the right position or else the suspended magnet will overcome the attracting force of one of the electromagnets and stick to the other; and because the margin of error is so small any jostle of the suspended magnet or apparatus sends the magnet flying towards one of the electromagnets.
I am hoping to correct this problem by giving the current to the individual electromagnets a wider range to vary. Right now the current to a coil will vary from about 2.5 amps to 2 amps, by increasing this range to 2.5 to .5 amps or so, I am hoping this will cause the margin of error to broaden. I think Beakers circuit should allow me to do this, but if any of you know how to modify RonH’s suggestion to allow for more variability that would be great. Once again, thanks for all of your help.

rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Inverting a linear signal

Post by rshayes » Wed Apr 13, 2005 9:58 pm

Your position sensor probably needs to cover a wider range in position. The luminous area of an LED is a fraction of an inch in diameter, as is the sensitive area on a phototransistor. If the suspended oblect moves out of the direct line of sight between these devices, you lose your position information, and the servo system can't work properly.<p>One possible light source would be a rectangular diffused LED. This should give you a light source about .15 inches long. The sensitivity will probably be less, but that can be compensated for by increasing the gain in the feedback loop.<p>Butting several LED's together would give you even more position range.

John Abel
Posts: 31
Joined: Sat Feb 26, 2005 1:01 am
Location: San Luis Obispo, CA
Contact:

Re: Inverting a linear signal

Post by John Abel » Wed Apr 13, 2005 10:19 pm

Sorry Stephen, I posted my last reply without refreshing the page and noticing your post. I found what you said to be very useful, I had not thought about the combined effects of distance and current, I always assumed the distance from magnet to electromagnet would be directly proportionate to the current going through the coil. This un-linear behavior will no doubt hinder my efforts to control the position of the magnet, but I’m hoping that the proper ratio of current between the two electromagnets will automatically be found as the sensor to electromagnet/object feedback narrows until equilibrium is found.

Your prediction as to the narrow (1/8th inch) range of the sensor seems to add up, as explained in my last post, there is very little margin of error. Perhaps this explains why the margin of error is so small, but the original project was not nearly as finicky as it is now, so I still believe if I am able to vary the current to the electromagnets more, the suspended object will be more easily put in place, before it finally achieves equilibrium.

As to your suggestion of broadening the range of the sensor, I’ll remove the opaque tubes I have put around the LED and phototransistor, which were there to help exclude outside light from the sensor. However ambient light does have a big effect on my circuit, which does not include the reference detector that is included in the design at:
http://www.oz.net/~coilgun/levitation/r ... tector.htm
So, I’ll have to operate the project in the dark, which kind of ruins the effect :) .

I think your idea of “Butting several LED's together would give you even more position range” is feasible, so if you could elaborate on this I would appreciate it. Anyways, thanks again.

rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Inverting a linear signal

Post by rshayes » Wed Apr 13, 2005 11:13 pm

An example of the type of the type of LED that I was thinking of is available from Digi-Key (www.digikey.com) as their part number 516-1277-ND. This has a rectangular diffused package that is .3 long. Two of these side by side would give you an illuminated area about .1 inch wide by .6 inches long.<p>Shielding the light path is still a good idea. The tubes might have to be a bit larger is all.<p>A much more complicated method of avoiding the ambient light problem is to modulate the LED source and AC couple the signal from the photodetector. This also requires that the AC signal be rectified and filtered to get a DC signal for your coil drivers. As I said, much more complicated.<p>Incidently, what are you suspending? A ball bearing is quite reflective and might have possibilities with a reflective sensor system. The reflection from a sphere would change from one side to the other as the sphere moved through the center. This might work well with your differential sensor system.<p>[ April 14, 2005: Message edited by: stephen ]</p>

Post Reply

Who is online

Users browsing this forum: dyarker and 42 guests