Skip to content

Commit

Permalink
Merge branch 'soft-amp-models' into flux-jump
Browse files Browse the repository at this point in the history
  • Loading branch information
bengineerd committed Oct 26, 2023
2 parents ea6d210 + 3c4d9bf commit 754b461
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion firmware/python/warm_tdm/_Amplifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def __init__(self, **kwargs):
linkedGet = self.rout))

def gain(self):
ret = self.FbR.value() / self.InputR.value()
ret = self.FbR.value() / (self.InputR.value())
if self.Invert.value() is True:
ret = ret * -1
return ret
Expand Down
3 changes: 3 additions & 0 deletions firmware/python/warm_tdm/_ColumnModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,21 @@ def __init__(self,
self.add(warm_tdm.FastDacDriver(
name = 'SAFb',
offset = 0xC0600000,
shunt = 7.15e3,
rows = rows,
))

self.add(warm_tdm.FastDacDriver(
name = 'SQ1Bias',
offset = 0xC0400000,
shunt = 10.0e3,
rows = rows,
))

self.add(warm_tdm.FastDacDriver(
name = 'SQ1Fb',
offset =0xC0500000,
shunt = 11.3e3,
rows = rows,
))

Expand Down
8 changes: 4 additions & 4 deletions firmware/python/warm_tdm/_FastDacDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def setVoltage(self, value, index, write):

class FastDacDriver(pr.Device):

def __init__(self, rows, **kwargs):
def __init__(self, shunt, rows, **kwargs):
super().__init__(**kwargs)

self.rows = rows
Expand All @@ -83,8 +83,8 @@ def __init__(self, rows, **kwargs):
for i in range(8):
self.add(warm_tdm.FastDacAmplifierSE(
name = f'Amp[{i}]',
defaults = {'Invert': True},
hidden = True))
defaults = {'Invert': True, 'ShuntR': shunt, 'FbR': 4.7e3},
hidden = False))


for col in range(8):
Expand Down Expand Up @@ -138,7 +138,7 @@ def _overCurrentSet(value, index, write, x=col):
# Voltage Conversion
####################
def _overVoltageGet(index, read, x=col):
ret = self.Amp[x].dacToOutCurrent(self.OverrideRaw[x].value())
ret = self.Amp[x].dacToOutVoltage(self.OverrideRaw[x].value())
#print(f'_overGet - OverrideRaw[{x}].value() = {self.OverrideRaw[x].value()} - voltage = {voltage}')
return ret

Expand Down
2 changes: 1 addition & 1 deletion firmware/python/warm_tdm/_HardwareGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(
rows=rows))

pidDebug = [warm_tdm.PidDebugger(name=f'PidDebug[{i}]', hidden=False, col=i, fastDacDriver=self.ColumnBoard[index].SQ1Fb) for i in range(8)]
waveGui = warm_tdm.WaveformCaptureReceiver(hidden=False, amplifier=self.ColumnBoard[index].amplifiers)
waveGui = warm_tdm.WaveformCaptureReceiver(hidden=False, amplifiers=self.ColumnBoard[index].amplifiers)

# Link the data stream to the DataWriter
if emulate is False:
Expand Down
12 changes: 6 additions & 6 deletions firmware/python/warm_tdm/_WaveformCapture.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ def _get(*, read, index, check):

class WaveformCaptureReceiver(pr.Device, rogue.interfaces.stream.Slave):

def __init__(self, amplifier, **kwargs):
def __init__(self, amplifiers, **kwargs):
rogue.interfaces.stream.Slave.__init__(self)
pr.Device.__init__(self, **kwargs)

self.amplifier = amplifier
self.amplifiers = amplifiers

def _conv(adc):
return adc/2**13
Expand Down Expand Up @@ -285,7 +285,7 @@ def _conv(adc):
disp = '{:0.3f}',
guiGroup = 'RmsNoiseAmpInX',
dependencies = [self.RmsNoiseVADC[i]],
linkedGet = lambda read, ch=i: self.amplifier[ch].ampVin(self.RmsNoiseVADC[ch].get(read=read), 0.0)))
linkedGet = lambda read, ch=i: self.amplifiers[ch].ampVin(self.RmsNoiseVADC[ch].get(read=read), 0.0)))

for i in range(8):
def _getPkPk(read, x=i):
Expand Down Expand Up @@ -325,7 +325,7 @@ def _getAvg(read, x=i):
# disp = '{:0.3f}',
mode = 'RO',
guiGroup = 'AmpInConvFactor',
variable = self.amplifier[i].AmpInConvFactor))
variable = self.amplifiers[i].AmpInConvFactor))


self.add(MultiPlot(
Expand Down Expand Up @@ -373,7 +373,7 @@ def _acceptFrame(self, frame):
if channel >= 8:
for sample in range(len(voltages)):
for ch in range(len(voltages[0])):
ampVin[sample, ch] = self.loading.ampVin(voltages[sample, ch], 0.0, ch)
ampVin[sample, ch] = self.amplifiers[ch].ampVin(voltages[sample, ch], 0.0)

d = {ch: {
'ADC Counts': adcs[:,ch],
Expand All @@ -384,7 +384,7 @@ def _acceptFrame(self, frame):
else:
print(f'Setting data for channel {channel}')
for sample in range(len(voltages)):
ampVin[sample, channel] = self.loading.ampVin(voltages[sample, channel], 0.0, channel)
ampVin[sample] = self.amplifiers[channel].ampVin(voltages[sample], 0.0)

d[channel]['ADC Counts'] = adcs
d[channel]['V@ADC'] = voltages
Expand Down
2 changes: 1 addition & 1 deletion software/python/warm_tdm_api/_Group.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def __init__(self, groupConfig, groupId, dataWriter, simulation=False, emulate=F
self.add(pr.LocalVariable(
name='NumRows',
description='Total number of rows in the Group. NumRowBoards * 32.',
value=len(self.config.rowMap),
value=self.config.numRows,
mode='RO',
groups='TopApi'))

Expand Down
2 changes: 2 additions & 0 deletions software/python/warm_tdm_api/_Mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def __init__(self, *, rowBoards, columnBoards, host, rowOrder=None):

self.numColumns = len(self.columnMap)
self.numRows = len(self.rowMap)
if self.numRows == 0:
self.numRows = 1

self.rowOrder = rowOrder
if self.rowOrder is None:
Expand Down
10 changes: 7 additions & 3 deletions software/python/warm_tdm_api/_Sq1Tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _plot_ax(self, ax, col, row, curves):
def linkedGet(self, index=-1, read=False):
tune = self.parent.Sq1TuneOutput.value()

if tune == {}:
if tune == {} or tune == []:
return self._fig


Expand All @@ -39,8 +39,10 @@ def linkedGet(self, index=-1, read=False):
else:
col, row = index

# shunts = [self.parent.Loading.Column[x].SQ1_FB_SHUNT_R.value() for x in range(8)]
print(f'Sq1TunePlot - {row=}, {col=}')

# shunts = [self.parent.Loading.Column[x].SQ1_FB_SHUNT_R.value() for x in range(8)]

self._plot_ax(self._ax, col, row, tune[row][col])

return self._fig
Expand All @@ -61,7 +63,7 @@ def linkedGet(self, index=-1):
tune = self.parent.Sq1TuneOutput.value()
# shunt = self.parent.parent.SQ1_FB_SHUNT_R.value()

if tune == {}:
if tune == {} or tune == []:
return self._fig

if index == -1:
Expand Down Expand Up @@ -258,6 +260,8 @@ def _sq1TuneWrap(self):
with self.root.updateGroup(0.25):
ret = warm_tdm_api.sq1Tune(group=self.parent, process=self)
self.Sq1TuneOutput.set(value = [[col.asDict() for col in row] for row in ret])
print('SQ1Tune Output')
print(self.Sq1TuneOutput.value())

def _saveData(self,arg):
print(f"Sq1Tune - Save data called with {arg=}")
Expand Down
6 changes: 4 additions & 2 deletions software/python/warm_tdm_api/_Tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def saTune(*, group, process=None, doSet=True):
"""
# group.Init()

group.RowTuneIndex.set(0)
#group.RowTuneIndex.set(0)
#group.RowTuneMode.set(True)
saBiasResults = saBiasSweep(group=group,process=process)

Expand Down Expand Up @@ -373,7 +373,7 @@ def sq1FbSweep(*, group, bias, fbRange, row, process):
Iterates through Sq1Fb values determined by lowoffset,
highoffset,step. Generates curve points with saOffset()
"""

print(f'sq1FbSweep({bias=}, {fbRange=}, {row=})')
colCount = len(group.ColumnMap.get())
curves = [warm_tdm_api.Curve(bias[i]) for i in range(colCount)]
numSteps = len(fbRange[0])
Expand Down Expand Up @@ -414,6 +414,8 @@ def sq1BiasSweep(group, row, process):

# Extract iteration steps from Rogue variables
# Create CurveData obects for storing output data
print(f'saBiasSweep({row=})')

colCount = len(group.ColumnMap.get())
numBiasSteps = process.Sq1BiasNumSteps.get()
numFbSteps = process.Sq1FbNumSteps.get()
Expand Down

0 comments on commit 754b461

Please sign in to comment.