new to Ardunio but trying to compile

Status
Not open for further replies.
I should add a diode to the output of the module?
was wondering about that. Just need to locate a diode since I sold most all my junk box stuff ($160)
 

I don't see how that will do what you want? - it's not an amplifier, it's a comparator - and the output switches high and low as the signal crosses the point set by the pot on the board. So it's not an analogue signal, it's just either high or low - no point using an analogue input to try and read it.
 
The last time he said he was getting numbers from the log function, he was getting numbers in the range of 0.039 to 0.045 or something similar – in other word garbage. If there isn't valid data to start with, averaging will just confuse the issue.

Please understand that getting MrDEB to string THREE commands together without copying them from somewhere is a MAJOR ACCOMPLISHMENT.
 
Here is a microphone module that will do what's needed. It provides an analog output proportional to the microphone input. But do note – its output is biased to Vcc/2. This has several impacts:

¤ At the quietest levels, the ADC will read 512 counts.

¤ The output level will be between 512 and 1023 for positive going peaks in the sound and 512 and 0 for negative going peaks. (0 = max negative level, 1023 = max positive level)

¤ Linear levels need to be computed considering the offset of the ADC and the absolute value from there. Compute the linear average first, then convert to dB.

¤ Since the output is biased to Vcc/2, the maximum range is reduced to 20 × log(512) = 54 dB instead of 60 dB.

 
Would rectifying and an RC filter get the required result? Say a 1S timescale.

Mike.
 
Would rectifying and an RC filter get the required result? Say a 1S timescale.

Mike.

Not with what he has now. The output is digital, the output of a comparator. It's not an analog signal.

If you mean with the module I recommended, maybe, but you'd be losing a lot of range wit the diode voltage drop.
 
Well I thought I had the right module. I purchased several of the module w/ LM393 as well as several with the LM386 BUT I didn't realize the modules were different until yesterday.

I know I have at least 2 of the LM386 modules but locating them. I recently moved my work bench and can't find a few things such as the desired modules.. Ordered several of the LM386 and will order a few of the modules Jon posted.
 
well I received the modules with an amp on board (see post 145)
using the code in post 136 but it prints 500+ db
I adjusted the gain and not a lot of change.
getting frustrated have the computer freeze due to a java issue?
looking to see if a new Java download needed?
 
As I suggested, you should print out the ADC count as well as the dB level. Why you might wonder? Because the ADC count can only range from 0 to 1023. If it's outside of that range, you've done something wrong.

The dB level will range from 0 for an ADC count of 0 to a bit more than 60 for an ADC count of 1023. (I suggested you punch some numbers on a calculator to see how this works, but you had a raft of excuses about why you couldn't do this). If the ADC numbers span the right range, but the dB numbers don't, you know where the error is.

ALSO, you need to see the raw ADC values to set the gain. You want the value to be close to 1023 at the maximum level.

But since you haven't done this simple things, anything I can suggest is a wild-assed guess, so I have nothing to say until you provide some concrete data.
 

Actually, even more reason to print out the ADC values. With the proper mic board now, the ADC count should be around 512 for a quiet condition, because the amp output is biased to Vcc/2.

ADC = abs(ADC – 512)

will correct for the offset and make positive peaks and negative peaks into positive numbers.

The biggest ADC value you will see is 512 at max volume, which corresponds to 54 dB.
 
You really want to compute the RMS voltage and shove that into the dB equation.

Think of a sine wave. With a single ADC reading you have no idea where on the curve you are.
If you're unlucky and always happen to sample around "0V" then you'll think there's no signal.
 
Good point. But I think we're already pushing the envelope pretty hard with the ideas of

¤ signal is biased to Vcc/2 when it's quiet.
¤ signal has positive and negative peaks, around the midpoint of the ADC.
¤ the abs() function.
¤ computing dB.

Then there was the entire problem of expecting to get an analog output from a comparator output.

So the first baby step is seeing ADC and dB values over the expected range. 500dB is impossible.
 
the output reading the adc = about 512 at quiet
was worried because I couldn't get any where near 0
 
I know almost nothing about C programming but I suspect you have not understood adding an offset of a voltage coresponding to 512 counts to your AC waveform which is centered on zero volts is a way to deal with the fact that the ADC can only read positive voltages. You have even been given the line of code to convert the ADC output to a value of 0 to 512 for both the positive AND NEGATIVE parts of your waveform. Read back though and UNDERSTAND the information that has been provided.

Les.
 
There was talk of adding a diode to the only-positive voltage output, so take that for what it's worth.

Instead of subtracting a fixed value of 512 for the 2.5V offset I would think it would be better to just use the ADC to measure it with no sound and use that value as the "0V" offset, but that's getting ahead of things.
 
Les and Tumbleweed, are you saying my suggestion to subtract the offset and take the absolute value of the result isn't a good way to handle this? It's the best way I could think of to do it, but I'm all ears. Once there are legitimate numbers coming out, RMS summing or maybe even just capturing the peak values during rapid sampling would be enough.

I am concerned that some creativity in a few lines of code will turn valid data into something else, with zero recognition that output has no relation to input if you get my drift.
 
Visitor, I think it is a good way to solve the problem with minimal hardware. My point is the TS does not seem to read replies and UNDERSTAND them.
I would do it differently by using an active rectifier followed by a low pass filter but I would not suggest it in this case as it would be too difficult for the TS to understand.

Les.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…