Notifications
Clear all

Teensy’s and OpAmps

19 Posts
4 Users
2 Reactions
802 Views
(@jonweisw)
Member
Joined: 12 months ago
Posts: 20
Topic starter  

Hello all!

I am attempting to control an aircraft simulator gauge using a Teensy microcontroller board interfaced to simulation software. The controller has the ability to supply PWM 3.3v signals at 10mA max. The gauge I am trying to control uses a signal that starts at -10vDC and ends at +10vDC. I need a component that will control this voltage range linearly based on the signal from the Teensy board (for example, 0v in leads to -10vDC out, 1.65v in will lead to 0vDC out, and 3.3vDC in will lead to +10vDC out). The unit I am powering requires no more than  50mA. 

From my reading, I believe I need an op amp (?). How do I even begin to find the correct component? Variables such as bandwidth and voltage feedback are beyond my scope of knowledge in this context. If anyone knows offhand what kind of op amp I would need (or what kind of component) and how to wire it up and would be willing to share this info with me, I would be most deeply appreciative!!

Thank You!!

Jon Weiswasser

jon.weiswasser@hotmail.com


   
Quote
(@bbutcher85)
Member
Joined: 2 years ago
Posts: 27
 

Hello Jon,

An op amp would work well for this application. The attached schematic shows one way to do the job. Since you want to amplify the input voltage so that a 3.3 volt input swing produces a 20 volt output swing, the total gain must be 20/3.3 = 6.06. This could be done several ways, but one simple way is to use a dual op amp such as the LM358, or the surface mount equivalent. Since your output voltage needs to swing from -10 volts to + 10 volts, I suggest using a power supply that produces +/- 15 volts to power the op amp. This gives you a little voltage to spare, which is good since some op amps do not work very well if driven to the rail (i.e. to the power supply voltage, either plus or minus). I suggest using two inverting op amps (the LM358 has two such amps). The first stage has a gain of - 2.49 (- indicates inverting) and the second has a gain of -2.43. The total gain is the product of the individual gains, namely + 6.06. The gain of an op amp is the ratio of feedback resistor to the input resistor for an inverting op amp. Thus the 24.9K and 10K resistors (R5 & R4). Likewise for the second stage a 24.3K and a 10K produces the desired gain. These are all standard resistor values for 1% tolerance thin film resistors. 

Since you want the output to be zero at 1.65 volts input, the non-inverting (+) input of the first stage is set at near this value. Sometimes there is a slight offset in the amplifier so I included a potentiometer to allow a small adjustment range for this input. The 10K potentiometer (R2) is located in a voltage divider circuit (R1, R2, R3) to allow about 1 volt of adjustment (from about +1 volt to +2 volts), and a small capacitor (C1, 0.1 uF ceramic) is used to hold this voltage constant. Connect your input and set it to 1.65 volts, then tweak the potentiometer to get the output close to zero. You will probably want some small capacitors (not shown on the schematic) on the two power supply voltages for stability (perhaps 1 uF ceramic).

All the components can be ordered from Digikey or Mouser Electronics if desired.

Unless you need real fast voltage changes you should not need to be concerned about bandwidth or frequency response. The LM358 has a gain bandwidth of about 700 kHz and your gain is about 2.5, so it should be good up to about 700/2.5 = 280 kHz.

The risetime of a square wave signal at this bandwidth should be

Tr = 0.35/BW

or a risetime in the 1/2

microsecond range. If you need faster response, search for a higher gain-bandwidth op amp. 


   
ReplyQuote
(@jonweisw)
Member
Joined: 12 months ago
Posts: 20
Topic starter  

This is EXACTLY the advice I was searching for. THANK YOU!


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1924
 

Hi Jon (@jonweisw) and @bbutcher85,

bbutcher has done such a detailed explanation, I feel rather mean to point out one query, so I hope you will both forgive my intrusion.

My concern relates to: The unit I am powering requires no more than 50mA. 

This could be interpreted in several ways, but my concern is only relevant if it means the load that the amplifier must drive would take a current of (near to) 50mA, presumably when the voltage is 10V (and/or -10V).

In other words, the opamp must be able to source currents of up to +/- 50mA, whilst still acting as an accurate operational amplifier.

The following snip is from the data sheet for the LM358,  https://www.ti.com/lit/ds/symlink/lm358.pdf,

image

 This suggesting the design limits for maximum output currents are 10-20mA, and short-circuit limits of 40-60mA.

Hence, if the load require 20mA-50mA on at least some occasions, then it is likely to actually get a smaller voltage than it needs to operate correctly.

Note, the short circuit protection of the opamp, should prevent the chip being damaged, but the 'gauge' is likely to show a 'smaller' reading than expected.

However, since the requirement said " no more than 50mA", I am conscious that the 'real' requirement might be somewhat less than 50mA. So my first recommendation is to check this value. I don't know what the 'gauge' is, but many are electro-mechanical devices with no 'electronics' inside, so the load might be the resistance of a coil of wire, or similar. In that case, measuring the resistance, and applying Ohm's law

I ( Current in Amps )  = V (Maximum Voltage in Volts) / R (Resistance in Ohms)

Where Maximum Voltage is apparently 10V, should be a useful guide.

-------------------------

If it appears the current requirement will exceed the LM358 capability, then the opamp type needs to be 'upgraded' to one that is designed to output higher currents.

-------------------

I apologise for not being very familiar with what devices are conveniently and cheaply available. Suppliers like Mouser can provide many high quality alternatives, but their delivery costs can be high on small orders. Maybe others can provide suggestions.

----------------

If 'all else fails', I note from a quick look on AliExpress that an OPA1622, on a tiny PCB, is available from many suppliers for a few pounds, delivered to the UK. This device was apparently aimed at driving headphones, rather than the more 'typical' opamp applications, but a first glance at the data sheet suggested it might be suitable. Please note that I may be totally mistaken with this suggestion. It is easy to overlook something, and I do not have one of these devices to try out. Plus, many devices from suppliers like AliExpress are clones, which may not behave in exactly the same way as the original design. All risks are yours - it is only a suggestion, if your budget is tight.

----------

Note, if the 'gauge' has significant financial value, or would be difficult to replace if damaged, then I would choose a resistor that would draw a similar current, and prototype my hardware and software using the resistor as the load, and measuring the voltage across the resistor with a meter. This way you can check the voltage from the opamp is the expected one, for each Teensy output value.

e.g. based on the values provided in the first post:

50mA current when voltage is 10V, the R = V / I  = 10 / 0.05 = 200 Ohms

Power in resistor = 10 (V ) * 0.05 (A) = 500 milliWatts

So need at least 0.5W resistor, or perhaps 2 X 100 Ohm, 0.25W(or more) in series.

-----------------------

NB If you decide to try the OPA1622,  you will need to connect the enable pins appropriately. If this sounds confusing, please ask.

-----------------------

Hope this helpful. Good luck with your project. Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@davee @bbutcher85 OMG, now we have TWO of them!!!!!

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
huckOhio reacted
ReplyQuote
(@bbutcher85)
Member
Joined: 2 years ago
Posts: 27
 

Dave makes a good point that I missed. If you need more current for the load, you can add a simple emitter follower to the circuit (Q1, R10). This transistor must be capable of handling the current and power to drive the load without overheating. The 2N3055 is a TO-220 package (through hole) and should have no problem delivering 50 mA even without a heat sink. The new schematic is attached. I also corrected a minor error, the +/- 15 is only connected to one set of pins on the LM358, the other amp is internally connected to power. I adjusted the offset voltage a bit since the emitter follower will have about 0.6 volts less on the emitter than the output of the op amp. As a result you will need to adjust the offset on the op amp by that amount. Just tweak the potentiometer until the output is zero at 1.65 volts input.

 


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1924
 

Hi @bbutcher85,

   Sorry, I hate to query your efforts again, but I presumed that the opamp was expected to source up to -50mA, when the output voltage was -10V.

I think your 2nd circuit will struggle to achieve this, because you have a 10k resistor in series with the 2N3055 emitter lead, not a second 'pull down' transistor.

-------------

Assuming the 'gauge' is connected between "OUT" and ground (0V), this means the absolute maximum negative current that can be sourced is (-15V / 10kOhm ) = 1.5milliAmps, and the corresponding voltage will be (near) 0V, not -10V.

If I use my previous illustrative guess, that the gauge resistance might be 200 Ohms:

