Commit 678cd33b authored by Anchal Gupta's avatar Anchal Gupta
Browse files

Added uPDH box model

parent be6f3b87
%% Cell type:markdown id: tags:
***
# Circuit Definition (For reference)
All yellow marked signal ports in the schematic are named as it is in the
zero model without any spaces.
Following are some useful node names to remember:
| Node name | Function/Parameter |
| --- | --- |
| ServoIn | Servo Input.|
| InMon | Input monitor.|
| OutMon | Output Monitor.|
| TP# | Test points in the main signal chain. Eg. TP4.|
| J3A | Servo Input BNC port.|
| J1A | Piezo BNC port.|
The model provides options of setting the variable gain, switching Boost,
and inverter switch.
| Function | What does it do? | Arguments and usage |
| --- | --- | --- |
| VarGain(circuit, Rpot=None, G=None, Vg=None, vb=True, R27=1e3, R26=1e3) | Set variable gain | circuit: 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. |
| Boost(circuit,state) | Switch on or off Boost. | circuit: Circuit object <br>State: 'ON' or 'OFF' |
| Inverter(circuit,state) | Switch on or off inversiont. | circuit: Circuit object <br>State: 'ON' or 'OFF' |
## Importing the circuit definition
%% Cell type:code id: tags:
``` python
from uPDHBox import uPDH, VarGain, Boost, Inverter
from copy import deepcopy
import numpy as np
```
%% Cell type:code id: tags:
``` python
SN01 = deepcopy(uPDH)
```
%% Cell type:markdown id: tags:
***
### Adding anychanges to the circuit:
This is just for example.
%% Cell type:code id: tags:
``` python
SN01['R30'].value=1.1e3
```
%% Cell type:markdown id: tags:
***
### Set variable gain
%% Cell type:code id: tags:
``` python
VarGain(SN01, Rpot=6.6e3)
```
%% Cell type:markdown id: tags:
***
### Switch Boost and/or Inverter
%% Cell type:code id: tags:
``` python
Boost(SN01, 'Off')
Inverter(SN01, 'Off')
```
%% Cell type:markdown id: tags:
### Simulating
%% Cell type:code id: tags:
``` python
from zero.analysis import AcSignalAnalysis
frequencies = np.logspace(-1, 5, 600)
Signal_analysis = AcSignalAnalysis(circuit=SN01)
TFServoInBoff = Signal_analysis.calculate(frequencies=frequencies, input_type="voltage", node="ServoIn")
```
%% Cell type:code id: tags:
``` python
TFServoInBoff.plot_responses(sink='outMon', scale_db=False)
```
%% Cell type:code id: tags:
``` python
Boost(SN01, 'On')
Inverter(SN01, 'off')
```
%% Cell type:code id: tags:
``` python
Signal_analysisBOn = AcSignalAnalysis(circuit=SN01)
TFServoInBon = Signal_analysisBOn.calculate(frequencies=frequencies, input_type="voltage", node="ServoIn")
```
%% Cell type:code id: tags:
``` python
TFServoInBon.plot_responses(sink='outMon', scale_db=False)
```
# HAM-A Coil Drivers
### Zero representation of LIGO HAM-A Coil Drivers
## Purpose
To have a single import point for creating a circuit object which represents
Satellite Amplifier circuit board
[LIGO-D0901351](https://dcc.ligo.org/LIGO-D0901351-v1).
The code is written in jupyter notebook to easily understand the flow of code
and which element (component and nodes) is which. The notebook in the end
writes a script copy of itself which we can import out of this module.
## Documentation
All yellow marked signal ports in the schematic are named as it is in the
zero model without any spaces.
Following are some useful node names to remember:
| Node name | Function/Parameter |
| --- | --- |
| ServoIn | Servo Input.|
| InMon | Input monitor.|
| OutMon | Output Monitor.|
| TP# | Test points in the main signal chain. Eg. TP4.|
| J3A | Servo Input BNC port.|
| J1A | Piezo BNC port.|
The model provides options of setting the variable gain, switching Boost,
and inverter switch.
| Function | What does it do? | Arguments and usage |
| --- | --- | --- |
| VarGain(circuit, Rpot=None, G=None, Vg=None, vb=True, R27=1e3, R26=1e3) | Set variable gain | circuit: 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. |
| Boost(circuit,state) | Switch on or off Boost. | circuit: Circuit object <br>State: 'ON' or 'OFF' |
| Inverter(circuit,state) | Switch on or off inversiont. | circuit: Circuit object <br>State: 'ON' or 'OFF' |
## Contribution
Everyone's contribution towards any bug fixes and additional features are most
welcome but please make your changes in the notebook, save it and use 'restart
and run all' function to generate equivalent script copy. This will ensure that
the notebook and the script do not diverge from each other and we always have
an up-to-date notebook environment to understand the circuit. Thanks!
## Email
Anchal Gupta - anchal@caltech.edu
%% Cell type:code id: tags:
``` python
from zero import Circuit
from zero.components import Resistor, OpAmp
from math import log10
```
%% Cell type:code id: tags:
``` python
# Variable Gain Amplifier. Will be used by changing a0.
AD8336 = {'model': 'AD8336',
'a0': 10, # Nominal 20 dB gain. Will be changed.
'gbw': 80e6,
'vnoise': '3n',
'vcorner': 1e3,
'inoise': '3p',
'icorner': 1e3, # Guess
'vmax': 10,
'imax': 72e-3,
'sr': 550e6}
```
%% Cell type:markdown id: tags:
## Insertion Amplifier Stage
%% Cell type:code id: tags:
``` python
uPDH = Circuit()
uPDH.add_resistor(value=0, name='J3A', node1='ServoIn', node2='J3A')
uPDH.add_resistor(value=0, name='TP1', node1='ServoIn', node2='TP1')
uPDH.add_library_opamp(model='OP27', name='U1', node1='ServoIn', node2='n1', node3='InMon')
uPDH.add_resistor(value=49.9, name='R17', node1='ServoIn', node2='gnd')
uPDH.add_resistor(value=1e3, name='R14', node1='n1', node2='gnd')
uPDH.add_resistor(value=1e3, name='R12', node1='n1', node2='InMon')
uPDH.add_resistor(value=0, name='TP3', node1='InMon', node2='TP3')
```
%% Cell type:markdown id: tags:
## Variable Gain Stage
%% Cell type:code id: tags:
``` python
uPDH.add_component(OpAmp(node1='InMon', node2='gnd',
node3='n2', name='U6', **AD8336))
def VarGain(circuit, Rpot=None, G=None, Vg=None, vb=True,
R27=1e3, R26=1e3):
preAmpGain = 20 * log10(1 + R26/R27)
if Rpot is None: