Author Topic: Want to do something with Audio without background in electronics  (Read 1699 times)

0 Members and 1 Guest are viewing this topic.

Offline soFPGTopic starter

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: de
Hi lovely EEVblog community,

my mind comes up with new project ideas all the time. Usually they stick around for a while but eventually are replaced with other ideas. This idea though comes up every now and then and doesn't want to go away.

What it's all about:
  • design a PCB which is able to measure the impedance of a loudspeaker chassis (usually 4 - 8 Ohm resistance) from 20Hz to 20kHz

For me who doesn't have a background in electronic engineering and circuit design, this is not as easy as it might be for others who already have the necessary knowledge (I am more a software guy).
Nevertheless, I want to describe possible solutions for this project which I came up with:
  • I am probably going to need a DAC which creates a sine wave from 20Hz to 20kHz
  • this sine wave probably needs to be fed into an operational amplifier (or any amplifier) whose output is connected to a speaker
  • then there must be a resistor with precisely known value in series to the second connector of the speaker
  • somewhere inbetween the resistor and the loudspeaker I have to measure the voltage with an ADC

I have some questions:

  • How much output power does the sine wave has to have and at which voltage to be able to drive a 4/8 Ohm speaker properly?
  • How do I measure negative voltage (half period of the sine wave which is below 0)? Do I have to measure it at all or is there some workaround?
  • Are there any specific things I have to pay attention to while designing the PCB?
  • Do I need 24-bits of resolution or are 16-bits more than enough (again, I am only talking about Impedance not about sound quality)?

I want to use an ESP8266 for that because it has a built in I2S interface which can be used to interface with the ADC/DAC. Also, It would be pretty neat to have a webinterface where the user (most likely I am going to be the only user) can see the curve (Impedance over Frequency) and save it to his computer.

Any help / ideas / solutions are very much appreciated!

Thank you so much
« Last Edit: January 12, 2020, 05:35:41 pm by soFPG »
 

Offline Messtechniker

  • Frequent Contributor
  • **
  • Posts: 808
  • Country: de
  • Old analog audio hand - No voodoo.
Re: Want to do something with Audio without background in electronics
« Reply #1 on: January 12, 2020, 05:56:11 pm »
For this I went the sound card route.
All you need:
- A stereo sound card. Even a cheap one will do because
  any frequency response anomalies can be compensated for
- A small power amp (10 W will easily do)
- A 50 Ohm 5 W or so resistor
- A measurement program like "Arta" or "Audio Tester", for example.

Will do nicely. No need to bother making a pcb.


Agilent 34465A, Siglent SDG 2042X, Hameg HMO1022, R&S HMC 8043, Peaktech 2025A, Voltcraft VC 940, M-Audio Audiophile 192, R&S Psophometer UPGR, 3 Transistor Testers, DL4JAL Transistor Curve Tracer, UT622E LCR meter, UT216C AC/DC Clamp Meter
 

Offline soFPGTopic starter

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: de
Re: Want to do something with Audio without background in electronics
« Reply #2 on: January 12, 2020, 05:59:36 pm »
Thanks for your reply.

I really appreciate your idea but (unfortunately) I am more interested in the way of how to solve such a problem than in the real impedance values at the end.
 

Offline bob91343

  • Super Contributor
  • ***
  • Posts: 2675
  • Country: us
Re: Want to do something with Audio without background in electronics
« Reply #3 on: January 12, 2020, 06:17:48 pm »
Read up on impedance bridges.  That is perhaps the best solution.  There are many types and some more suited than others.

You indeed will need a source of signal, either from a signal generator or home brew.  The latter is like reinventing the wheel but it's entirely feasible.  For this you  need to investigate oscillator circuits.

You will need a standard of impedance, one you know accurately, such as a resistor and a capacitor.

If you don't need great precision, an oscilloscope may be a way to measure phase angle and, thus, impedance.

You can build what's called an Octopus, which will put a graph of impedance on the screen of a scope, which you then calibrate.
 

Offline soFPGTopic starter

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: de
Re: Want to do something with Audio without background in electronics
« Reply #4 on: January 12, 2020, 07:02:02 pm »
You indeed will need a source of signal, either from a signal generator or home brew.

Do you think a microcontroller could do that? I mean sending the digital values of a sine wave to the DAC?
 

Online CatalinaWOW

  • Super Contributor
  • ***
  • Posts: 5375
  • Country: us
Re: Want to do something with Audio without background in electronics
« Reply #5 on: January 12, 2020, 07:23:35 pm »
You indeed will need a source of signal, either from a signal generator or home brew.

Do you think a microcontroller could do that? I mean sending the digital values of a sine wave to the DAC?

