Characterizing speakers in LTSpice using the freq response graph. - Page 1
Forum section: electronics / beginners

author: dazz
author_rank: Frequent Contributor
timestamp: January 01, 2021, 02:42:06 pm
content: Happy new year everyone.So I'm trying to model guitar speakers in LTSpice to use them in the AC simulation. The idea is to use the datasheet graphs to create a model that I can use with different amp simulations, so that the speakers "color" the sound too.I came across this potential solution while browsing the web, that uses a behavioral voltage source to map frequencies with impedance and phase:Code:.subckt speakerload 1 2B1 1 2 V=I(B1)/100K MAG FREQ=+ 20.142, 7.540, 20.971+ 20.508, 7.564, 21.387+ 21.240, 7.666, 22.072+ 21.973, 7.772, 22.653+ 22.705, 7.869, 23.831+ 23.438, 8.016, 22.457+ 24.170, 8.265, 24.358+ 24.902, 8.211, 24.728+ 25.635, 8.416, 22.599+ 26.367, 8.571, 25.396+ 27.100, 8.707, 25.959+ 27.832, 8.895, 26.814+ 28.564, 9.152, 26.909+ 29.297, 9.343, 27.048+ 30.029, 9.612, 26.830.endsProblem is, I generally won't have that kind of data. Instead I'll be using these graphs:Through some trial and error I managed to replicate the graph, but I don't really know what I'm doingCode:.subckt V30-AC 1 2B1 1 2 V=I(B1)/100K MAG FREQ=+ 3, 1, 20+ 10, 316.227766016838, 20+ 20, 3162.27766016838, 20+ 30, 8912.50938133747, 20+ 38, 13335.2143216333, 20+ 48, 12589.2541179417, 20+ 61, 17782.7941003892, 20+ 71, 17782.7941003892, 20+ 125, 63095.7344480193, 20+ 140, 70794.5784384138, 20+ 215, 63095.7344480193, 20+ 240, 70794.5784384138, 20+ 290, 66834.3917568616, 20+ 300, 74989.4209332457, 20+ 330, 74989.4209332457, 20+ 350, 70794.5784384138, 20+ 450, 94406.0876285924, 20+ 600, 94406.0876285924, 20+ 700, 100000, 20+ 800, 94406.0876285924, 20+ 1200, 94406.0876285924, 20+ 1350, 66834.3917568616, 20+ 1500, 125892.541179417, 20+ 1550, 141253.754462276, 20+ 1700, 141253.754462276, 20+ 1850, 133352.143216333, 20+ 2200, 223872.113856834, 20+ 2250, 223872.113856834, 20+ 2350, 177827.941003893, 20+ 2500, 237137.370566166, 20+ 2800, 188364.90894898, 20+ 3000, 188364.90894898, 20+ 3100, 199526.231496888, 20+ 3200, 199526.231496888, 20+ 3600, 158489.319246112, 20+ 3850, 188364.90894898, 20+ 4450, 100000, 20+ 4900, 105925.372517729, 20+ 7700, 3548.13389233575, 20+ 8200, 7498.94209332456, 20+ 9000, 7079.45784384138, 20+ 10000, 10000, 20+ 11500, 3349.65439157828, 20+ 12400, 10000, 20+ 12900, 10000, 20+ 13500, 3162.27766016838, 20+ 14500, 1778.27941003892, 20+ 15000, 2818.38293126446, 20+ 15750, 2371.37370566166, 20+ 18500, 12589.2541179417, 20+ 20000, 10000, 20+ 50000, 1, 20This doesn't work. When I use that in a circuit, it kind of changes the frequency response accordingly, but it doesn't really do it by the correct amount of dB.Any ideas, please? I'm not sure I can scale the model's entries so that it will apply the gain conversion that the graph stipulates, or can I?(I attached the symbol for the speaker, in case it helps)EDIT: Forgot to mention how I came up with the impedance values above: I simply took the dB values and applied the formula 10dB/20Then divided by 100K trying to make it work, because the original values are too high apparently

