LM358 circuit help needed ...

Thread Starter

daba1955

Joined Apr 27, 2019
218
Sounds easy....

From your linked page, do you think this will suffice, it gives a -3dB cut-off at 159Hz, and unity gain in the bandpass.

EDIT : Gain calculates as 2, so I've added a pot divider on the output. I can then feed this signal onto the DMX controller board at the point where I remove the MIC. Picture updated ...

2019-04-28 14.47.29_daba1955.jpg
 
Last edited:

LesJones

Joined Jan 8, 2017
4,511
If it is an electret microphone you need to supply power to it via a load resistor. Also you will need a negative power supply as well as apositive one as the DC level of the - input is ground. You also need a DC path to ground for the positive + input. You will then need a DC blocking capacitor between the junction of the electret microphone and it's load resistor. You could avoid the negative supply if you biased the inputs of the op amp to about half the supply voltage.

Les.
 

Thread Starter

daba1955

Joined Apr 27, 2019
218
Hi Les, sorry not got back for a while, my Internet router decided to die yesterday morning, only just got the replacement...

I'd planned on using the MIC off the main board on the LPF, and that just connects to pin 3 of the LM358 via a 10K resistor. I didn't originally see the trace, but, yes it has a 10k to pin 8, and there's an RC network going back onto the chip somewhere.

I think I need to trace out the whole circuit - it's possible it already has the components that will make it a LPF and peak detection circuit. I may get the time to do that tomorrow, and when it's done I'll post it for your perusal.
 

Thread Starter

daba1955

Joined Apr 27, 2019
218
And here is said circuit. Does it seem OK for the application ?
If there is a low-pass filter, I have no way of determining the capacitor values, so Don't know cut-off frequency.

2019-05-01 16.02.40_OpAmp_daba1955-s.jpg

Mod Note:
Please rotate the circuit to the right direction and compress the image to as 800x600 *.jpg, this circuit already rotated to the right direction and compressed it to 799x402 *.jpg from 1280x960.
 

LesJones

Joined Jan 8, 2017
4,511
The first stage has a theoretical voltage gain of about 920 times. It would also give very severe distortion as you would loose the negative part of the output waveform because you have the input biased to ground with no negative supply to the op amp. I don't understand the reason for putting in all the extra gain when you are trying to reduce the sensitivity. The second stage would also not function as it did in the original circuit as the DC conditions are different.

Les.
 

Thread Starter

daba1955

Joined Apr 27, 2019
218
Thanks for staying with this Les.
The circuit I posted originally was incorrect. The latest one is correct to the best of my knowledge, as I painstakingly replicated the PCB layout in my PCB software. Thankfully nearly all the PCB tracks were topside, so it was relatively easy to trace them.
The final stage feeds pin 31 on the Megawin MA805-64AD44 mcu, and it is a digital pin, so that stage should "hit the rails" I'll scope it later to see what the pulse width and polarity is..

Anyway, in a nutshell, I don't think the circuit is very clever, and doesn't perform well IMHO. Can we do better? All I want is to pick up the beat from the music, cut-off about 120Hz, with variable sensitivity. I'm prepared to remove the components off the board, and build an external board to feed the mcu trigger pin. There is only a single supply, +5V, I can work with, no dual rails.
 

Attachments

AnalogKid

Joined Aug 1, 2013
12,128
The basic functions for an audio trigger go like this:

Mic amplifier
Lowpass filter
Envelope detector (Half- or full-wave rectifier, plus filter)
Comparator with adjustable threshold (and adjustable hysteresis?)

The envelope detector is key. Even with things rolled off at 120 Hz, you don't want the individual cycles of a bass guitar note showing up at the uC as a burst of 30 trigger signals in 1/2 second. The rectifier circuit can be more or less complex. Least is what you already have, with the lack of a negative power supply turning the mic preamp into a faux-rectifier. Not a terrible idea, but not the best performance. What is an outstanding feature of the 358 in many applications - that the input stage common mode range extends *below* its negative power pin - works against you in terms of how "precise" the rectification is.

There are many ways to do each of the stages, but my first thought is that it will take a 2nd LM358.

ak
 

LesJones

Joined Jan 8, 2017
4,511
I thought the schematic in post #26 was your proposed modification. I think the second stage is behaving as a monostable multivibrator but I can't fined any examples of that configuration. I still suggest trying the variable resistor in series with a capacitor in parallel with the michrophone that I suggested in an earlier post.

Les.
 

Thread Starter

daba1955

Joined Apr 27, 2019
218
The basic functions for an audio trigger go like this:

Mic amplifier
Lowpass filter
Envelope detector (Half- or full-wave rectifier, plus filter)
Comparator with adjustable threshold (and adjustable hysteresis?)

The envelope detector is key. Even with things rolled off at 120 Hz, you don't want the individual cycles of a bass guitar note showing up at the uC as a burst of 30 trigger signals in 1/2 second. The rectifier circuit can be more or less complex. Least is what you already have, with the lack of a negative power supply turning the mic preamp into a faux-rectifier. Not a terrible idea, but not the best performance. What is an outstanding feature of the 358 in many applications - that the input stage common mode range extends *below* its negative power pin - works against you in terms of how "precise" the rectification is.

There are many ways to do each of the stages, but my first thought is that it will take a 2nd LM358.

ak
That sounds like a lot of circuit to design, ak.......

I have two LM358's to hand, but lack the knowledge to design analog circuitry. Spent my life working with digital, and now hobbyist Arduino and Teensy meddler.

I'm in favour of ditching the existing circuit which I traced out and posted in #26, stripboarding a more refined version, and taking a digital signal out back to the mcu on the main board...

Even with things rolled off at 120 Hz, you don't want the individual cycles of a bass guitar note showing up at the uC as a burst of 30 trigger signals in 1/2 second.
And that is what I think is wrong with the existing circuit, a burst of noise causes extremely rapid bursts of the chases on the light controller, too fast to actually "see" the effect. I suspect the trigger input pin is assigned to an interrupt that steps the chases on, and there's no "delay" built-in to stop it being triggered rapidly. If I had written the code I would have found a way to suspend further interrupts for a time period, I'd probably make it about half a second, so that rapid step changes can't occur. But there's no way I can get at the code for this mcu, not without spending way too much money and time. So any repeat triggering delay must be put into the design, which I could likely do with an Arduino Nano or the like - sort of like a "pre-processor"

EDIT : I've just found a code sample for the Arduino which detects the beat from music !! Probably won't need all those functions, just a variable gain mic pre-amp ....
 
Last edited:

AnalogKid

Joined Aug 1, 2013
12,128
That sounds like a lot of circuit to design, ak.......
Yeah, I though the list might spark a concern. But breaking things down to their fundamental steps is the only way to make sure you've got everything covered. Plus, its not really as bad as it looks; some functions can be combined into one stage.
EDIT : I've just found a code sample for the Arduino which detects the beat from music !! Probably won't need all those functions, just a variable gain mic pre-amp ....
The code probably is doing some form of peak detection or averaging, what would be dome with a diode and a capacitor. Lowpass filtering is difficult to do in software, but you might be able to get away with a single-pole filter after the preamp.

ak
 

Thread Starter

daba1955

Joined Apr 27, 2019
218
I posted a link to the code, you may want to check it out to see how it functions. It has a Bass Filter, an Envelope Filter, and a Beat Filter.

Also I already have an audio pre-amp, it's one of these devices

I will be having a go with this today, see if I can get beat detection working.

One of the great beauties working with Arduino's and the like is the ability to infinitely "tweak" the software to get it working as you want it, and I'll be using a wifi module and RemoteXY on my iPhone or iPad so that I can change program variables "on-the-fly". This will be a great bonus for live performances ....
 

Thread Starter

daba1955

Joined Apr 27, 2019
218
Note the rather poor low frequency response of the mic module. Other than that, sounds like a good plan.
Noted. Although to be fair, I'm not after fidelity, and if the MIC module has to have a higher gain to compensate I don't think I'm really bothered, providing the filtering algorithm in the software works well.

And indeed it does show some semblance of working, but some playing about with the adjustable factors is probably in order. What I have noticed is that a single "beat" produces two pulses from the software, not really a problem as I can put a divide by 2 flip-flop before feeding it to the DMX controller.

Sadly the MIC module and the WiFi module don't like being in the same universe, I think the WiFi beacon signal is being picked up and triggering the beat detection software. Since I only want it to set parameters in the software it doen't need to be a fast interface, so am going to try my Bluetooth modules instead..
 

AnalogKid

Joined Aug 1, 2013
12,128
Entirely possible that the mic amplifier circuit is acting as a radio detector. This is an ooooold problem from the 40's-60's, where a phono or mic preamp would pick up strong AM radio signals. A 1 nF cap from between C1 and R4 to GND should squelch it, if that is what is happening.

