LTSpice .wave statement and audio file processing question - Page 1
Forum section: electronics / projects

author: Lucky-Luka
author_rank: Unknown
timestamp: December 23, 2019, 12:27:21 pm
content: Hi allI'm trying to work with the wave statement in my voltage amplifier circuit.I've read that it works fine for an +-1V output range.I have +-1V input range and my circuit gain is 10 so this statement doesn't work properly.How can I properly scale my input signal (a .wav file) in order to get an appropriate output in the +-1V range?Thanks

author: iMo
author_rank: Super Contributor
timestamp: December 23, 2019, 12:51:35 pm
content: You may use a resistive divider for example.

author: Ian.M
author_rank: Super Contributor
timestamp: December 23, 2019, 01:07:51 pm
content: How do you mean your circuit doesn't work properly?If you want other than 1V max amplitude from a wavefile source, use a wavefile current source (which has max amplitude 1A) with a low value resistor across it, or if you really *NEED* zero output impedance and don't mind a slower sim with a greater probability of convergence problems, buffer a wavefile voltage source with a voltage controlled voltage source (e) and set the gain of the e source to increase or decrease the amplitude.

author: Lucky-Luka
author_rank: Unknown
timestamp: December 23, 2019, 01:47:00 pm
content: Quote from: Ian.M on December 23, 2019, 01:07:51 pmIn the attached image there is the answer to your question.I haven't fully understood your second suggested solution but I've applied a voltage divider as imo seggested and I think I've obtained what I was looking for: I have now a max +-1V output signal and the .wave statement works just fine.

author: Ian.M
author_rank: Super Contributor
timestamp: December 23, 2019, 02:37:59 pm
content: So you want to scale down the output to capture it to a wave file.A potential divider works OK for that, as LTspice uses ideal resistors and doesn't add parasitic capacitance unless you tell it to, so you can use a divider with an impedance several orders of magnitude greater than your circuit's output impedance for negligible loading. You may need to AC couple the signal to the divider to remove DC offset.In real life you may well need to buffer the signal either before or after the potential divider or even both, and if its high impedance parallel a resistive divider with a capacitive divider of the same ratio to swamp the effects of stray capacitance.However if you want an ideal no load probe with scaling to generate a signal you can record to a wav file, use an E source, or even a BV source if you want to transform the signal mathematically, including subtracting a DC offset.

author: Lucky-Luka
author_rank: Unknown
timestamp: December 23, 2019, 02:50:16 pm
content: Quote from: Ian.M on December 23, 2019, 02:37:59 pmHow can I do that? Using a capacitor in series with the input in my circuit? Which size?

author: Ian.M
author_rank: Super Contributor
timestamp: December 23, 2019, 03:10:21 pm
content: No. As I said earlier, if you want to scale the input, the easiest option is a wavefile current source with a resistor across it e.g. 0.1 ohms for 100mV amplitude. Whether or not you need a coupling capacitor depends on your circuit's biassing. Your circuit needs a DC path for the base current of Q17, so if you AC couple the input, you'll need to provide a bias network after the coupling capacitor.If you use a potential divider to scale the circuitOUTPUTand need to get rid of DC offset, AC couple it. The RC time constant of the coupling capacitor with the total divider resistance should be chosen to get the -3db cutoff frequency well below the lowest frequency of interest. Alternatively, if the operating point is stable, for sim only, you could add a DC voltage source in series with the output to cancel out the offset.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 23, 2019, 03:57:50 pm
content: There are more that one way to do this, but if you want to use this case as an opportunity to learn how to use arbitrary calculations on signals to generate new signals in LTSpice, you can use an intermediate arbitrary voltage source.Let's say that the output node of your "wave" statement is "Wav". Add a "bv" type voltage source. The default "value" field when you edit it is "V=F(...)". Replace it with "V=0.1*V(Wav)". Done. You can use of course much more sophisticated calculations as well. Pretty handy. See section "B. Arbitrary Behavioral Voltage or Current Sources" of the inline help.

author: Lucky-Luka
author_rank: Unknown
timestamp: December 23, 2019, 04:16:26 pm
content: That's interesting.However in this case I just wanted to test how my circuit made my input "sound".imo solution is the simplest one and gets the job done, right?Cheers