Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 07ceed9512e5
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7d3acf4d1009
Choose a head ref
  • 4 commits
  • 19 files changed
  • 1 contributor

Commits on Jun 26, 2015

  1. Copy the full SHA
    e6a4c2f View commit details
  2. Copy the full SHA
    c71fe29 View commit details

Commits on Jun 27, 2015

  1. Copy the full SHA
    a7bbcdc View commit details
  2. Copy the full SHA
    7d3acf4 View commit details
4 changes: 1 addition & 3 deletions artiq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from artiq.language.core import *
from artiq.language.experiment import Experiment
from artiq.language.db import *
from artiq.language.units import check_unit
from artiq.language.units import ps, ns, us, ms, s
from artiq.language.units import Hz, kHz, MHz, GHz
from artiq.language.units import *
6 changes: 1 addition & 5 deletions artiq/coredevice/core.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
from artiq.language.units import ns

from artiq.transforms.inline import inline
from artiq.transforms.lower_units import lower_units
from artiq.transforms.quantize_time import quantize_time
from artiq.transforms.remove_inter_assigns import remove_inter_assigns
from artiq.transforms.fold_constants import fold_constants
@@ -61,13 +60,10 @@ def build(self):

def transform_stack(self, func_def, rpc_map, exception_map,
debug_unparse=_no_debug_unparse):
lower_units(func_def, rpc_map)
debug_unparse("lower_units", func_def)

remove_inter_assigns(func_def)
debug_unparse("remove_inter_assigns_1", func_def)

quantize_time(func_def, self.ref_period.amount)
quantize_time(func_def, self.ref_period)
debug_unparse("quantize_time", func_def)

fold_constants(func_def)
10 changes: 5 additions & 5 deletions artiq/coredevice/dds.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
from artiq.language.units import *


PHASE_MODE_DEFAULT = -1
_PHASE_MODE_DEFAULT = -1
# keep in sync with dds.h
PHASE_MODE_CONTINUOUS = 0
PHASE_MODE_ABSOLUTE = 1
@@ -104,17 +104,17 @@ def set_phase_mode(self, phase_mode):
self.phase_mode = phase_mode

@kernel
def set(self, frequency, phase_mode=PHASE_MODE_DEFAULT, phase_offset=0):
def set(self, frequency, phase=0, phase_mode=_PHASE_MODE_DEFAULT):
"""Sets the DDS channel to the specified frequency and phase.
:param frequency: frequency to generate.
:param phase: adds an offset, in turns, to the phase.
:param phase_mode: if specified, overrides the default phase mode set
by ``set_phase_mode`` for this call.
:param phase_offset: adds an offset, in turns, to the phase.
"""
if phase_mode == PHASE_MODE_DEFAULT:
if phase_mode == _PHASE_MODE_DEFAULT:
phase_mode = self.phase_mode

syscall("dds_set", time_to_cycles(now()), self.channel,
self.frequency_to_ftw(frequency), round(phase_offset*2**14),
self.frequency_to_ftw(frequency), round(phase*2**14),
phase_mode)
24 changes: 5 additions & 19 deletions artiq/devices/lda/driver.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import ctypes
import struct

from artiq.language.units import dB, check_unit, Quantity
from artiq.language.units import dB


logger = logging.getLogger("lda")
@@ -47,22 +47,15 @@ def set_attenuation(self, attenuation):
"""

step = self.get_att_step_size()

if isinstance(attenuation, Quantity):
check_unit(attenuation, "dB")
att = attenuation
else:
att = attenuation*dB

att = round(att/step)*step
att = round(attenuation/step)*step

if att > self.get_att_max():
raise ValueError("Cannot set attenuation {} > {}"
.format(att, self.get_att_max()))
elif att < 0*dB:
raise ValueError("Cannot set attenuation {} < 0".format(att))
else:
att = round(att.amount*4)/4. * dB
att = round(att*4)/4. * dB
self._attenuation = att

def ping(self):
@@ -218,22 +211,15 @@ def set_attenuation(self, attenuation):
"""

step = self.get_att_step_size()

if isinstance(attenuation, Quantity):
check_unit(attenuation, "dB")
att = attenuation
else:
att = attenuation*dB

att = round(att/step)*step
att = round(attenuation/step)*step

if att > self.get_att_max():
raise ValueError("Cannot set attenuation {} > {}"
.format(att, self.get_att_max()))
elif att < 0*dB:
raise ValueError("Cannot set attenuation {} < 0".format(att))
else:
self.set(0x8d, bytes([int(round(att.amount*4))]))
self.set(0x8d, bytes([int(round(att*4))]))

def ping(self):
try:
33 changes: 13 additions & 20 deletions artiq/devices/thorlabs_tcube/driver.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

import serial

from artiq.language.units import V, strip_unit
from artiq.language.units import V


logger = logging.getLogger(__name__)
@@ -302,7 +302,7 @@ def ping(self):
class Tpz(Tcube):
def __init__(self, serial_dev):
Tcube.__init__(self, serial_dev)
self.voltage_limit = self.get_tpz_io_settings()[0].amount
self.voltage_limit = self.get_tpz_io_settings()[0]

def handle_message(self, msg):
msg_id = msg.id
@@ -372,8 +372,6 @@ def set_output_volts(self, voltage):
between the three values 75 V, 100 V and 150 V.
"""

voltage = strip_unit(voltage, "V")

if voltage < 0 or voltage > self.voltage_limit:
raise ValueError("Voltage must be in range [0;{}]"
.format(self.voltage_limit))
@@ -390,7 +388,7 @@ def get_output_volts(self):

get_msg = self.send_request(MGMSG.PZ_REQ_OUTPUTVOLTS,
[MGMSG.PZ_GET_OUTPUTVOLTS], 1)
return st.unpack("<H", get_msg.data[2:])[0]*self.voltage_limit*V/32767
return st.unpack("<H", get_msg.data[2:])[0]*self.voltage_limit/32767

def set_output_position(self, position_sw):
"""Set output position of the piezo actuator.
@@ -532,7 +530,6 @@ def set_output_lut(self, lut_index, output):
<artiq.devices.thorlabs.driver.Tpz.set_tpz_io_settings>` method.
"""

output = strip_unit(output, "V")
volt = round(output*32767/self.voltage_limit)
payload = st.pack("<HHH", 1, lut_index, volt)
self.send(Message(MGMSG.PZ_SET_OUTPUTLUT, data=payload))
@@ -548,7 +545,7 @@ def get_output_lut(self):
get_msg = self.send_request(MGMSG.PZ_REQ_OUTPUTLUT,
[MGMSG.PZ_GET_OUTPUTLUT], 1)
(index, output) = st.unpack("<Hh", get_msg.data[2:])
return index, output*self.voltage_limit*V/32767
return index, output*self.voltage_limit/32767

def set_output_lut_parameters(self, mode, cycle_length, num_cycles,
delay_time, precycle_rest, postcycle_rest):
@@ -684,9 +681,6 @@ def set_tpz_io_settings(self, voltage_limit, hub_analog_input):
100 V limit.
150 V limit.
You can either provide this parameter as an integer or as a
:class:`artiq.language.units` Volt quantity (e.g. 75*V).
:param hub_analog_input: When the T-Cube piezo driver unit is used in
conjunction with the T-Cube Strain Gauge Reader (TSG001) on the
T-Cube Controller Hub (TCH001), a feedback signal can be passed
@@ -706,7 +700,7 @@ def set_tpz_io_settings(self, voltage_limit, hub_analog_input):
connectors.
"""

self.voltage_limit = strip_unit(voltage_limit, "V")
self.voltage_limit = voltage_limit

if self.voltage_limit == 75:
voltage_limit = 1
@@ -727,21 +721,21 @@ def get_tpz_io_settings(self):
Hub analog input. Refer to :py:meth:`set_tpz_io_settings()
<artiq.devices.thorlabs.driver.Tpz.set_tpz_io_settings>` for the
meaning of those parameters.
:rtype: a 2 elements tuple (Quantity, int)
:rtype: a 2 elements tuple (int, int)
"""

get_msg = self.send_request(MGMSG.PZ_REQ_TPZ_IOSETTINGS,
[MGMSG.PZ_GET_TPZ_IOSETTINGS], 1)
voltage_limit, hub_analog_input = st.unpack("<HH", get_msg.data[2:6])
if voltage_limit == 1:
voltage_limit = 75*V
voltage_limit = 75
elif voltage_limit == 2:
voltage_limit = 100*V
voltage_limit = 100
elif voltage_limit == 3:
voltage_limit = 150*V
voltage_limit = 150
else:
raise ValueError("Voltage limit should be in range [1; 3]")
self.voltage_limit = voltage_limit.amount
self.voltage_limit = voltage_limit
return voltage_limit, hub_analog_input


@@ -1398,14 +1392,13 @@ def get_tpz_display_settings(self):
return self.intensity

def set_tpz_io_settings(self, voltage_limit, hub_analog_input):
self.voltage_limit = strip_unit(voltage_limit, "V")

if self.voltage_limit not in [75, 100, 150]:
if voltage_limit not in [75, 100, 150]:
raise ValueError("voltage_limit must be 75 V, 100 V or 150 V")
self.voltage_limit = voltage_limit
self.hub_analog_input = hub_analog_input

def get_tpz_io_settings(self):
return self.voltage_limit*V, self.hub_analog_input
return self.voltage_limit, self.hub_analog_input


class TdcSim:
3 changes: 1 addition & 2 deletions artiq/gui/moninj.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@

from artiq.tools import TaskObject
from artiq.protocols.sync_struct import Subscriber
from artiq.language.units import strip_unit


logger = logging.getLogger(__name__)
@@ -170,7 +169,7 @@ def __setitem__(self, k, v):
if (v["module"] == "artiq.coredevice.dds"
and v["class"] == "DDS"):
channel = v["arguments"]["channel"]
sysclk = strip_unit(v["arguments"]["sysclk"], "Hz")
sysclk = v["arguments"]["sysclk"]
self.dds_widgets[channel] = _DDSWidget(
self.send_to_device, channel, sysclk, k)
self.dds_cb()
2 changes: 1 addition & 1 deletion artiq/language/core.py
Original file line number Diff line number Diff line change
@@ -231,7 +231,7 @@ def time_to_cycles(time, core=None):
"""
if core is None:
raise ValueError("Core device must be specified for time conversion")
return round64(time.amount//core.ref_period)
return round64(time//core.ref_period)


def cycles_to_time(cycles, core=None):
Loading