author: radiolistener
author_rank: Super Contributor
timestamp: January 01, 2021, 07:12:49 pm
content: I think LTspice needs impedance data, you can measure it with vector network analyzer.But you're using sound pressure level, this is different data.

author: dazz
author_rank: Frequent Contributor
timestamp: January 01, 2021, 08:37:08 pm
content: Quote from: radiolistener on January 01, 2021, 07:12:49 pmYes, I know. The assumption is that a speaker with a SPL curve like the above, will shape the amp's frequency response by "correcting" the output at any given frequency by the same amount of dB, if that makes any sense. Am I operating under a false premise maybe?

author: CaptDon
author_rank: Super Contributor
timestamp: January 01, 2021, 09:04:04 pm
content: SPL and impedance vary differently from each other and one will notaccurately predict the other. In addition you can't use the data froma 12" JBL and a 12" Eminence to predict the color of the sound unlessthey were both tested and graphed in an identical cabinet. In fact, thecabinet will have more effect on the color of the sound and the graphproduced in 'your' cabinet will be radically different than the graph youget from the factory supplied data. The factory data will provide littleinsight to how a speak will actually sound in any given cabinet. In criticallysmall cabinets, ones which were acoustically to small for the 12" speakerplaced in them I have had speakers who's T.S. parameters predicted terribleoperation sound very pleasant, and speakers specifically selected by theirT.S. parameters for use in a small cabinet sound horrible. You can't predictthe color of an apple based on the taste of an orange.

author: dazz
author_rank: Frequent Contributor
timestamp: January 01, 2021, 09:18:45 pm
content: Quote from: CaptDon on January 01, 2021, 09:04:04 pmMakes sense. Thanks.

author: SilverSolder
author_rank: Super Contributor
timestamp: January 01, 2021, 09:38:34 pm
content: The amplifier will color the sound much, much less than the speaker and its cabinet - so much less that you can ignore the contribution from the amp for practical purposes.If you are trying to model tone controls etc., you can just add the response curve of the tone control (in dB) to the speaker response chart, as a first approximation of what the final result might be heading towards (all else being equal).

author: dazz
author_rank: Frequent Contributor
timestamp: January 01, 2021, 11:43:02 pm
content: Quote from: SilverSolder on January 01, 2021, 09:38:34 pmThat was the original idea, I was wondering what would be a good way to accomplish that in LTSpice.I do have some tone controls in my preamps indeed. Power stages seem to be mostly flat in their response, but not preamps.I guess what I'm trying to do, in a way, is to model the speaker as an "amplifier" stage with a very specific frequency response. It's probably a stupid idea, but I'm curious as to how that could be done, if possible at all. It may be a practical way to also model amp stages if all you have is the dB graph

author: CaptDon
author_rank: Super Contributor
timestamp: January 01, 2021, 11:46:04 pm
content: Search on some of the online speaker data looking specifically fora graph which plots both impedance and SPL on the same graph.I think JBL may do this. The impedance variation is just crazy!!At self resonance or at cabinet resonance the impedance of an8 ohm speaker may be as high as 60 ohms. There in becomesa bit of a lie in the way speakers are characterized. They will say'1 watt / 1 meter' but in reality as the impedance changed so wouldthe required drive voltage. This is not how the SPL is usually measured.They keep the voltage constant, I forget the exact number but at 8 ohmsit is something like 2.83vrms. If you keep the voltage constant and theimpedance varies widely then so also does the actual power consumedby the speaker and so does the power draw placed on the amplifier.This is why there is some sort of negative feedback in the amplifier,to make sure the output voltage is always some exact ratio of the inputvoltage which remains constant across varying frequencies and loads.This negative feedback along with 'output impedance' of the amplifierhelps to create 'Damping' which is how we 'control' the tendency ofthe speaker to keep vibrating from a single energy hit. Similar to givinga push to a kid on a swing. For accurate reproduction we don't wantthe speaker to keep 'swinging' after just one push. We want the swingto follow our hands, if our hands stop, the swing immediately stops.This is the 'damping factor'. In reality the speaker has mechanical'Q' or quality factor which means it wants to act like a swing and continueto move after just one push. This is probably more than you ever wanted toknow hehehe. Cheers!!! Happy New Year Mate!!