ak
 

Thread Starter

daba1955

Joined Apr 27, 2019
218
A 1 nF cap from between C1 and R4 to GND should squelch it, if that is what is happening.
The MIC amp module I am using is this one, not the one I posted earlier...
I've traced the circuit out, and it nearly agrees with the circuit shown here, except R1, R2, and R5 are different values. That's going to make it awkward, because the C values I've put on my drawing are from the circuit above ( I have no way of measuring them), but the resistor values are correct....
2019-05-05_072427.jpg

NOTE TO MOD : Is that better ?
 

AnalogKid

Joined Aug 1, 2013
12,128
R3 and R4 make for a very high input impedance that can pick up all kinds of EMI. Plus, the high value makes for a very small filter capacitor value. C2 and R2 should lower that impedance at high frequencies (to a minimum of 1K), but in the nearby presence of a strong transmitter that might not be enough.

For a 10 kHz corner frequency, add a 33 pF cap in parallel with R4 to GND.

ak
 

AnalogKid

Joined Aug 1, 2013
12,128
Comments on the circuit. Changing R1 and R2 to 1K decreases the DC impedance seen by the mic cartridge output to 500 ohms. That is pretty low for an electret cartridge, but without knowing which one Adafruit is using, I cannot comment further.

Changing R5 from 10K to 1K raises the low frequency response corner to 160 Hz. In your application this is not a good change. To counter, either replace R5 with a 10K or add a 10 uF cap in parallel with C3. C3 probably is ceramic, but an aluminum electrolytic is ok.

Note that the overall frequency response of the circuit changes as you adjust the gain. The Maxim circuit has a high frequency rolloff corner of 16 kHz. The Adafruit circuit varies from 72 kHz at low gain down to 13 kHz at high gain.

ak
 
Last edited:

Thread Starter

daba1955

Joined Apr 27, 2019
218
I cannot make changes to the MAX4466 board. I don't have SMT components, nor the tools or skill to work with them.

So, taking a step back, I have 8-pin DIP LM358s, stripboard, resistors of all values, can get capacitors as I need. So all I want is a pre-amp with a reasonable gain at the low freq band (say up to about 160Hz), I don't care much about fidelity, rectification etc., the signal will just go into the Arduino and be filtered, enveloped, and peak detected from there. It would even be a bonus if the op-amp didn't perform well above 160Hz.

Taking that MAX4466 as a starting point (the circuit, that is, not the component values that are on it), could you suggest suitable values for all the components and I'll make a stab at building it.

On another note, my meanderings around the internet found a circuit that uses a graphic equaliser chip MSGEQ7 to split the audio into seven bands. Throw away all but the topmost and use envelope profiling on the lowest. Can't find it again at the mo, but I'll hunt it down again - looks promising.
 

Thread Starter

daba1955

Joined Apr 27, 2019
218
I said ....
I will be having a go with this today, see if I can get beat detection working.

One of the great beauties working with Arduino's and the like is the ability to infinitely "tweak" the software to get it working as you want it, and I'll be using a wifi module and RemoteXY on my iPhone or iPad so that I can change program variables "on-the-fly". This will be a great bonus for live performances ....
Well I have breadboarded the Arduino beat detection circuit, and I have to say it works infinitely better than I had expected. So much so that I'm going to roll with it and build it into my DMX lighting controller.

It appears to be massively insensitive to volume changes, working well at medium volumes and not exhibiting any false detection at very high volumes. I did tweak some of the parameters, and introduced an anti-repeat hold-off time of 0.25 seconds, which should allow the beat detection up to about 200 bpm, well in excess of what I had hoped for.

I have also added a BPM display on the iPad HMI, and tested this with an online Drum Metronome which it agrees with +/-1 BPM ! A normal metronome doesn't get detected, the frequencies are too high.

There is also a selection on the iPad of selecting which beats are sent to the DMX chip : OFF (no triggers), 1:1 (on beat), 1:2 (alternate beats), 1:3 (every third beat), etc., up to 1:8.

All in all, I'm pretty darned chuffed with it, and can't wait to see it in action triggering my light chases.

EDIT : I have uploaded a poor video of the setup working to Dropbox if anyone is interested. The sound quality may not be good, but that is a good bassy drum sound coming from my pc speakers.
 
Last edited:
Top