Then the maximum negative current will be a little less than -1.5mA, with a corresponding small negative voltage at OUTPUT ...approximately  (200 Ohm * -1.5mA) = -300mV.

-------------------

Curiously, for a moment, I previously wondered about adding an output stage, before writing my first reply, but I immediately discarded the thought, for this very reason, considering two transistors, etc. was probably more complicated and hence liable to problems, than picking another opamp with a higher output drive.

-------------------

Of course, we don't actually accurately know the 'comprehensive' load characteristics, beyond the limited description

"The gauge I am trying to control uses a signal that starts at -10vDC and ends at +10vDC. ... The unit I am powering requires no more than 50mA.",

which might have alternate interpretations to mine, with obvious repercussions on the validity of my analysis. 🙄 

Best wishes, Dave


   
ReplyQuote
(@bbutcher85)
Member
Joined: 2 years ago
Posts: 27
 

@davee 

You are correct, perhaps a second transistor or a smaller resisitor would be required. U forgot it needed to go to negative 10 volts. 270 ohms for R10 would be better, or a push-pull output stage.


   
DaveE reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1924
 

Hi @bbutcher85,

   Sorry yet again, but I don't think 270 Ohm resistor would work ... instead:

   To deliver -10V at 50mA, from a -15V rail, via a resistor, then the maximum 'allowable' voltage drop would be 5V at 50mA. Using Ohm's Law

R = V/I = 5 (V) / 0.05 (A) = 100 Ohm.

But then dissipation in resistor when OUT is +10V out, will put 25V across the resistor,  = V^2/R = 25*25/100 = 6.25W

I still think an uprated opamp is the easiest solution!

Best wishes, Dave


   
ReplyQuote
(@bbutcher85)
Member
Joined: 2 years ago
Posts: 27
 

You are probably correct, the best solution is to incorporate a class B push-pull output. The attached schematic shows one option for this. Three op amps are now required, so this could be an LM324 quad op amp, or two LM385 dual op amps, or perhaps three single op amps such as Texas Instruments OPA991IDBVR. Single op amps make circuit board layout somewhat easier. There are many op amps available in both through hole and surface mount. One consideration is if small size is a requirement, and another is if battery power is required. Power consumption may be a factor especially if battery powered, although the 50 mA gauge seems to indicate power is not a big factor.

The attached circuit has the same features as the original, but adds a class B push-pull output capable of delivering high currents in both polarities. Class B push-pull amplifiers do have a problem with distortion of the signal since near zero output neither the NPN or the PNP transistor are biased on over about a +/- 0.7 volt range. The third op amp stage provides feedback to minimize the distortion of the signal. 

Class A push-pull amplifiers are another option, but they tend to consume a lot of power and create a lot of heat.

There is a lot of information available on the internet regarding op amps and push-pull amplifiers for anyone interested in the subject.

Dual Inverting op amp with offset and push pull output

 


   
ReplyQuote
(@jonweisw)
Member
Joined: 12 months ago
Posts: 20
Topic starter  

David and bbutcher -

THANK YOU so very much for your input on this. I have learned a tremendous amount just from your discussion about this. I'm sorry I cant provide more technical information about the amperage requirements of or the impedance of the load that this is going to. Once I get this up and running I'm sure that I will have that information more readily. I have ordered all fo the components from Mouser outlined in the first schematic and am going to order the components in the second schematic. I was able to locate the 2N3055 bipolar transistor, but was unable to find the 2N2955 transistor...am I missing something? Also, what would you recommend for R8?

Jon

This post was modified 7 months ago by Jonweisw

   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@jonweisw Just a note on forum use. When you want to talk to somebody, use the reply link at the bottom of the post you are replying to. AND if more than one person, add the other user like Dave with @davee. You can get the 'handle' by looking at an earlier post or from their member info. This way the person will be notified and will not miss the post.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1924
 

Hi @jonweisw,

  re: I was able to locate the 2N3055 bipolar transistor, but was unable to find the 2N2955 transistor...am I missing something? Also, what would you recommend for R8?

As the circuit you were referring to was designed by @bbutcher85, I was respectfully waiting for them to reply with definitive answers, which will probably happen soon.

In the meantime, I'll venture my suggestions. Please note, I have not tried or analysed the circuit suggested, so these answers are just based on my first thoughts, based on the devices in general usage.

--------------

The 2N2035 and 2N2955 transistors are NPN and PNP complementary 'equivalents' of each other that originated over 50 years ago. The 2N2035 (NPN) appeared in many more circuits than the 2N2955 (PNP), and hence is probably easier to find. The 2N2035 in particular, became 'famous', as the 'go-to' device for fairly high power circuits, but was originally linked to the relatively inconvenient metal package.

Hence, some semiconductor manufacturers produced "clones" of a similar device in a plastic package, with '***2035' style type numbers, where '***' was replaced by two or three letters, often loosely based on the manufacturer's name.

Of course, these "clones" have an entirely different physical appearance, and may have had different electrical characteristics, but in most circuits, would probably perform in a similar manner to the original 2N3055. (It would be the responsibility of the circuit designer to ensure equivalence in a production scenario, by carefully checking the data sheets, and then testing pre-production samples, as there could be 'unexpected' issues.)

For example, the metal can device was credited with 115W power dissipation capability, whilst I have seen 90W quoted for one of the plastic devices. In practice, it needs a very substantial heatsink (at least without fans or other add-ons) to dissipate 90W, and most circuits, including yours, will operate well below this level.

I haven't done a proper search or comparison of devices, but TIP (TIP2035) and MJ (MJ2035) seem popular choices.

And you will not be surprised to find, TIP2955 and MJ2955, the PNP version, are also listed, which may be easier for you to source.

However, confusingly, some of the TIP and MJ devices are also listed in the metal can packaging, so check before you buy!

------------------

With op-amps in the inverting gain configuration of U1B, it is common to choose the two input resistors to be the same value. Hence, my first guess is R8 would be the same value as R6. R6 is 10kOhm.

-----------------

As I started, @bbutcher85 may respond with more authoritative answers. I am only trying to fill a gap, and may have missed something.

Hope this helps. Best wishes, Dave


   
ReplyQuote
(@jonweisw)
Member
Joined: 12 months ago
Posts: 20
Topic starter  

@bbutcher85 and @davee,

 

First, allow me to say how thankful I am for your willingness to help me out and your generosity of knowledge. For someone new to this as I am, it mean more than you know!

 

While waiting for the correct transistors to arrive (Dave - I got the MJ2955 coming from Mouser tomorrow), I constructed the circuit that @bbutcher85 proposed on 8/1 (scroll back) which I will continue to refine using both of your suggestions (esp with the push/pull transistors). I was indeed able to get a 0-3.3vDC signal to modulate a -10 to +10vDC signal.

 

I hooked it up into the gauge that I am trying to power (N1 tachometer which is the primary indication of how fast the big fan of a jet engine is turning) and got it to work but with some serious jitteriness. Here is a video I took to give you some idea of what's going on..

 

I installed 0.1uF capacitors between the V+ and V- (rails) and ground (+/-) without any luck. Also the gauge itself uses +15V, -15V and +/- as a reference voltage (+/- referring to the connection between the two power supplies). Could this be a problem related to the amperage issue you referred to above?

THANK YOU!

Jon


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1924
 

Hi @jonweisw Jon, (and @bbutcher85),

Good to see you are making progress. 

I am not clear of the source of the jitter, so I recommend a systematic approach to discovering the cause.

I think my first attempt to discovering the cause would be to provide a temporary variable DC source of 0 to 3.3V to feed to Vin, instead of the Teensy, to see if it still jittered. My reasoning being the Teensy output will be a PWM signal, not DC, and MIGHT be the origin.

Remember, the op-amp circuit above will have an input impedance of 10k ... that is, if you arrange a variable voltage using (say) resistors and a potentiometer, then when the circuit is operating, then the output of the potentiometer will apparently be connecting via a 10k resistor, to ground, which will result in a lower voltage output from the pot, compared to when the pot output is unconnected.

If there is no jitter with the DC source, then an RC filter between the Teensy output and Vin (or possibly between U1B and U1c) might help. To assist with designing this, it would be helpful to know the waveform timing from the Teensy, indicating the likely range of waveforms from minimum to maximum, whilst avoiding the theoretical extremes of always on(high) and always off(low), that are obviously DC.

However, if it jitters with a DC source, then other problems need to be considered.

Best wishes, Dave


   
ReplyQuote
Page 1 / 2