Author Topic: LTSpice .wave statement and audio file processing question  (Read 1826 times)

0 Members and 1 Guest are viewing this topic.

Offline Lucky-LukaTopic starter

  • Supporter
  • ****
  • Posts: 240
  • Country: it
LTSpice .wave statement and audio file processing question
« on: December 23, 2019, 12:27:21 pm »
Hi all
I'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
Memento audere semper.
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 5570
  • Country: va
Re: LTSpice .wave statement and audio file processing question
« Reply #1 on: December 23, 2019, 12:51:35 pm »
You may use a resistive divider for example.
« Last Edit: December 23, 2019, 12:54:24 pm by imo »
Readers discretion is advised..
 
The following users thanked this post: Lucky-Luka

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: LTSpice .wave statement and audio file processing question
« Reply #2 on: December 23, 2019, 01:07:51 pm »
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.   
 

Offline Lucky-LukaTopic starter

  • Supporter
  • ****
  • Posts: 240
  • Country: it
Re: LTSpice .wave statement and audio file processing question
« Reply #3 on: December 23, 2019, 01:47:00 pm »
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.

In 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.
Memento audere semper.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: LTSpice .wave statement and audio file processing question
« Reply #4 on: December 23, 2019, 02:37:59 pm »
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.
« Last Edit: December 23, 2019, 02:42:12 pm by Ian.M »
 

Offline Lucky-LukaTopic starter

  • Supporter
  • ****
  • Posts: 240
  • Country: it
Re: LTSpice .wave statement and audio file processing question
« Reply #5 on: December 23, 2019, 02:50:16 pm »
You may need to AC couple the signal to the divider to remove DC offset.   
How can I do that? Using a capacitor in series with the input in my circuit? Which size?
Memento audere semper.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: LTSpice .wave statement and audio file processing question
« Reply #6 on: December 23, 2019, 03:10:21 pm »
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 circuit OUTPUT and 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.

 
The following users thanked this post: Lucky-Luka

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Re: LTSpice .wave statement and audio file processing question
« Reply #7 on: December 23, 2019, 03:57:50 pm »
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.
 
The following users thanked this post: Lucky-Luka

Offline Lucky-LukaTopic starter

  • Supporter
  • ****
  • Posts: 240
  • Country: it
Re: LTSpice .wave statement and audio file processing question
« Reply #8 on: December 23, 2019, 04:16:26 pm »
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
Memento audere semper.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf