Want to do something with Audio without background in electronics - Page 1
Forum section: electronics / projects

author: soFPG
author_rank: Frequent Contributor
timestamp: January 12, 2020, 05:33:11 pm
content: 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 measurethe impedance of a loudspeakerchassis (usually 4 - 8 Ohm resistance) from 20Hz to 20kHzFor 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 20kHzthis sine wave probably needs to be fed into an operational amplifier (or any amplifier) whose output is connected to a speakerthen there must be a resistor with precisely known value in series to the second connector of the speakersomewhere inbetween the resistor and the loudspeaker I have to measure the voltage with an ADCI 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 measurenegativevoltage (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 Impedancenotabout 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

author: Messtechniker
author_rank: Frequent Contributor
timestamp: January 12, 2020, 05:56:11 pm
content: For this I went the sound card route.All you need:- A stereo sound card. Even a cheap one will do becauseany 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.

author: soFPG
author_rank: Frequent Contributor
timestamp: January 12, 2020, 05:59:36 pm
content: 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.

author: bob91343
author_rank: Super Contributor
timestamp: January 12, 2020, 06:17:48 pm
content: 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.

author: soFPG
author_rank: Frequent Contributor
timestamp: January 12, 2020, 07:02:02 pm
content: Quote from: bob91343 on January 12, 2020, 06:17:48 pmDo you think a microcontroller could do that? I mean sending the digital values of a sine wave to the DAC?

author: CatalinaWOW
author_rank: Super Contributor
timestamp: January 12, 2020, 07:23:35 pm
content: Quote from: soFPG on January 12, 2020, 07:02:02 pmOf 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.

author: Prehistoricman
author_rank: Regular Contributor
timestamp: January 12, 2020, 08:44:24 pm
content: 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.

author: OldEE
author_rank: Contributor
timestamp: January 13, 2020, 03:07:05 am
content: Here are a couple of papers to read for ideas:https://www.rationalacoustics.com/files/Impedance_Tech-Note.pdfGood 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.pdfLIMP manual which is part of the Arta package. Good stuff and understandable.As previously mentioned Arta is worth a look.

author: soFPG
author_rank: Frequent Contributor
timestamp: January 13, 2020, 10:54:20 am
content: QuoteSure, 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.pdfQuoteDo 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.QuoteI also described that idea in my original posting. Without a known resistor, measuring impedance is not going to be possible.QuoteWhat 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.

author: ConKbot
author_rank: Super Contributor
timestamp: January 13, 2020, 11:13:09 pm
content: It sounds like you want something similar to this?https://youtu.be/rexXJ2xc2ZQEven 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.

author: Prehistoricman
author_rank: Regular Contributor
timestamp: January 14, 2020, 01:05:05 pm
content: Quote from: soFPG on January 13, 2020, 10:54:20 amThis 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 amI 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 amSorry, 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.

author: soFPG
author_rank: Frequent Contributor
timestamp: January 15, 2020, 02:05:11 pm
content: Thanks Prehistoricman, that's a very valuable post for me.QuoteThanks for the clarificationQuoteNo, 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.QuoteWell, how would this work if I truly create an AC voltage?QuoteI don't really want to play with an AC power supply or whatnot. Is it possible to stick to a 5V DC supply?QuoteHow 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)?QuoteSo 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?QuoteI wrote:then there must be a resistor with precisely known value in series to the second connector of the speakerQuoteI don't think we are speaking about the same thing. How do I getIwithout an resistor?Sorry to ask so many beginners questions

author: Prehistoricman
author_rank: Regular Contributor
timestamp: January 15, 2020, 05:01:48 pm
content: Quote from: soFPG on January 15, 2020, 02:05:11 pmHere'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 pmIn 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 pmThat'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 pmAha, 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 / RsenseThe current through the sense resistor is equal to the current through the speaker. Ispk = IsenseFrom this you can know two of the Ohm's law parameters for the speaker: Vspk and IspkSo 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 pmMore 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

author: soFPG
author_rank: Frequent Contributor
timestamp: January 15, 2020, 06:01:25 pm
content: QuoteNo! 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.