Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

new to Ardunio but trying to compile

Status
Not open for further replies.
Comment out the 4 print statements in the code I provided and add this one.

Serial.println(ADCValue);
 
Here is an example showing what you should see. Why do I waste my time???

The first plot shows the data with a blender or vacuum next to the microphone. The graph shows positive and negative peaks around the Vcc/2 baseline. The purple lines show the rough midpoint between the varying peaks that are positive and negative. Say the average of the negative peaks is around 100, and the average of the high level peaks is about a thousand. The average data spans between about 100 counts and a thousand counts, a range of 900 counts.

dB example max gain max noise.jpg


The next plot is the same measurement, taken next to a vacuum or blender, with the gain set to a minimum.
Unfortunately, the Arduino plot tool auto-scales, but we can see the positive peaks average about 650 counts, and the negative peaks average about 350 counts, a span of about 300 counts. This shows the gain control is working and which direction is which.

dB example min gain max noise.jpg


We want to set the gain as high as possible for the loudest expected noise source. If something like the first plot can be achieved, that's the ideal case. Positive peaks close to but not quite 1023, negative peaks close to but not quite reaching zero.


If you see a plot like this one, the gain is too high, and the signal is clipping and overloading the ADC. If this occurs, the result is garbage. The gain should be set as high as possible, without this occurring.

db example - overload.jpg
 
already have that in there and not blocked out.
here are the wave forms fist is cw(gain) at low and high volume
second is same but ccw hopefully in right order(pretty sure)
 

Attachments

  • Screenshot (29).png
    Screenshot (29).png
    245 KB · Views: 364
  • Screenshot (30).png
    Screenshot (30).png
    255.4 KB · Views: 359
  • Screenshot (31).png
    Screenshot (31).png
    219.3 KB · Views: 371
  • Screenshot (32).png
    Screenshot (32).png
    265.8 KB · Views: 379
Sigh. Your graphs are out of order.

What did you use as a noise source? Please describe fully. What? Located where compared to the microphone?

You can figure out the range of the between positive and negative peaks just as easily as I can. What is it? What's the difference between maximum gain and minimum? Ain't my circus nor my monkeys. Look at the measurements and figure out what they mean.
 
Get back to me when you do as I suggested.

Not another word from me until you do what I have explained, exactly as I have explained and you fully explain what you have done in enormous detail.

I thought I had made this perfectly clear already but this is it.
 
For those of you playing along at home, you may be wondering why I am insistent on using a blender or vacuum cleaner as a noise source. There are a couple reasons:

1. I have a good idea of the noise level of typical blenders and vacuums, and I know it's likely to be louder than would ever be desired from a TV. If the gain is set to handle this level of noise, it should be sufficient to handle the levels expected.

2. It's a repeatable source. Today, tomorrow, next week, similar levels will be provided if needed for further measurements to verify anything.

3. The frequencies generated by these devices are broadband and a reasonable representation of white noise.


None of these things are true for certain with MrDEB's white noise generator or whatever it is. What he does today will not be the same as what he does next time he uses it, and there's no way to verify if the signal levels are anywhere the same. MrDEB unfortunately tends not to understand what details are important, and gets creative without mentioning what he's really done.

So yes, my comments are harsh. I have been burnt too many times by MrDEB saying he did something one way, only to find out he did something totally other than what he said. Taking any thing for granted is sure to be regretted later.
 
"burnt"? don't think so but using Jons suggestion is good and I try every one of them if I can.
Am using a youtube pink noise to see variations in the volume adjustment.
I think I found a formula for this dB volume measurement but going to do some more testing and research.
the formula responds very well to different volume levels using 128 samples of audio the converting to dB using the regression method.
 
MrDEB, just for my own curiosity, how much time do you think I've spent trying to help you on this thread and over the years on all your other epic threads?

Hours? 10s of hours? 100s of hours? Thousands? Round numbers.
 
Sorry to but in, without wishing to state the obvious, why not make it a voice controlled option? You have a wife a wife, simply hand her the remote and yell:D.
Seriously though this is a fantastic thread with loads of info, good luck with the project

Simon
 
the formula responds very well to different volume levels using 128 samples of audio the converting to dB using the regression method.
At this point I'd be more concerned with getting valid ADC readings in a range you can deal with, which I'm not sure you've proved yet.

There's nothing magical about dB... it's just a formula, so if you put trash into the equation guess what you get back?
 
My plan to hopefully complete this project.


PROJECT – A micro-controller that has an ADC input to process the sound coming from the TV set. Convert the AC signal to a Decibel value. Two different approaches to achieving the desired ADC/ decibel conversion. One suggested method is the formula 20Log10(ADCvalue)/.1


This works but not as close to the actual value of decibels as using the regression method


ADC=(11.003 * db)-83.2073


dB=(ADC + 83.2073)/11.003


Am still testing both methods and adjusting the volume to get an idea which formula seems to work best.


After the ADC conversion the micro-controller will drive a 7 segment display (maybe two?) to display the sound volume from the TV set in numerical form (0 -10 or 0 -20).


the user adjusts the volume on the TV set to desired level, then using a rheostat adjust the display to a mid point (rheostat is connected from sound module to ADC input.)


The project then adjusts the TV set volume using infrared.
 
This works but not as close to the actual value of decibels as using the regression method
ADC=(11.003 * db)-83.2073
dB=(ADC + 83.2073)/11.003

I have no idea what those numbers mean.

You need to take a step back and understand what you're measuring.
You can't take the numbers from the ADC and shove them directly into a dB equation and have it mean anything.

Here's what I would do to start:
Instead of trying to use noise, get an audio signal generator app for your PC.
here's a list of some: https://listoffreeware.com/best-free-signal-generator-software-windows/

Set it to generate a 1KHz sine wave. Pick a reasonable volume and run the code WITHOUT any "dB" calculations or other fluff...
just the code that reads and plots the raw ADC values.

Increase the volume from the signal generator. Run another set of plots.

Take a look at the min and max ADC readings you get from both plots. If there isn't much difference, try adjusting the gain pot on the mic module and run the test again. If you put the mic module near the PC speaker the plot should get larger.

If you can't see a big difference in any of those plots, then you need to find out why.
 
Everyone suggesting the same thing and the OP completely ignoring. I'm still of my opinion.

Mike.
 
I was using a pink noise from youtube. downloaded sig generator prg and will give it a try thanks
 
Everyone suggesting the same thing and the OP completely ignoring. I'm still of my opinion.

Mike.
Maybe he do not understand it. After many failures, he will accept it. Its part of learning process.
 
well I used a 1khz signal and an actual code using the max 4466 module. here is a screen shot of the plotter. I have the gain at full tilt. Maybe looks promissing? even way down in Mexico? Enjoy the sun Jon.
Code:
[code]
/*
  modified on Sep 8, 2020
  Modified by MohammedDamirchi from Arduino Examples
  https://electropeak.com/learn/
*/


// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  }
[/CODE]
 

Attachments

  • Screenshot (34).png
    Screenshot (34).png
    279.2 KB · Views: 350
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top