author: dazz
author_rank: Frequent Contributor
timestamp: January 02, 2021, 12:06:41 am
content: Don, thanks again for your input, it's always much appreciated when highly knowledgeable people like you guys take your time to help clueless hacks like meThat will take some time to process, but every opportunity to learn something is most welcome. I've heard about that damping factor thing before though it mostly went over my head I guess. I'll look it up.

author: dazz
author_rank: Frequent Contributor
timestamp: January 02, 2021, 12:19:29 am
content: So here's an example of the graph you mentioned, including the impedance data. I see what you're talking about re: "The impedance variation is just crazy"That looks pretty close to the kind of curves I get from "proper" speaker models here.

author: srb1954
author_rank: Super Contributor
timestamp: January 02, 2021, 12:43:21 am
content: Quote from: dazz on January 01, 2021, 08:37:08 pmIt is important to also model the electrical impedance of the speaker to determine its effect on the amplifier performance. This can affect the amplifier stability and the peak voltages/currents seen by the output transistors. This is a fairly basic amplifier design without much in the way of protection for the output transistors so you could potentially damage the output transistors if the speaker presents an adverse electrical load to the amplifier.You can measure the electrical impedance of the speaker using a vector impedance meter and create an equivalent circuit for simulation using inductors, capacitors and resistors.Please note that this electrical impedance of the speaker is not directly related to the acoustic response graphs you have been attempting to simulate but both are affected by the cabinet design at lower frequencies.

author: dazz
author_rank: Frequent Contributor
timestamp: January 02, 2021, 12:54:02 am
content: Quote from: srb1954 on January 02, 2021, 12:43:21 amI only picked that output stage because it's fairly flat, so thought it would be a good choice to test my LTSpice models. I was obviously missing some crucial facts like those you guys mentioned. Cabinet design, Damping factor, etc...So my original idea is nonsense by the looks of it.Thanks, srb

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: January 02, 2021, 03:47:27 am
content: Quote from: dazz on January 02, 2021, 12:54:02 amAs someone who used to design and build cabinets (out of necessity), I found the discussion interesting none the less.

author: dazz
author_rank: Frequent Contributor
timestamp: January 02, 2021, 07:50:41 am
content: Quote from: Ed.Kloonk on January 02, 2021, 03:47:27 amSure, I always learn a few things here. It's an awesome place for beginners like me. Really appreciate everyone's insight

author: SilverSolder
author_rank: Super Contributor
timestamp: January 02, 2021, 03:29:44 pm
content: Quote from: dazz on January 02, 2021, 12:54:02 amYou can actually ignore the speaker impedance for your purposes.The response curve of the speaker also involved ignoring impedance when it was measured, as others have pointed out. The response curve actually shows the speaker's response to a constant AC voltage, rather than constant power. This is actually much more useful and simpler to work with!A simple way to do what you want in LTSpice might be to define the speaker response as a generator (I believe you did that already), and use that as the input to your amplifier and tone control model. What comes out of that model, is now the combined response of the two systems - which LTSpice can now plot easily!

author: dazz
author_rank: Frequent Contributor
timestamp: January 02, 2021, 05:18:31 pm
content: Quote from: SilverSolder on January 02, 2021, 03:29:44 pmYep, that worked like a charm.It's weird to have that speaker symbol at the input, but it's a behavioral voltage source. I think the elephant in the room right now is that I don't fully understand simple concepts like how voltage and current sources workWhy would I need to add that AC current source I1? If the voltage source is defined in terms of frequency and magnitude, shouldn't that be an AC source already?Just to be clear, at this point this doesn't have anything to do with speakers and their SPL response, just trying to understand how this sources work and if it's possible to have stages that "apply" arbitrary frequency response curves to the amp. Probably just as stupid as the original concept, but I feel there's something to be learnt here.

