Go Down

Topic: Arduino Peak Detector and Uni-Directional Microphone (Read 572 times) previous topic - next topic

VosemGov

I have got this circuit with the help of stack exchange that uses a peak detector to let me sample extremely fast without the Arduino needing to sample quickly at all (that is at least what I understood. Sorry I have been using the arduino for a while but havn't done large projects like this without much of a guide before)

This is the schematic I was given. I put this onto a breadboard with an arduino and a

https://www.ebay.co.uk/itm/Negative-Voltage-conversion-Dual-Power-5V-12V-to-12V-100ma-For-Amplifier/223330100802?_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D20160908105057%26meid%3D31f7eadb0a2f47b7b9b02746a3790849%26pid%3D100675%26rk%3D1%26rkt%3D15%26sd%3D223330100802%26itm%3D223330100802&_trksid=p2481888.c100675.m4236&_trkparms=pageci%3A226ce78b-68e6-11e9-bdd7-74dbd180cdd4%7Cparentrq%3A5eb8b35f16a0a68d5fa15266fffba178%7Ciid%3A1.

Here is a picture of the breadboard. (also with 100nf capacitors on the + and - of the opamp)

I read the output with analog read and am Just getting 0. Any help would be appreciated,
Many Thanks,
Thomas

PieterP

It looks like you are shorting out the power supply. Never connect Vout+ and Vout- together!

Also, you aren't powering the op-amp. What op-amp are you using?

Pieter

VosemGov

#2
Apr 27, 2019, 04:30 pm Last Edit: Apr 27, 2019, 05:19 pm by VosemGov
I am using a Lm358, and I didn't think that was right but the person on stack exchange seemed very knowledgeable and helpful so I used his schematic. My project is to have many unidirectional microphones in a semi circle (9) to detect the direction of the loudest noise. Any ideas are appreciated, thanks.

EDIT:
His schematic is correct I am just reading it wrong

PieterP

The schematic tells you to connect Vout- to the V-, gnd, Vss, or Vee of the op-amp, and Vout+ to V+, Vdd, or Vcc of the op-amp and the resistor to the microphone. The schematic seems correct, as far as I can tell.


VosemGov

Okay I understand, I am just reading it wrong. I will connected out- directly too pin 4 and out+ directly too pin 8. I am still reading 0. Do you think I have created the circuit on the breadboard wrong? Thanks

PieterP

It's hard to tell what's going on on your breadboard.
Could you upload a new picture that clearly shows all connections?
What's the purpose of the capacitors on the inputs? Are you reading the correct pin in your code?

Maybe you blew up te regulator. Try measuring its output voltage with a DMM, or use an LED+ series resistor to see if it still provides power.

VosemGov

Yeah sorry I thought it would be too hard to follow the breadboard anyway so I didn't upload a great picture. Here is a better one:

And the stack exchange guy said I should put 'decoupling capacitors (100nf)' on the power pins. I only just realised they are not the power pins. Shall I remove them entirly or just move them to v- and v+
Many Thanks,
Thomas


(as a side note thank you very much for reading through the breadboard from a picture, I would never be able to do that)

PieterP

You forgot to connect the ground, and you didn't connect the mic to Vout+ through R4. The wire to your Arduino is connected to ground instead of the output of the circuit (through the 1kΩ resistor).

PieterP

I don't think the connection between Vout+ and R4 is correct. I can't really tell if the other connections around the microphone are correct.

VosemGov

#9
Apr 27, 2019, 07:21 pm Last Edit: Apr 27, 2019, 07:25 pm by VosemGov
I redid the circuit and now am getting a load of random values. Here is the new circuit:


Here is a video of it:
https://imgur.com/a/OXrW64X

VosemGov

#10
Apr 27, 2019, 07:54 pm Last Edit: Apr 27, 2019, 07:58 pm by VosemGov
Okay okay we have progress. When I put a delay I can see the peak detector working I think! It rises to 1023 then slowly drops!!!

EDIT:
Okay it doesn't work. It rises to 1023 every few seconds and drops regardless of noise. I actually removed the microphone and it did the same.

MarkT

Can you post the schematic for what you have now?  Schematic, not wiring diagram if at all possible.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

VosemGov

#12
Apr 28, 2019, 11:29 am Last Edit: Apr 28, 2019, 11:52 am by VosemGov
Yes, it is the original schematic unless I have made a mistake:

Does the polarity of the electret microphone matter?

EDIT:
I read through the schematic one more time and re-positioned  some components, and now I am pretty sure that the schematic is what I have on the breadboard. The analog read now starts at 0 slowly rises to around 1023 then drops again. If these results point to the schematic being wrong, Ill use a bigger breadboard and remake the whole thing. Thanks
Like This:
Code: [Select]

1023
1023
1023
1023
1023
1023
1023
1004
949
855
752
645
537
437
334
232
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
21
78
164
285
414
541
663
790
913
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
972
910
805
691
581
475
373
270
144
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
38
98
198
344
476
625
763
945
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023


DVDdoug

The turn-on "glitch" is probably normal.

And the amplifier only has a gain of 10 so you might get small readings unless the sound is very loud.

If you appear to be reading "something" with loud sounds, try increasing R3 to 100K.

You can also switch to the optional 1.1V ADC reference to compensate for low signal levels.

Are all of the grounds tied together?

Are the + & - terminals on the electret mic clearly marked and correctly connected?   (The audio signal is AC, so polarity doesn't matter but the power to an electret mic does matter.)

Do you have a multimeter?  If not, it's probably time to get one...

Make sure you have the positive & negative power supplies to the op-amp.

...You can buy a sound sensor board with an envelope follower (peak detector) output.


Quote
My project is to have many unidirectional microphones in a semi circle (9) to detect the direction of the loudest noise. Any ideas are appreciated, thanks.
You'll need a significant (percentage-wise) distance-difference to get a significant difference in loudness.    And indoors, it may not work at all because reflections tend to even-out loudness throughout the room.



With no signal the output of the op-amp (before the diode) should be resting at about 0.6V (because of the diode in the feedback loop).    The other side of the diode (and the Arduino's analog input) should be reading about zero.    We know it's not positive because the Arduino is reading zero, but it might be negative.

MarkT

The circuit is simply wrong, I a tempted to say go find a proper one, but basically the inverting and non-inverting inputs are swapped over, so the opamp is a comparator with a vast amount of hysteresis.  There is far too little
gain possible with those resistors too.

Where did you get this bad circuit from?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up