Electronics > Projects, Designs, and Technical Stuff

Want to do something with Audio without background in electronics

<< < (3/3)

Prehistoricman:

--- Quote from: soFPG on January 13, 2020, 10:54:20 am ---
--- Quote ---You may need to capture more cycles for the higher frequencies, depending on the sampling speed of your ADC.
--- End quote ---
Sure, probably twice the frequency as suggested by the Nyquist theorem. My currently selected ADC can do up to 96kHz: http://www.ti.com/lit/ds/symlink/pcm1808.pdf
--- End quote ---
This isn't a Nyquist-type problem. What I mean by that is: you're not interested in seeing the waveform and resolving its details because you can assume it's a sine. All you want is the amplitude or a function of the amplitude.
What I meant by the original statement is that if you're going to undersample (which you can), you want a good distribution of samples over the input wave.
However, you have the chance to oversample, so you might as well do that and use an average or peak detection function.


--- Quote from: soFPG on January 13, 2020, 10:54:20 am ---
--- Quote ---Reading back of the current waveform can be done very dumbly
--- End quote ---
Do you know if I am fine with the sine generated by the DAC is wiggling around 1V with peaks at 2V and 0V? Do loudspeaker receive negative voltage from an amplifier while playing music? An average voltage of 1V sine curve will probably cause the loudspeaker cone to move out compared to its idle state, right? I don't know if that's going to be a problem.

--- End quote ---
I hope you're not planning to couple the speaker directly to your DAC... A small DC offset on the speaker generally doesn't matter, but it may for making measurements (idk).
You can easily have a single-ended amplifier that's AC-coupled to the speaker with a series resistor for measuring current. That resistor could be direct on the output such that the whole signal is in range of the ADC or at the ground-end such that the ADC only sees half-cycles. It doesn't matter.


--- Quote from: soFPG on January 13, 2020, 10:54:20 am ---
--- Quote ---Messtechniker's idea of using a known resistive load to characterise the system is a good one.
--- End quote ---
I also described that idea in my original posting. Without a known resistor, measuring impedance is not going to be possible.

--- End quote ---
Sorry, I missed it in your post. Why not possible? R = V / I, you know V and I so you can calculate R. Calibration is there to remove any poor performance your system may have as a whole, but the fundamental calculation doesn't require calibration.

soFPG:
Thanks Prehistoricman, that's a very valuable post for me.


--- Quote ---However, you have the chance to oversample, so you might as well do that and use an average or peak detection function.
--- End quote ---
Thanks for the clarification :)


--- Quote ---I hope you're not planning to couple the speaker directly to your DAC
--- End quote ---
No, I am not. What I meant to say if this offset is going to produce any problems because I can't generate an AC-voltage (in terms of a voltage < 0 during one half sine wave) with a DAC (I assume?) if there is no negative supply voltage. So there has to be an offset - right?
I don't have enough knowledge about electronics to tell whether an operational amplifier would be sufficient or if I need something with more output power.


--- Quote ---A small DC offset on the speaker generally doesn't matter, but it may for making measurements (idk).
--- End quote ---
Well, how would this work if I truly create an AC voltage?


--- Quote ---You can easily have a single-ended amplifier that's AC-coupled to the speaker with a series resistor for measuring current.
--- End quote ---
I don't really want to play with an AC power supply or whatnot. Is it possible to stick to a 5V DC supply?


--- Quote --- That resistor could be direct on the output such that the whole signal is in range of the ADC
--- End quote ---
How can the whole signal be in the range of the ADC if the signal is AC and the ADC can only measure half of the cycle (because DC)?


--- Quote ---It doesn't matter.
--- End quote ---
So what you are saying is that I don't need to sample a complete sine wave from the ADC because I just need the peaks (which will of course also occur during the positiv wave) to calculate impedance?


--- Quote ---Sorry, I missed it in your post.
--- End quote ---
I wrote: then there must be a resistor with precisely known value in series to the second connector of the speaker


--- Quote ---R = V / I, you know V and I so you can calculate R.
--- End quote ---
I don't think we are speaking about the same thing. How do I get I without an resistor?

Sorry to ask so many beginners questions

Prehistoricman:

--- Quote from: soFPG on January 15, 2020, 02:05:11 pm ---
--- Quote ---I hope you're not planning to couple the speaker directly to your DAC
--- End quote ---
No, I am not. What I meant to say if this offset is going to produce any problems because I can't generate an AC-voltage (in terms of a voltage < 0 during one half sine wave) with a DAC (I assume?) if there is no negative supply voltage. So there has to be an offset - right?
I don't have enough knowledge about electronics to tell whether an operational amplifier would be sufficient or if I need something with more output power.

Well, how would this work if I truly create an AC voltage?

