Skip to content

Commit

Permalink
sayma: fix hmc542 to/from mu
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourdeauducq committed Jan 16, 2020
1 parent 37bff3d commit 622dad9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions artiq/coredevice/basemod_att.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
from artiq.coredevice.shiftreg import ShiftReg


@portable
def to_mu(att):
return round(att*2.0) ^ 0x3f

@portable
def from_mu(att_mu):
return 0.5*(att_mu ^ 0x3f)


class BaseModAtt:
def __init__(self, dmgr, rst_n, clk, le, mosi, miso):
self.rst_n = dmgr.get(rst_n)
Expand Down Expand Up @@ -58,7 +67,7 @@ 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))
self.set_mu(to_mu(att0), to_mu(att1), to_mu(att2), to_mu(att3))

@kernel
def get(self):
Expand All @@ -67,4 +76,4 @@ def get(self):
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
return from_mu(att0), from_mu(att1), from_mu(att2), from_mu(att3)

0 comments on commit 622dad9

Please sign in to comment.