ExampleUse.ipynb 4.48 KB
Newer Older
Anchal Gupta's avatar
Anchal Gupta committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "***\n",
    "# Circuit Definition (For reference)\n",
    "All yellow marked signal ports in the schematic are named as it is in the\n",
    "zero model without any spaces.\n",
    "Following are some useful node names to remember:\n",
    "\n",
    "|\tNode name\t|\tFunction/Parameter\t|\n",
    "|\t---\t|\t---\t|\n",
    "| ServoIn | Servo Input.|\n",
    "| InMon | Input monitor.|\n",
    "| OutMon | Output Monitor.|\n",
    "| TP# | Test points in the main signal chain. Eg. TP4.|\n",
    "| J3A | Servo Input BNC port.|\n",
    "| J1A | Piezo BNC port.|\n",
    "\n",
    "The model provides options of setting the variable gain, switching Boost,\n",
    "and inverter switch.\n",
    "\n",
    "|\tFunction\t|\tWhat does it do?\t|\tArguments and usage\t|\n",
    "|\t---\t|\t---\t|\t---\t|\n",
    "|\tVarGain(circuit, Rpot=None, G=None, Vg=None, vb=True, R27=1e3, R26=1e3)\t|\tSet variable gain\t|\tcircuit: Circuit object <br>Rpot:R7 potentiometer setting in Ohms (0-10kOhms)<br>Vg:Gain setting voltage<br>vb: verbose<br><br>R27, R26: Resitors associated to preamplifier again in AD8336.<br>One only needs to provide one of arguments Rpot, G, or Vg.\t|\n",
    "|\tBoost(circuit,state)\t|\tSwitch on or off Boost. |\tcircuit: Circuit object <br>State: 'ON' or 'OFF'\t|\n",
    "|\tInverter(circuit,state)\t|\tSwitch on or off inversiont. |\tcircuit: Circuit object <br>State: 'ON' or 'OFF'\t|\n",
    "\n",
    "## Importing the circuit definition"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from uPDHBox import uPDH, VarGain, Boost, Inverter\n",
    "from copy import deepcopy\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "SN01 = deepcopy(uPDH)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "***\n",
    "### Adding anychanges to the circuit:\n",
    "This is just for example."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "SN01['R30'].value=1.1e3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "***\n",
    "### Set variable gain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "VarGain(SN01, Rpot=6.6e3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "***\n",
    "### Switch Boost and/or Inverter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Boost(SN01, 'Off')\n",
    "Inverter(SN01, 'Off')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Simulating"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from zero.analysis import AcSignalAnalysis\n",
    "\n",
    "frequencies = np.logspace(-1, 5, 600)\n",
    "Signal_analysis = AcSignalAnalysis(circuit=SN01)\n",
    "TFServoInBoff = Signal_analysis.calculate(frequencies=frequencies, input_type=\"voltage\", node=\"ServoIn\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "TFServoInBoff.plot_responses(sink='outMon', scale_db=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Boost(SN01, 'On')\n",
    "Inverter(SN01, 'off')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Signal_analysisBOn = AcSignalAnalysis(circuit=SN01)\n",
    "TFServoInBon = Signal_analysisBOn.calculate(frequencies=frequencies, input_type=\"voltage\", node=\"ServoIn\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "TFServoInBon.plot_responses(sink='outMon', scale_db=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}