Diferencia entre revisiones de «Taller de distorsión»

De fabwiki
Ir a la navegación Ir a la búsqueda
Sin resumen de edición
Línea 229: Línea 229:


.control
.control
   pre_shell python3 wavtospice.py clean.wav in.dat
   pre_shell python3 wavtospice.py clean.wav in.dat
   tran 0.02m 10
   tran 0.02m 10

Revisión del 19:39 29 ago 2026

clip

Archivo SPICE (clip.cir)

.title clip
.include 1n4148.lib

v1 sig 0 sin 0 3v 300
r1 sig out 1k
d1 out 0 1n4148

comandos

  • ngspice clip.cir
  • tran 10us 3s
  • plot v(sig) v(out) xlimit 0 10m
  • plot v(sig) v(out)+1 xlimit 0 10m
  • plot v(sig) v(out) 1000*-1*v1#branch xlimit 0 10m

amp 1

Archivo SPICE (amp1.cir)

.title amp1
.include TL072.mod

x1 ninv inv cc ee out TL072

vcc cc 0  15
vee ee 0 -15

v1 sig 0 sin 0 3v 1

r1 sig inv 10k
rfb out inv 10k
rninv ninv 0 1

.control
  tran 1ms 30s
.endc

.end

comandos

  • ngspice amp1.cir
  • plot v(sig) v(out) xlimit 0 3
  • fft v(out)
  • plot mag(v(out)) xlimit 0 10

dist 1

Archivo SPICE (dist1.cir)

.title dist1
.include TL072.mod
.include 1n4148.lib

x1 ninv inv cc ee out TL072

vcc cc 0  15
vee ee 0 -15

v1 sig 0 sin 0 3v 1

r1 sig inv 10k
rfb out inv 10k
d1 inv out 1n4148
d2 out inv 1n4148
rninv ninv 0 1

.control
  tran 1ms 30s
.endc

.end

comandos

  • ngspice dist1.cir
  • plot v(sig) v(out) xlimit 0 3
  • fft v(out)
  • plot mag(v(out)) xlimit 0 10

amp 2

Archivo SPICE (amp2.cir)

.title amp2
.include TL072.mod

x1 ninv inv cc ee out TL072

vcc cc 0  15
vee ee 0 -15

v1 sig 0 sin 0 3v 300

r1 sig inv 10k
rfb out inv 10k
rninv ninv 0 1

.control
  tran 3us 3s
  wrdata out.dat v(out)
.endc

.end

comandos

  • ngspice amp2.cir
  • python spicetowav.py out.dat out.wav (spicetowav.py)

dist 2

Archivo SPICE

.title dist2
.include TL072.mod
.include 1n4148.lib

x1 ninv inv cc ee out TL072

vcc cc 0  15
vee ee 0 -15

v1 sig 0 sin 0 3v 300

r1 sig inv 10k
rfb out inv 10k
d1 inv out 1n4148
d2 out inv 1n4148
rninv ninv 0 1

.control
  tran 3us 3s
  wrdata out.dat v(out)
.endc

.end

comandos

  • ngspice dist2.cir
  • python spicetowav.py out.dat distout.wav


1n4148.cir

.model 1n4148 D(IS=2.5n N=1.9 BV=100 RS=1)

TL072.mod

* TL072 OPERATIONAL AMPLIFIER "MACROMODEL" SUBCIRCUIT
* CREATED USING PARTS RELEASE 4.01 ON 06/16/89 AT 13:08
* (REV N/A)      SUPPLY VOLTAGE: +/-15V
* CONNECTIONS:   NON-INVERTING INPUT
*                | INVERTING INPUT
*                | | POSITIVE POWER SUPPLY
*                | | | NEGATIVE POWER SUPPLY
*                | | | | OUTPUT
*                | | | | |
.SUBCKT TL072    1 2 3 4 5
*
  C1   11 12 3.498E-12
  C2    6  7 15.00E-12
  DC    5 53 DX
  DE   54  5 DX
  DLP  90 91 DX
  DLN  92 90 DX
  DP    4  3 DX
  EGND 99  0 POLY(2) (3,0) (4,0) 0 .5 .5
  FB    7 99 POLY(5) VB VC VE VLP VLN 0 4.715E6 -5E6 5E6 5E6 -5E6
  GA    6  0 11 12 282.8E-6
  GCM   0  6 10 99 8.942E-9
  ISS   3 10 DC 195.0E-6
  HLIM 90  0 VLIM 1K
  J1   11  2 10 JX
  J2   12  1 10 JX
  R2    6  9 100.0E3
  RD1   4 11 3.536E3
  RD2   4 12 3.536E3
  RO1   8  5 150
  RO2   7 99 150
  RP    3  4 2.143E3
  RSS  10 99 1.026E6
  VB    9  0 DC 0
  VC    3 53 DC 2.200
  VE   54  4 DC 2.200
  VLIM  7  8 DC 0
  VLP  91  0 DC 25
  VLN   0 92 DC 25
.MODEL DX D(IS=800.0E-18)
.MODEL JX PJF(IS=15.00E-12 BETA=270.1E-6 VTO=-1)
.ENDS

Archivo de WAV de entrada, WAV de salida

Archivo SPICE (wav_in.cir)

Esta simulación consume el contenido de un archivo se llama clean.wav. Genera un archivo se llama out.wav.

Consulte en el manual de Ngspice

  • 8.2.9 Filesource (PWL sourced from file)
  • 8.1 Code Model Element
  • 8.1.1 %v represents a single-ended voltage port
  • 8.1.1 Square brackets ([ ]) are used to enclose vector input nodes.
  • 13.5.78 General Form: Shell: Call the command interpreter
  • 13.5.56 General Form: Pre_<command>: execute commands prior to parsing the circuit

Necesitas esos archivos en el mismo directorio con el archivo SPICE:

  1. wavtospice.py
  2. spicetowav.py
  3. clean.wav


.title wave input

a1 %v([in]) filesrc

.model filesrc filesource (file="in.dat" amploffset=[0] amplscale=[100] timeoffset=0 timescale=1 timerelative=false amplstep=false)

.model 1n4148 D(IS=2.5n N=1.9 BV=100 RS=1)

r1 in out 1k
d1 out 0 1n4148
d2 0 out 1n4148

.control
  pre_shell python3 wavtospice.py clean.wav in.dat
  tran 0.02m 10
  wrdata out.dat v(out)
  shell python3 spicetowav.py out.dat out.wav
.endc

comandos

Nota: Pasar la opción -b hace que se ejecute y luego finalice. Consulte "12.3 Command line options for starting ngspice" en el manual

  • ngspice -b wav_in.cir

Ahora podés escuchar out.wav.