author: SilverSolder
author_rank: Super Contributor
timestamp: January 02, 2021, 08:31:38 pm
content: Quote from: dazz on January 02, 2021, 05:18:31 pmI think this is probably just the way LTSpice works - it requires an AC source to act as the reference point for an AC analysis, and it isn't accepting the behavioural model as that AC source, for whatever reason. Maybe someone that knows LTSpice better than me knows how to persuade LTSpice to accept it as an AC source for this purpose.Quote from: dazz on January 02, 2021, 05:18:31 pmYes, that is exactly possible now. You could try adding a simple RC filter (high pass) to the output, as a pretend tone control, and see what happens!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: January 02, 2021, 10:48:13 pm
content: Here's an example, comparing measured and fitted speaker impedances. Afraid I don't know what type, or frequency response.Assuming for a moment that the response is similar to yours, yeah, you can see there isn't much relation between them.The acoustic response is not indicative of terminal impedance, because there are other losses in the system (namely, coil resistance which is particularly dominant at LF; suspension and cone loss; and whatever the cabinet does (or whatever the standard test environment is, in which the SPL was measured)).Also, it's unlikely that the SPL curve was measured under a constant-power or matched-impedance condition -- probably constant-voltage, as most power amps are. And again, as you can see from the plot, in general the power draw will vary all over the place.Losses are very important here -- most speakers have terrifically poor efficiency, in terms of raw electrical to acoustic power conversion. A high-efficiency peak could be +10 or +20dB against the baseline, IIRC. (Alas, high efficiency speakers tend to be very narrow -- one resonance that couples well to the air, and crap anywhere else -- or expensive and large, e.g. horns. Imagine a horn designed for efficient operation at 100Hz, or even less -- it's no wonder they're usually confined to tweeter or mid use.)So there are better ways to approach this sort of problem. First, we can separate the problem into two aspects:1. Stability2. Frequency responseStability.Depends on the relationship between amplifier behavior, and load impedance. We can test this independently, by simply mocking up whatever impedance load we like, and giving it a buzz.In particular, capacitive and resonant loads tend to be the most challenging for typical amplifier designs. A good test is 1Ω + 4.7uF (film) across the amplifier output, tested with a square wave of variable amplitude. Be sure to check a range of amplitudes, because it may "squegg" at certain operating points (their time constants vary: capacitances vary with instantaneous voltage, and loop gain (transconductance) with instantaneous current). Resonant loads include piezo tweeters, which can cause ultrasonic oscillation even in rather stable amplifiers -- a good mimic is an L+C series resonant circuit, say 39uH and 0.68uF).This can be supported by other studies in stability or phase margin, in the amplifier's global loop or in local feedback environments. Basically, test connected units of transistors, like Darlington/Sziklai pairs; and by "test", I mean test them in their intended environment -- including stray wiring inductance and full bias voltage and current!Frequency response.This can be solved entirely with small-signal filtering, as long as your final amplifier has enough capacity to drive the speaker hard enough to compensate for its flaws. (Which, that's why you use a 100 or 500W or whatever amplifier, when you do.) You can solve for a network of inverse response, even attempting to correct phase shift if you like. This will probably take the better part of a dozen op-amps to achieve, but yeah, it's doable, just a bit tedious (and hard to adjust, in case it should ever need to change!).More likely, you'll just take a best-fit approximation with a parametric EQ and settle for that. Hence the "smiley face" profile commonly seen on them.Alternately, solve it in DSP -- a typical Cortex >= M0 MCU can do this, or anything DSP or FPGA, or if your signal source goes through a PC, just set up a filter in software there.In any case, this is pretty useless if you don't have a way to verify the actual result -- you're just assuming you know that your ears know what they're hearing, and that's areally poor assumption!(I submit as evidence, an article such as this:https://audiophilereview.com/news/the-case-for-double-blind-tests/there's a good half dozen glaring fallacies listed there, consider it an exercise to spot them.) Best case, you have a microphone -- which just the same, needs to have a well known (calibrated) frequency response -- and then you can measure frequency response of the real speakers, cabinets, room and furniture, and make adjustments as needed.Which isn't nearly as bad as it sounds -- a reasonable mic is under a hundred bucks, and by playing white noise or sweeps, you can record the frequency response at a point in the room in mere seconds. Tally up a few of those, fudge around the EQ, and there you go, calibrated in maybe an hour's time.Tim