basemod_att: add dB functions, document

This commit is contained in:
Sebastien Bourdeauducq 2019-12-21 14:56:41 +08:00
parent 5ff164b385
commit 6639d9443d
2 changed files with 33 additions and 1 deletions

View File

@ -11,7 +11,7 @@ class BaseModAtt:
@kernel @kernel
def reset(self): def reset(self):
# HMC's incompetence in digital design an interfaces means that # HMC's incompetence in digital design and interfaces means that
# the HMC542 needs a level low on RST_N and then a rising edge # the HMC542 needs a level low on RST_N and then a rising edge
# on Latch Enable. Their "latch" isn't a latch but a DFF. # on Latch Enable. Their "latch" isn't a latch but a DFF.
# Of course, it also powers up with a random attenuation, and # Of course, it also powers up with a random attenuation, and
@ -27,6 +27,11 @@ class BaseModAtt:
@kernel @kernel
def set_mu(self, att0, att1, att2, att3): def set_mu(self, att0, att1, att2, att3):
"""
Sets the four attenuators on BaseMod.
The values are in half decibels, between 0 (no attenuation)
and 63 (31.5dB attenuation).
"""
word = ( word = (
(att0 << 2) | (att0 << 2) |
(att1 << 10) | (att1 << 10) |
@ -37,9 +42,29 @@ class BaseModAtt:
@kernel @kernel
def get_mu(self): def get_mu(self):
"""
Retrieves the current settings of the four attenuators on BaseMod.
"""
word = self.shift_reg.get() word = self.shift_reg.get()
att0 = (word >> 2) & 0x3f att0 = (word >> 2) & 0x3f
att1 = (word >> 10) & 0x3f att1 = (word >> 10) & 0x3f
att2 = (word >> 18) & 0x3f att2 = (word >> 18) & 0x3f
att3 = (word >> 26) & 0x3f att3 = (word >> 26) & 0x3f
return att0, att1, att2, att3 return att0, att1, att2, att3
@kernel
def set(self, att0, att1, att2, att3):
"""
Sets the four attenuators on BaseMod.
The values are in decibels.
"""
self.set_mu(round(att0*2.0), round(att1*2.0), round(att2*2.0), round(att3*2.0))
@kernel
def get(self):
"""
Retrieves the current settings of the four attenuators on BaseMod.
The values are in decibels.
"""
att0, att1, att2, att3 = self.get_mu()
return 0.5*att0, 0.5*att1, 0.5*att2, 0.5*att3

View File

@ -112,6 +112,13 @@ RF generation drivers
:members: :members:
:mod:`artiq.coredevice.basemod_att` module
++++++++++++++++++++++++++++++++++++++++++
.. automodule:: artiq.coredevice.basemod_att
:members:
DAC/ADC drivers DAC/ADC drivers
--------------- ---------------