Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Commit e891a94

Browse files
committed
init
1 parent 5c42871 commit e891a94

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.out

LV.net

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
* Red Pitaya Analog Input
2+
* https://wiki.redpitaya.com/tmp/Fast_analog_inputs_sch.png
3+
* https://forum.redpitaya.com/viewtopic.php?f=9&t=468
4+
5+
C200 Vin Vout 6.8p
6+
C3 Vin Vout 10p
7+
R3 Vin Vout 499k
8+
R5 Vin 0 499k
9+
C206 Vout 0 10p
10+
11+
RL Vout 0 500K
12+
13+
*------- test source ------------
14+
* source resistance
15+
Rs Vs Vin 50
16+
17+
* transient
18+
* V_V1 Vs 0 sin(0.0 1 50MEG 0 0)
19+
20+
* AC freq sweep
21+
V_V1 Vs 0 dc 0. ac 1. sin(0. 1. 100MEG 0 0)
22+
23+
24+
*V_V1 Vin 0 pulse(-0.5 0.5 0 0.1u 0.1u 4.8u 10u)
25+
26+
*--------- freq sweep -------------------------------------
27+
.print ac v(Vin) v(Vout)
28+
.AC DEC 200 100 50MEG > LV.out
29+
30+
*--------- transient ----------------
31+
* .print selects quantities to output
32+
.print tran v(Vin) v(Vout)
33+
*gnucap
34+
*.tran 0.1u 10u 0 trace all > LV.out
35+
36+
*ngspice
37+
*.tran 1u 100u 0
38+
39+
.END

PlotTransfer.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
from pathlib import Path
3+
from numpy import loadtxt,log10
4+
from matplotlib.pyplot import figure,show
5+
import seaborn
6+
seaborn.set_style('whitegrid')
7+
8+
fn = Path('LV.out')
9+
10+
11+
dat = loadtxt(fn)
12+
13+
T = dat[:,2]/dat[:,1]
14+
#%%
15+
ax = figure().gca()
16+
ax.plot(dat[:,0], 20*log10(T))
17+
ax.set_xlabel('frequency [Hz]')
18+
ax.set_ylabel('gain [dB]')
19+
ax.set_title(f'{fn.stem} Transfer Function $H(f)$')
20+
ax.autoscale(True,axis='x',tight=True)
21+
ax.set_xscale('log')

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
# red-pitaya-analog-input-model
22
Red Pitaya analog input SPICE model (GNUcap/ngSPICE compatible)
3+
4+
## Run Simulation
5+
6+
gnucap -b LV.net
7+
8+
## Plot Simulation output
9+
10+
./PlotTransfer.py

0 commit comments

Comments
 (0)