Shop OBEX P1 Docs P2 Docs Learn Events
OP Amp as signal conditioner HELP - Page 2 — Parallax Forums

OP Amp as signal conditioner HELP

2»

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-07-04 20:31
    DRMorrison wrote: »
    @Phil,

    You're correct, I should use a series resistor; considering the voltage is 3.7V, and will in the final circuit. I am not using the Opto; it loaded the VSS too much and gave me the fault code and set the MIL.
    I'll check the amp draw into the Propeller from the Op Amp just to be safe.

    Any suggestions on using perhaps a better Op Amp? Or does using it in this way not much matter which Op amp I use?

    Does anyone know how to mark this thread as SOLVED?

    Thanks a million, Daniel

    As mentioned in my earlier posts if you are going to use an opamp, use it as a comparator. If you use a cheap common LM358 tied to +5V then you can safely tie the output directly to the Prop as the output cannot swing to the +5V rail anyway, it's around 3.5V which is well within Vdd+0.3V and never a problem. But if you are going to get a chip then get the LM393 dual comparator in an 8-pin DIP and just use a pullup on the output. The LM393 and LM358 are totally footprint and circuit compatible for this application anyway. Beware though that since you have no hysteresis that you may have oscillations around the transistions.
  • DRMorrisonDRMorrison Posts: 81
    edited 2014-07-04 21:01
    As mentioned in my earlier posts if you are going to use an opamp, use it as a comparator.

    Am I not using it as a comparator? Isn't my voltage divider on the non-inverting input the Vref typically used in a comparator configuration? Or am I missing something?

    The LM358 states it can be used from 3 to 32 volts. I will try running this at 3.3V supply to see if the output is high enough to give me the logic high that I need
    on the input to the Prop. The logic low is not a problem now; this thing swings all the way near the neg. rail--close enough, anyway. The project will actually have
    3 voltages on its PCB; 3.3, 4 & 5 volts. So perhaps the 3.3 or 4 will suffice.

    Daniel

    P.S. I noticed that the post above that is titled SUCCESS! showed a VSS on the non-inverting input of the op amp, but this is the VSS from the vehicle, not the
    standard use of the acronym in electronics.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-07-04 22:25
    DRMorrison wrote: »
    Am I not using it as a comparator? Isn't my voltage divider on the non-inverting input the Vref typically used in a comparator configuration? Or am I missing something?

    The LM358 states it can be used from 3 to 32 volts. I will try running this at 3.3V supply to see if the output is high enough to give me the logic high that I need
    on the input to the Prop. The logic low is not a problem now; this thing swings all the way near the neg. rail--close enough, anyway. The project will actually have
    3 voltages on its PCB; 3.3, 4 & 5 volts. So perhaps the 3.3 or 4 will suffice.

    Daniel

    P.S. I noticed that the post above that is titled SUCCESS! showed a VSS on the non-inverting input of the op amp, but this is the VSS from the vehicle, not the
    standard use of the acronym in electronics.

    My point about using it as a comparator wasn't taken at the time which is why I said "use it as a comparator" because the solutions being proffered were becoming much more complex without actually providing a solution.

    You can't really use the LM358 at 3.3V too well as it may say "from 3V to 32V" but you have to understand about opamps and applications etc which is why I pushed the sure and simple darlington approach. At 3.3V the performance of the 358 wlll be poor, the 358 has a very slow slew rate and at higher pulse frequencies it may fail to provide a clean output which is already limited by it's output swing which is 1.5V less than the supply. Just use the 393 or the darlington if you are really seeking good advice.
  • kwinnkwinn Posts: 8,697
    edited 2014-07-04 22:32
    An NPN transistor (ie 2N3904) with a 2.7K resistor an in emitter follower circuit to drive the opto isolator led should provide a nice clean signal.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-07-05 10:13
    Yes, a lowly 2N3904 could very well do it all driving and opto-isolator.

    I think we are hung up on trying to get an extremely high impedance so the ECU doesn't complain about a ground fault. Thus, the Darlington. Both the LED and the Darlington seem to have a 1.4V operating threshold.

    I guess the Darlington would be an emitter follower with about a 510ohm load resistor to create about a 10ma load. The junction of the emitter could connect to a Propeller input that would possibly swing between 3.6v and ground.

    ++++++++++++
    OPamps are a lot of fun to work with, but they really don't fit into a digital world... special power requirements (work better with voltages in the 18 volt range) and are intended to faithful replicate the whole signal, not just swing from High to Low in a clean fashion.

    I actually have a nice little board here that has a complete OPamp built just with transistors. It produces a nice clean audio pre-amp, but hardly worth the trouble when really good OPamps are nearly as cheap as the transistors and require less capacitors.

    Here is Texas Instrument's tome on OPamps for more than you ever might care to know.

    http://www.ti.com/lit/an/sboa092a/sboa092a.pdf
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-07-05 12:38
    OPamps are a lot of fun to work with, but they really don't fit into a digital world... special power requirements (work better with voltages in the 18 volt range)
    That may have been true, many, many years ago, but it certainly isn't the case now. There is a plethora of low-voltage, single-supply op amps available now for cheap with high-impedance CMOS rail-to-rail inputs, rail-to-rail outputs, and gain-bandwidth-products well into the tens of megahertz and higher. Many of these, for example, would make excellent preamp or frequency-filtered front ends to a Prop-based sigma-delta ADC, The same amps could also be used for filtering and buffering the Prop's duty-mode DAC output -- all without supply requirements beyond +5V or +3.3V.

    -Phil
  • SpillySpilly Posts: 26
    edited 2014-07-05 13:57
    I believe I had a similar problem with an engine position sensor. When I tied the propeller in parallel with the engine control unit, I kept having sync issues at various rpm's. Skimming over these posts, it looks like I tried similar workarounds. I ended up using four npn transistors to keep the engine control unit input isolated from the propeller. This worked perfectly. Doing this does add an additional delay due to the transistors' switching time.

    Here's a diagram of the circuit from memory.

    g32h0VL.jpg
  • DRMorrisonDRMorrison Posts: 81
    edited 2014-07-05 17:40
    Phil,
    You are absolutely correct about the current op amps. I'm using the LM358N in single supply mode as a comparator here, and the results fit what I need in this situation. High input impedance, clean square wave output and
    with a single supply voltage of 5V. The project will have 5V available anyway, so this is not a problem.


    I put together several prototypes on a breadboard for testing, and this one here fits very well all of my needs. Here is the schematic.

    Screen Shot 2014-07-05 at 5.15.21 PM.png


    And here is the input and output waveforms shown on my scope. The top is the input signal I have been calling VSS (Vehicle Speed Signal). The bottom is the output from the op amp that goes into the Propeller.
    The 3.3k resistor should suffice for the Prop. input. This screenshot is at 400Hz, the target frequency of the circuit. The circuit consumes 0.857 mA DC @ 6k Hz, which is the highest frequency the circuit will
    encounter, and equates to 133 MPH.

    Screen Shot 2014-07-05 at 5.18.57 PM.png
    NOTE: the bottom trace looks a little odd, but that is due to the cursors measuring the top and bottom of the trace; values are given on the right.

    I've tested this in vehicle, and it works flawlessly; meaning it doesn't set the MIL, and counts pulses more than sufficient for the application. And if my memory serves me correctly, the Prop. is running at 5 MHz.
    I set the counter in the Prop. to NEG EDGE detect, and count for 1 second, which gives me Hz directly. If I divide this by 45, I get MPH. And 400 Hz is my target speed for this part of the project.

    Thanks to everyone for their input. Daniel
  • edited 2014-07-05 21:52
    Parallax Application Note AN010 - Low Cost Bidirectional Mixed-Voltage Interfacing recommends a 4.7k resistor when interfacing 5V signals to the prop. Got to the parallax home page and enter AN010 in the search box.

    The Application Notes are a good general resource. There are 17 different ones; AN001 thru AN015, AN018 and AN019. There is sample spin code supplied for the ones that require code. Don't know what happened to 16 and 17.

    Sandy
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-07-05 22:57
    Parallax Application Note AN010 - Low Cost Bidirectional Mixed-Voltage Interfacing recommends a 4.7k resistor when interfacing 5V signals to the prop. Got to the parallax home page and enter AN010 in the search box.

    The Application Notes are a good general resource. There are 17 different ones; AN001 thru AN015, AN018 and AN019. There is sample spin code supplied for the ones that require code. Don't know what happened to 16 and 17.

    Sandy

    Here is the result from LTSpice using 1M input and a "darlington" - nothing special at all, just dumb transistors.
    Screenshot from 2014-07-06 15:58:57.jpg
  • DRMorrisonDRMorrison Posts: 81
    edited 2014-07-06 00:14
    Sandy,

    I have seen that note before, and thanks for reminding me of it.

    Doing the math for my circuit gives me a Ro value of 1.5K Ohm. My 3.3k should suffice.
    3.76 - 3.0 / 500e-6 = 1.52k
    Even in the worse case they mention in the note of 2.7V, the resistor would be 2.12k Ohm

    I actually measured the current flowing into the Prop. from the output of the Op amp at 0.020 mA, or 20uA.

    These are some small numbers, so accuracy in the value is only as good as the measuring device. I used a
    Fluke 45 that was just calibrated. I also have on the way one of Dave Jones' uCurrent Gold devices that
    can measure small numbers very well, as he claims. Can't wait to see what it reports.

    Thanks, Daniel
  • DRMorrisonDRMorrison Posts: 81
    edited 2014-07-06 00:25
    Peter,

    There is still that pesky .7V drop across the diode, and then there are 2 more drops across the two transistors in the Darlington pair. Some current must flow thru them. In most cases the setup should not be a problem, but in this
    case I'm sure it would upset my ECU, given that it didn't even like the single drop across an LED in the Opto.

    WIth the nearly infinite input impedance of the Op amp, the ECU sees no load whatever, and is happy. The circuit shown in a few posts back has been built and tested in the vehicle for more than twenty minutes
    with no hick ups, or codes pending.

    I needed to get the VSS from the ECU to talk, so to speak, to the Prop. without either one getting upset. Thanks to everyone for helping with the translation.

    Daniel
  • Heater.Heater. Posts: 21,230
    edited 2014-07-06 00:46
    DRMorrison,
    There is still that pesky .7V drop across the diode, and then there are 2 more drops across the two transistors in the Darlington pair. Some current must flow thru them.
    True. But it is the input impedance that matters not those internal voltage drops, as long as the input rises high enough to overcome them. The current flowing into the input in that circuit is limited by a one mega ohm resistor. Surely the ECU can drive 3 or 4 micro amps into that impedance?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-07-06 01:01
    Well, I seem to have been wrong about an emitter follower arrangement. Don't use it.

    Peter J uses an Open Collector arrangement with a pullup resistor to 3.3v.

    The input side deals with the 1.4v offset, and the output side swings crisply from 0 to 3.3v.

    As long as the ECU output voltage exceeds all the diode drops involved, the large amplificatin of the Darlingtion with take the remainer and swing between full on and full off.

    There are diodes available with less than 0.7v drop, maybe 0.3v if that is a concern.
    http://en.wikipedia.org/wiki/Schottky_diode

    AND D1 might not be absolutely necessary. After all the transistor is really a diode construction and behaves as such with reverse voltages.

    @Peter J
    Thanks for your clarification.

    There is a tendency for newcomers to 'junk up' a very simple design with a lot of extra protection and complexities that are unwarranted. (I have done my share of this.)

    And, there are always more ways to build than just one. Usually alternative builds are driven by what happens to be on-hand or on EBay at the moment.
  • Heater.Heater. Posts: 21,230
    edited 2014-07-06 03:16
    Did we ever discus the nature of this MCU output? I have not followed everything here in detail.

    Is it just an open collector output? With perhaps a very weak pull up? That is the only way I can rationalize that it has such trouble driving an opto-isolator or transistor.

    In which case an external pull up might be in order to get the opto, transistor or darlington circuits to work nicely.

    Looking at the LM358 internal circuit we see that it in an "upside down" differential amplifier input. It uses PNP transistors. As such it is pulling up on the input though a 6uA current source. Which might account for why this LM358 circuit works well.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-07-06 05:24
    DRMorrison wrote: »
    Peter,

    There is still that pesky .7V drop across the diode, and then there are 2 more drops across the two transistors in the Darlington pair. Some current must flow thru them. In most cases the setup should not be a problem, but in this
    case I'm sure it would upset my ECU, given that it didn't even like the single drop across an LED in the Opto.

    WIth the nearly infinite input impedance of the Op amp, the ECU sees no load whatever, and is happy. The circuit shown in a few posts back has been built and tested in the vehicle for more than twenty minutes
    with no hick ups, or codes pending.

    I needed to get the VSS from the ECU to talk, so to speak, to the Prop. without either one getting upset. Thanks to everyone for helping with the translation.

    Daniel

    I'm not sure on what basis you have such misgivings, it is as if you don't quite understand the the nature of the signal from the tacho in that it probably never goes to ground because that is one way that a short to ground can be detected as a fault but also that the circuit will have some drive, it is never expecting no load at all, that is unrealistic and impractical. Because you put a very heavy opto load on it and it complained you therefore surmise that it can't have a load?

    The voltage drops of the transistor inputs are necessary to ensure that the circuit does not switch on with 1.4V but once it does then the current is limited by 1M which wouldn't even affect a 100K source impedance to any appreciable degree, but your tacho circuit is probably more like a few K source impedance. The circuit doesn't actually need the extra diode in there, it was only put in initially because the sim indicated that the transistors were conducting too heavily at 1.4V which didn't seem right but after I specified real transistor models using 2N2222 then it behaved as I expected it to. The current that will flow at 5.2 volts therefore will be (Vsigmax - 2Vbe) / 1M = a mere 4ua.

    Anyway, use the opamp as a comparator if you must but the point was that you didn't need anything complicated or specialized.
  • DRMorrisonDRMorrison Posts: 81
    edited 2014-07-06 12:44
    I feel that we may be starting to beat a dead horse here.
    I have a circuit that works, and works well. And using parts that I currently have is a plus.
    The specs for the Op amp are ideal for my application.

    Did we ever discus the nature of this MCU output? I have not followed everything here in detail.

    Yes, in the first entry to this post. It can also be seen as the top trace in the photos that I uploaded.

    Daniel
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-07-06 13:08
    Daniel,

    Despite your success with the LM358 circuit, there is one thing I would still add to it: a 220K resistor between the op-amp's output and the positive input. This little bit of positive feedback will give you about a 5% hysteresis band that will come in handy under noisy conditions. Otherwise, you risk multiple transistions when the VSS input changes state.

    -Phil
  • DRMorrisonDRMorrison Posts: 81
    edited 2014-07-06 21:01
    Daniel,

    Despite your success with the LM358 circuit, there is one thing I would still add to it: a 220K resistor between the op-amp's output and the positive input. This little bit of positive feedback will give you about a 5% hysteresis band that will come in handy under noisy conditions. Otherwise, you risk multiple transistions when the VSS input changes state.

    -Phil

    Actually, I don't want any hysteresis; I want the transitions quick and sharp & no delay. The VSS signal from the auto is very stable, and the
    Propeller has not problem counting those pulses in the range at which I need to count them; 400Hz to 6kHz. This equate to speeds of 10 - 133 MPH.
    Even though the Op amp has a slew rate that shows up on the O'scope, it has no effect. The Prop. is quite capable of counting them, and I'm counting pulses for
    one second intervals so that I get Hz directly. And in all of the testing of the circuit, I only see the count change by 1/6,000 rarely.
    My test in the car with my Propeller Demo board and an LCD matched directly with the auto's speedometer. It has a digital readout speedo.

    If you look at the scope traces that I posted on page 2, you will see that the Op amp circuit accomplishes my goals of a high input impedance, not affecting the ECU, and
    removing the 1.4V offset of the input signal. The output is a little higher than the ideal 3.3V, but the resistor that I use takes care of that in regards to the Propeller input guidelines.
    I actually measured it, and that information is on this page somewhere. I was able to get the output to go down to the 3.3V by using a lower supply voltage to the Op amp, but
    this project has enough supply voltages as it is.

    Daniel
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-07-06 21:50
    DRMorrison wrote: »
    I feel that we may be starting to beat a dead horse here.
    I have a circuit that works, and works well. And using parts that I currently have is a plus.
    The specs for the Op amp are ideal for my application.

    Daniel

    I agree. At least I do understand that you wanted to use what you had on hand. And I presumed that you don't have any Darlington transistors.

    There are multiple ways to do this. And when you have both a calibrated multimeter and oscilloscope on hand as the builder, you can make things work precisely that otherwise would be quite challenging.

    It also seems that the ECU provides a very crisp square wave, so all the concern about transistions is not really an issue.

    For me, it is interesting to have more than one solution.
  • DRMorrisonDRMorrison Posts: 81
    edited 2014-07-06 22:26

    For me, it is interesting to have more than one solution.

    I agree, and if I were willing to spend more time sussing this out, or enough inclination to tinker with the other alternatives, I would. But, I have a solution that works
    wonderfully. It does, as I said, accomplish all three goals.

    Perhaps later, when I have more time, I will put together the Darlington setup and test it at the bench. I don't actually have the Darlington IC, but I could build one from
    2 transistors.

    I must move on in this project to the next hurdle. All of the other signals have been identified and conditioned to interface with the circuit, and the program has been written.
    I now must put all of the individual components together and test, test and then test some more. This project has been ongoing for way too long as it is. I can see by my first
    code entry, that I started it in 2010! I have not been working on it steadily, but in fits and starts. This time it will be completed, or it all goes into the trash bin.

    Daniel
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-07-06 23:48
    DRMorrison wrote:
    I want the transitions quick and sharp & no delay.
    Two of those (quick and sharp) are very good reasons to include hysteresis. And the delay will not be noticeable. Although the VSS signal may be clean, what if there's noise on the power rail? That will affect the divider voltage, and a power-line noise pulse during a transition could cause the op-amp's output to generate a double pulse. Hysteresis will alleviate that. At the very least you need a cap (0.1uF) from the op-amp's negative input to ground, but htere's no guarantee that that will be sufficient away from the test bench.

    -Phil
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-07-07 10:03
    For this level of power, the Darlingtons come in plastic TO-92 packages and look exactly like regular transistors... only the numbering will tell you it is a Darlington. I happen to have a few left over from fooling around with building audio pre-amps with BJT technology.

    If you really have difficulty with getting some, I could mail you a few. Send me a private message with your mailing address to do so. It would take about 10 days to arrive from Taiwan.

    I don't think I have the BC517 that I previously provided link to a PDF for, but that can provide a gain of up to 30,000x.

    http://www.fairchildsemi.com/ds/BC/BC517.pdf

    Another odd-ball that might be handy at times is the 'super-beta' transistors as they have huge gain and not the double diode drop.

    Both remain handy because of the TO-92 packaging. There are a lot of great MOSfets that are also handy, but they mostly seem to be surface mount devices for the better technology.

    ++++++++
    If and when you have trouble, the alternatives have been presented. Automotive environments tend to be some of the worst for noise... heavy load swings, a lot of inductive devices been switched on and off. So what works on a bench, may not be so stable in real use. The suggestions are just being offered to eliminate a lot of very real noise problems.

    The Propeller has been used in several successful automotive projects. But there are solutions that do make it easier to use and more reliable.

    ++++++++
    Some of the most rewarding projects are extremely long term. I have been doing a comparative study of Chinese and English grammar for about 20 years now and it finally seems to be coming together in a nice way. I actually have one small class of motivate students that can see how it makes understanding and using English grammar less burdensome.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-07-07 11:39
    Peter Jakacki,

    Was your circuit tested to work? You can improve upon the 0.7V drop of the darlington configuration by taking the collector of Q1 directly to +3.3V instead of the the collector of Q2. With that change the voltage on the output swings from 3.3V to about 50mV.

    This configuration seems like a dead short between Q1 and Q2 when Q1 is on, but because of the 1Meg resistors, the current through Q1 is only about 350uA, while Q2 can sink about 3.5mA to the Output.
  • D.PD.P Posts: 790
    edited 2014-07-07 13:53
    Here is the result from LTSpice using 1M input and a "darlington" - nothing special at all, just dumb transistors.
    Screenshot from 2014-07-06 15:58:57.jpg

    Got the same results with MultiSim FYI, I like to read these discussions on 'dead horses', I learn how to avoid them.

    Thanks everyone,

    dp
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-07-07 15:45
    Peter Jakacki,

    Was your circuit tested to work? You can improve upon the 0.7V drop of the darlington configuration by taking the collector of Q1 directly to +3.3V instead of the the collector of Q2. With that change the voltage on the output swings from 3.3V to about 50mV.

    This configuration seems like a dead short between Q1 and Q2 when Q1 is on, but because of the 1Meg resistors, the current through Q1 is only about 350uA, while Q2 can sink about 3.5mA to the Output.

    Yes, I looked at that too with the same idea but I was just demonstrating one solution that I offered right in the very beginning, that of a simple darlington. I figured that the Vce-sat of the darlington was never going to be a problem with the Prop's input threshold anyway. Seeing that the OP was absolutely intent upon using an opamp I refrained from any further suggestions :)

    Screenshot from 2014-07-08 08:41:55.jpg
Sign In or Register to comment.