I don't really want to play with an AC power supply or whatnot. Is it possible to stick to a 5V DC supply?

--- End quote ---

Here's a basic idea of what your setup could look like. The DAC on the left is generating the signal with a DC offset so that the output stays within the power supply rails.
The opamp could be just an opamp, or a driver IC like LM386, or a power amp IC. Start with an opamp and see how you get on. They don't have a lot of output drive for speakers but AFAIK, speaker parameters don't change a lot between 1 milliwatt and 1 watt (unless you have a very low-power speaker).
I added two resistors R1 and R2 as current sense resistors. You can choose either one and measure the voltage across it. 10 ohms is just a placeholder value that would work, but you may want to decrease the value to near-zero so you can assume that the voltage across the speaker is equal to the amplifier output voltage.
The capacitor (1 microfarad is probably a bit small, you would lose bass response) is an AC-coupling capacitor. You can see this kind of capacitor in many audio circuits. They are used to change a signal's DC value without changing its AC value.
On the topic of AC: you seem to be confusing mains AC power with the definition of AC. AC = alternating current, but usually when engineers talk about AC, they mean a voltage that is rapidly changing (hence "AC voltage"). So yes, mains power is AC but the presence of AC in your circuit (inevitable) is not related to mains power.



--- Quote from: soFPG on January 15, 2020, 02:05:11 pm ---How can the whole signal be in the range of the ADC if the signal is AC and the ADC can only measure half of the cycle (because DC)?

--- End quote ---
In reference to the image above, if you measure the voltage after R1, the whole signal will be within your power supply and the ADC can read it. Or you could accept the clipping and measure directly from R2. Or you could use an AC-coupling capacitor to add DC back to the voltage at R2 and then the ADC can read the whole signal.



--- Quote from: soFPG on January 15, 2020, 02:05:11 pm ---
--- Quote ---It doesn't matter.
--- End quote ---
So what you are saying is that I don't need to sample a complete sine wave from the ADC because I just need the peaks (which will of course also occur during the positiv wave) to calculate impedance?

--- End quote ---
That's right. For a perfect sine wave, the amplitude, peak to peak voltage, and RMS voltage are all linearly related. What that means for you is that you don't need to know anything except for the peak voltage to calculate the RMS voltage. From that and the resistor value, you know the current through the resistor by I = V / R.
For a sine wave signal, any of these values at any moment will work in the equation. The speaker impedance Z = V / I is an instantaneous value, but it will be constant at any point in the sine wave as long as the frequency stays the same.



--- Quote from: soFPG on January 15, 2020, 02:05:11 pm ---I wrote: then there must be a resistor with precisely known value in series to the second connector of the speaker
...
I don't think we are speaking about the same thing. How do I get I without an resistor?

--- End quote ---
Aha, we are talking about different things. I was talking about a resistor to calibrate the system where you place a known load on the speaker terminals.
You're talking about the current sense resistor, which is necessary.

Earlier, I said "but you may want to decrease the value to near-zero so you can assume that the voltage across the speaker is equal to the amplifier output voltage."
To expand on that:
Your output signal Vout will go to the speaker and the sense resistor. Vout = Vspk + Vsense (therefore Vspk = Vout - Vsense)
The current through the sense resistor is related to the voltage across it Isense = Vsense / Rsense
The current through the sense resistor is equal to the current through the speaker. Ispk = Isense
From this you can know two of the Ohm's law parameters for the speaker: Vspk and Ispk
So you can calculate its impedance Z = Vspk / Ispk = (Vout - Vsense) / (Vsense / Rsense)
If you use a small Rsense like 0.1 then you can probably ignore Vsense in the first equation and assume Vout = Vspk. Not really any point though so whatever.
If you use a big Rsense like 10 ohms then there will be more voltage across it so you'll get more resolution in your ADC and therefore a higher quality result.



--- Quote from: soFPG on January 15, 2020, 02:05:11 pm ---Thanks Prehistoricman, that's a very valuable post for me.
...
Sorry to ask so many beginners questions

--- End quote ---
More questions = more good. You're clearly thinking about the problem and you're willing to work on a solution which is great.
I hope I haven't given you too many words, or too many options  ;D

soFPG:

--- Quote ---I hope I haven't given you too many words, or too many options
--- End quote ---
No! You probably just gave me the most helpful response I've ever gotten in any forum, really!
Things are a lot clearer now.

Thank you so much!

I already started schematic design with the ESP8266 part of the project (+ pictures for the GUI) and I am going to advance with the audio part thanks to the ideas (+ solutions) from you.
Fortunately, my course at university about advanced technical computer science (which includes explanations about OpAmp/ADC etc...) is going to start pretty soon and will probably help me with this project.

Navigation

[0] Message Index

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod