I want to plot a graph on Matlab with the inputs of Arduino's analog pins
How can I do that, I am a newbie on Arduino
Thanks for your help.
I want to plot a graph on Matlab with the inputs of Arduino's analog pins
How can I do that, I am a newbie on Arduino
Thanks for your help.
Is using google beyond your level of experience? If so - the Arduino is probably not for you just yet...
cr0sh:
Is using google beyond your level of experience? If so - the Arduino is probably not for you just yet...
Actually no, it is not beyond my level of experience. I have looked at google many times and tried to find an answer in this forum a lot but I couldn't find any. This is just a very simple question that need to be answered very simply so that maybe it would help me to find my mistake.
If you can handle more, try to understand what I have wrote now and if you have any answer for me please don't hesitate to share.
I am using Arduino and Matlab combined. I have created a microphone and connect it to Arduino's analog input. Then I have plotted it. As you might know, Arduino works with 0-5V, so my voice signal only showed in the range of 0-900.
I don't why 900 but I am guessing it is because of my microphone's resistances. But the range of 0-900 is not enough for a speech signal because it has to be in the range of -something to +something so that it can be a perfect sound signal.
So this is my problem and if this is something that you can find on google, please be my guess and try to find it.
Otherwise if you know the answer, I will appreciate if you help me.
I need to change my ref into +- 2.5V instead of 0-5V, I think this will solve my problem but I don't know how to do it.
Thanks,
I am using Arduino and Matlab combined. I have created a microphone and connect it to Arduino's analog input. Then I have plotted it. As you might know, Arduino works with 0-5V, so my voice signal only showed in the range of 0-900.
I don't why 900 but I am guessing it is because of my microphone's resistances. But the range of 0-900 is not enough for a speech signal because it has to be in the range of -something to +something so that it can be a perfect sound signal.
I need to change my ref into +- 2.5V instead of 0-5V, I think this will solve my problem but I don't know how to do it.
Thanks,
But the range of 0-900 is not enough for a speech signal because it has to be in the range of -something to +something
So, subtract 450.
You can't have a negative voltage reference.
I need to change my ref into +- 2.5V instead of 0-5V, I think this will solve my problem but I don't know how to do it.
The Arduino cannot read negative voltages. In fact, it can be damaged by negative voltages depending on how much current you amplifier/preamp can put-out. And, if the Arduino isn't damaged the audio signal will be damaged (distorted).
The normal solution is to [u]bias[/u] the input at +2.5V. The two equal-value resistors form a voltage divider that divides the 5V power supply voltage in half. The 10uF capacitor isolates the DC from the audio circuit. (You can skip the 47nF cap.)
With the input biased at half the reference, zero (silence) will read about 512 depending on the precision of the resistors. You can subtract-out the bias digitally in your Arduino sketch or in Matlab.
my voice signal only showed in the range of 0-900.
Then when you did:-
I have created a microphone and connect it to Arduino's analog input.
You did it wrong. You should have a range of 0 - 1023.
I don't why 900 but I am guessing it is because of my microphone's resistances.
You guessed wrong, but as you haven't said what you did we can only guess what you did wrong.
But the range of 0-900 is not enough for a speech signal
Yes it is.
because it has to be in the range of -something to +something
No it doesn't.
so that it can be a perfect sound signal.
No such thing. So what do you want to do?
Hi,
Welcome to the forum.
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Thanks.. Tom.. ![]()
Hi,
YosiNif:
I am using Arduino and Matlab combined. I have created a microphone and connect it to Arduino's analog input. Then I have plotted it. As you might know, Arduino works with 0-5V, so my voice signal only showed in the range of 0-900.
"Created" a microphone has me worried, have you used an amplifier with it to get your level to 5V?
A copy of your code and circuit diagram is really needed.
Thanks .. Tom... ![]()
Thanks for the answers, this is my code in arduino and you can see my code and the output in matlab in the attachments also my microphone's circuit can be found in the attachments. You will see that my microphone works with +9V but I am not using 9V I am using 5V instead.
int sensePin = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
int val = analogRead(sensePin);
Serial.println(analogRead(sensePin));
delay(300);
}

You will see that my microphone works with +9V but I am not using 9V I am using 5V instead.
and what about the -9V on the LM324? What is that connected to?
If you have a -5V supply then this is fine.
If you have just connected it to ground then it is not fine, and you need to create a virtual ground using two 1K resistors between the rails with a capacitor across each.
Screen shots of code are totally useless, do not do it again.
I am using power supply in order to give +-5V and ground I am only connecting my microphone's output to the arduino's analog input, thats all I have. What I need to do is, collect my microphone's data through arduino in to the Matlab and plot/play it.
I am using power supply in order to give +-5V and ground I am only connecting my microphone's output to the arduino's analog input,
This is confusing, your are contradicting yourself.
You say you connect the microphone to the Arduino input but your schematic shows a LM324 connected to a speaker. If the first part is correct why post a schematic of what you haven't got?
It is clear from your graph you posted that your input is not biased correctly, if it were silence would show up as a reading close to 512.
So how about posting a schematic that shows your microphone, the Arduino and everything you have in between.
Grumpy_Mike:
This is confusing, your are contradicting yourself.
You say you connect the microphone to the Arduino input but your schematic shows a LM324 connected to a speaker. If the first part is correct why post a schematic of what you haven't got?
I didn't connect it to a speaker, I connect that part to my Arduino's analog input 0
Then you have not biased it correctly have you.
Hi,
What do you expect to see on the graph?
The waveform of what the microphone is producing or what?
What is your electronics, programming, arduino, hardware experience?
Is this a school/college/university project?
Thanks.. Tom.. ![]()
So just please tell me , did you understand what I really want to do and if is it something possible, I need to get my voice through Arduino but now I am only getting the data's of my audio. If you know how can I do it please give me detailed explanation otherwise I will fail from my project.
I am explaining my project one more time, I have microphone and it is working perfectly I can see it on oscillator. I need to somehow put my voice to Matlab and plot it and play it. Does anybody know how can I do such thing ?
Hi,
So you want to see on the Matlab is the voice output of your microphone.
Do you realise that you are DIGITALLY SAMPLING your voice signal, and you need to sample it at a rate faster than the highest frequency you are sampling.
What is the highest audio frequency you want to sample?
For normal voice say to 3.5kHz you will need to sample at least 8kHz.
void loop() {
int val = analogRead(sensePin);
Serial.println(analogRead(sensePin));
delay(300);
}
Now you are sampling every 300mS or more which is 3.3Hz or lower. . . . . . .tooo slooowww...
And you haven't answered our questions about the input waveform and if it is sysmetrical and does not go below gnd.
Hope this explains why.. Tom.. ![]()
Hi,
What qualification are you trying for with the completion of this project?
Do you understand sampling rates and digital sampling?
Tom.. ![]()
I need to sample it with 16kHz, I didn't know that 300ms makes 3.3Hz. so do I need to sample it with 1354.000second ? isn't it too much ?
This is university senior project. I need to see the waveform of my voice. Please do ask more questions with your questions I am starting to understand what I need to change