Op amp issue I don't understand

Hi Guys,

Having some issues with my circuit and wondering if anyone out there has any good ideas.

For the record, I have very little electronics experience, all self taught, so forgive me for any blindingly obvious mistakes I've made.

I'm generating a phase and frequency correct PWM signal with Timer1 on an Arduino Nano, and outputting the signal on OC1A (PIN D9). I have no problem with this signal. It's exactly what I need.

This square wave then goes through a capacitor/resistor differentiator to produce a positive and negative signal. This works as hoped. I'm quite happy with this signal wave form. It has a very sharp rising/falling edge and the capacitor discharges OK (I think).

The problem arises when I try to amplify this signal through a non-inverting amplifier. I'm using an LM358 or this job. Also tried a TL072 with the same result.

Here's the hopefully understandable circuit.

At node 1 I measured a clean square wave. Frequency is 216Hz. Duty cycle 13%. The voltage flips between 0V and 5V as expected. No problems here.

At node 2 I measured the spikes from the differentiator. The rising edge is fast and the waveform looks good on the scope. Not exactly sure if I'm allowed to do this on an Arduino due to the negative spike, but I ran it for an hour and nothing went bang :wink:

I feed this signal into the non-inverting input of the LM358. The sketch shows no resistor on the input. I tried with and without but no difference in the result. The negative feedback should give a gain if I'm understanding things correctly.

At node 3.....This is where it's all going wrong. I was thinking that the rising edge at the output should be a fast rise like the input, but alas this is not the case. The rise is super slow, and the output only rises to about 1V before trailing off back to zero. It takes roughly 10us at the output to go from 0 to 1V and from 0 to -1V.

I must be doing something very wrong.

I also tried the same circuit but with the op amp as a buffer, but the same result.

I haven't tried the op amp as an inverting amplifier. I can try that but I'd rather try to find out why it's doing what it's doing as it is right now. I'm sure that there's a very simple answer, but I've been trying for hours and got no where.

The final output will be the signal for a motorcycle capacitive discharge ignition system (CDI).

I have a somewhat longer version of the circuit I made, in which the pin D9 output fires a 2N7000 mosfet, which in turn fires the differentiator, which in turn goes through a non-inverting amplifier. This does actually work and can run a CDI, but when I scope the final signal it has exactly the same issue with the slow rising edge. I want a fast edge.

Also acceptable is a positive and negative square wave, but I have no idea how to do that. Maybe through a couple of comparators somehow???

Sorry for the long post, but if anyone has any useful tips then I'll be more than grateful.

Happy to give more info if needed (and if I can).

Cheers,'

Matt

That sounds most unlikely! :roll_eyes:

You need to explain properly what your requirement is.

The LM358 is about the slowest opamp available that's not micropower (its inadequate for audio signals even). For sharp edges you need a decently fast opamp, possibly a video bandwidth opamp.

1 Like

Here you see a stack of CDI circuits for mainly smaller motor cycle engines: Index of /andere/cdi

@Paul_B

Oh yee of little faith!

Please see this thread:

This was my journey to get the Arduino side of things working as planned, and maybe that explains it a little more "properly" for you.

And as for being "most" (in bold lettering no less) "unlikely", if you scroll right to the bottom of the thread then you'll see a link to my FB page in which the circuit is actually running a CDI.

To be specific, the circuit is to simulate the signals that come from the variable reluctance sensors on the engine, which are triggered by the lobes on the flywheel. This can then run the engine electronics without actually running the engine. I have a mechanical system I built 20 years ago to do the same thing but times change and I wanted to do it electronically.

I scoped the signal from the VR sensor and then tried to replicate it.

@MarkT
Thanks for your response. I didn't realise the LM358 was that slow.

There's also the confusing bit where I have a gain of 2, but it's actually a way lower voltage then the input. Is it that it's just really that slow that it never gets up to the voltage I want? 1V (or maybe 1.5V) in 10us seems a little off somehow.

Do you have an op amp you can recommend, or perhaps another idea completely?

@6v6gt
Many thanks for the link. Very nice. I just clicked through a dozen or so of the links, and seems they're all AC CDIs. I'm in process of making a DC CDI. I have the actual trigger bit (using an SCR) sorted and have been using a 12V to 300V DC to DC convertor with the output cap removed. It's using a UC3843 PWM chip and I'm controlling it with a Nano. Shutting down the PWM by grounding pin 1 of the UC3843 and then triggering the SCR. Not very reliable at the moment, but it does work....sort of.

Cheers,

Matt

A couple of points:

Use an active differentiator instead of a passive one.

Or try buffering the passive one with another op-amp wired for unity gain before passing it to the gain stage.

Of course you will need fairly fast op-amps...and TL07x I believe should be fast enough with a slew rate of 13V/uS. But VFB opamps have problems with slew rate limiting because of the internal compensation capacitor. If nothing works you may need a CFB op-amp like THS6012 - typically used for high speed, high gain and bandwidth applications such as video. But expect them to be relatively expensive.

1 Like

@rohitbd
Thanks for the tips.
I tried buffering the passive differentiator already but no success. I'll try an active differentiator. Haven't used one yet so will give it a go.
Cheers

Matt

See op amp AD8052. It is not expensive and it is fast - 145 V / μs slew rate.
https://www.analog.com/media/en/technical-documentation/data-sheets/AD8051_8052_8054.pdf

I thought as much. :grin:

Not sure why you are so keen on a fast rising edge as I doubt the variable reluctance sensor produces a sharp edge.

It occurred to me that the op-amps were too slow but when you mentioned 216Hz that should hardly be a challenge. :astonished:

@flashko Thanks for that info. Correct me if I'm wrong, but the AD8051/2 etc. Is a single 5V supply. I need a minimum +6V / - 6V output for stable triggering of the CDI. So maybe not the tool for the job.

@Paul_B you're correct in assuming that the VR sensor doesn't give a fast rise. The signal I'm making is actually much cleaner than the handful of VR sensors I've scoped, and as I said, the circuit works already but being an electronic noob I am trying to learn what does what and why it does it.

Another question if I may....

How does one go from the spikes from the differentiator to a square wave?

I guess a comparator could give me a positive pulse from the positive spike, but I'm a bit lost on getting the negative pulse. A cunning arrangement of comparators perhaps?

I don't actually need the square wave for this project but interested in how to do it, as it will also work to trigger the CDI.

Cheers

Matt

According to the data sheet, operation is from 3-12V, which means you could use a +/- 6V power supply.

@jremington Yes, I spotted that while perusing the datasheet a second time and consequently ordered a couple. Be interesting to have a play.

Cheers

Use an integrator or better a monostable (555 based) triggered by the spikes.

@rohitbd
Makes sense. Thanks.

I have never used an op amp as either an integrator or a differentiator, so that'll be fun :slight_smile:

Cheers,

Matt

But a square wave is from what you started, isn't it?

Do you perhaps mean alternating positive and negative short pulses?

You can easily generate a short pulse on each transition which is always the same duration independent of the speed. If you want each pulse to be a quarter of the period of the waveform and proportional to the speed, that becomes a little tricky.

Except that - you are using a microcontroller to generate the waveform after all. It can generate made-to-measure pulses on two channels, one for the positive pulses and one for the negative. All you need then is a (simple) switch arrangement for each output direction. :+1:

Exactly. A differentiator followed by an integrator, is more or less nothing, a "wire". Because they are the inverse of each other.

1 Like

Maybe raise the digital signal first to the amplitude required (with logic ports instead of opamps),
and then differentiate.
Leo..

Thanks to all. All the info is really helpful.

Yes, I started with a square wave from the Nano (0V - +5V).

What I need at the final output is a +6 to +12V / -6V to -12V signal.

I have this now in a spikey waveform, and it fires the CDI so I suppose I could just stop here, but I'm intrigued to learn more.

Interested to know how to make the final output a +ve and -ve square wave based on either the square wave from the Arduino, or the spikes from the differentiator.....or some other way.

On the Arduino I'm using both D9 and D10 outputs of the Timer 1, as the CDI I am running is a two channel (so two VR sensors). These signals are shifter 90 degrees. The signal from the Arduino is perfect. Just not sure of the exact path to get to the end of the journey, so to speak!

Maybe I'll get some time tonight to hook it back up to the scope and post some pics of the waveforms I'm getting.

Cheers,

Matt.

Spikes to square wave - integrator should work, but the output will be more of pulses - this works best if the spikey waveform is more of a triangular shape. Better still look at a 555 monostable triggered by the spikes, it will give much better pulses or square wave depending on its timing R and C. Updated in my earlier post as well.

A MAX232 comes to mind.
Leo..

Or MAX3232.