Of course it can.  There are advantages and disadvantages.  The sine waves generated by analog signal generators are imperfect, as are those from a digital signal generator.  Some of the imperfections are very different in characteristic.  One way or another you have to figure out how those imperfections impact the measurement you are making.  Once you understand that you can decide if it is good enough, and if so then start thinking about which might be cheaper, easier to build, easier to calibrate and a number of other things.  The answers to each of them are not universal, they depend on your situation and goals.

I find it best to model what is going mathematically.  Others find building test circuits and experimenting, or a sort of hybrid of the two using spice or other modeling program.  Each of these approaches has merits and limitations. 

Whether you go directly to one those methods, or just ask lots of questions in this and other forums you will need to do a lot of thinking to understand and evaluate the results.
 

Offline Prehistoricman

  • Regular Contributor
  • *
  • Posts: 216
  • Country: gb
Re: Want to do something with Audio without background in electronics
« Reply #6 on: January 12, 2020, 08:44:24 pm »
I would use a digital generator. You're more likely to have predictable non-linearity with digital generation than analogue (I'm confident on this, but I say it from a position of inexperience).

Reading back of the current waveform can be done very dumbly. See if you can get away with sampling the peak of the sine. If not, you can rectify the signal and average it. You may need to capture more cycles for the higher frequencies, depending on the sampling speed of your ADC.

Messtechniker's idea of using a known resistive load to characterise the system is a good one.

Offline OldEE

  • Contributor
  • Posts: 18
Re: Want to do something with Audio without background in electronics
« Reply #7 on: January 13, 2020, 03:07:05 am »
Here are a couple of papers to read for ideas:

https://www.rationalacoustics.com/files/Impedance_Tech-Note.pdf
Good math and design.  SMAART is overkill and current version doesn't do impedance anyway.

http://www.artalabs.hr/AppNotes/LIMP_Tutorial_Version_2_4_English.pdf
LIMP manual which is part of the Arta package.  Good stuff and understandable.

As previously mentioned Arta is worth a look.
 

Offline soFPGTopic starter

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: de
Re: Want to do something with Audio without background in electronics
« Reply #8 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.
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

Quote
Reading back of the current waveform can be done very dumbly
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.

Quote
Messtechniker's idea of using a known resistive load to characterise the system is a good one.
I also described that idea in my original posting. Without a known resistor, measuring impedance is not going to be possible.

Quote
easier to calibrate and a number of other things
What I've seen how system calibration can be done with ARTA/LIMP is to make a "short circuit"-connection where the loudspeaker would be (still measuring power from 20Hz - 20kHz at the known resistive load) and then use this measurement to subtract from the loudspeaker measurement to get a final result.
 

Offline ConKbot

  • Super Contributor
  • ***
  • Posts: 1397
Re: Want to do something with Audio without background in electronics
« Reply #9 on: January 13, 2020, 11:13:09 pm »
It sounds like you want something similar to this?
https://youtu.be/rexXJ2xc2ZQ
Even if you want to do the project for fun, having a peek at how another similar unit is run can give you an idea of how you'd want to do your own.

It looks like it just shows up as a sound device for windows, probably using stereo line in for voltage and current, and the number crunching/analysis is done on the PC.
 

Offline Prehistoricman

  • Regular Contributor
  • *
  • Posts: 216
  • Country: gb
Re: Want to do something with Audio without background in electronics
« Reply #10 on: January 14, 2020, 01:05:05 pm »
Quote
You may need to capture more cycles for the higher frequencies, depending on the sampling speed of your ADC.
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
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
Reading back of the current waveform can be done very dumbly
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.
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
Messtechniker's idea of using a known resistive load to characterise the system is a good one.
I also described that idea in my original posting. Without a known resistor, measuring impedance is not going to be possible.
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.
 
The following users thanked this post: soFPG

Offline soFPGTopic starter

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: de
Re: Want to do something with Audio without background in electronics
« Reply #11 on: January 15, 2020, 02:05:11 pm »
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.
Thanks for the clarification :)

Quote
I hope you're not planning to couple the speaker directly to your DAC
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).
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.
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
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.
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.
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.
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
 

Offline Prehistoricman

  • Regular Contributor
  • *
  • Posts: 216
  • Country: gb
Re: Want to do something with Audio without background in electronics
« Reply #12 on: January 15, 2020, 05:01:48 pm »
Quote
I hope you're not planning to couple the speaker directly to your DAC
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?

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.


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)?
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
It doesn't matter.
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?
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.


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?
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.


Thanks Prehistoricman, that's a very valuable post for me.
...
Sorry to ask so many beginners questions
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
 
The following users thanked this post: soFPG

Offline soFPGTopic starter

  • Frequent Contributor
  • **
  • Posts: 283
  • Country: de
Re: Want to do something with Audio without background in electronics
« Reply #13 on: January 15, 2020, 06:01:25 pm »
Quote
I hope I haven't given you too many words, or too many options
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf