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: 32572757820f
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: 9fd4594c5363
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Apr 5, 2015

  1. 1
    Copy the full SHA
    75dfa95 View commit details
  2. Copy the full SHA
    9fd4594 View commit details
Showing with 28 additions and 40 deletions.
  1. +8 −15 artiq/devices/pdq2/driver.py
  2. +6 −0 artiq/test/wavesynth.py
  3. +5 −24 artiq/wavesynth/compute_samples.py
  4. +9 −1 artiq/wavesynth/interpolate.py
23 changes: 8 additions & 15 deletions artiq/devices/pdq2/driver.py
Original file line number Diff line number Diff line change
@@ -6,13 +6,16 @@

import serial

from artiq.wavesynth.interpolate import discrete_compensate


logger = logging.getLogger(__name__)


class Segment:
max_time = 1 << 16 # uint16 timer
max_val = 1 << 15 # int16 DAC
max_out = 10. # Volt
max_out = 10. # Volt
out_scale = max_val/max_out
cordic_gain = 1.
for i in range(16):
@@ -53,24 +56,13 @@ def pack(widths, values):
values, widths, ud, fmt, e)
raise e

@staticmethod
def compensate(coef):
"""compensates higher order spline coefficients for integrator chain
latency"""
order = len(coef)
if order > 2:
coef[1] += coef[2]/2.
if order > 3:
coef[1] += coef[3]/6.
coef[2] += coef[3]
return coef

def bias(self, amplitude=[], **kwargs):
"""Append a bias line to this segment.
Amplitude in volts
"""
coef = self.compensate([self.out_scale*a for a in amplitude])
coef = [self.out_scale*a for a in amplitude]
discrete_compensate(coef)
data = self.pack([0, 1, 2, 2], coef)
self.line(typ=0, data=data, **kwargs)

@@ -83,7 +75,8 @@ def dds(self, amplitude=[], phase=[], **kwargs):
phase[2] in turns*(sample_rate/2**shift)**2
"""
scale = self.out_scale/self.cordic_gain
coef = self.compensate([scale*a for a in amplitude])
coef = [scale*a for a in amplitude]
discrete_compensate(coef)
if phase:
assert len(amplitude) == 4
coef += [p*self.max_val*2 for p in phase]
6 changes: 6 additions & 0 deletions artiq/test/wavesynth.py
Original file line number Diff line number Diff line change
@@ -116,3 +116,9 @@ def drive(self):

def test_run(self):
x, y = self.drive()

@unittest.skip("manual/visual test")
def test_plot(self):
import cairoplot
x, y = self.drive()
cairoplot.scatter_plot("plot.png", [x, y])
29 changes: 5 additions & 24 deletions artiq/wavesynth/compute_samples.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
from copy import copy
from math import cos, pi


def discrete_compensate(c):
if len(c) > 2:
c[1] += c[2]/2
if len(c) > 3:
c[1] += c[3]/6
c[2] += c[3]
return c
from artiq.wavesynth.interpolate import discrete_compensate


class Spline:
def __init__(self):
self.c = [0.0]

def set_coefficients(self, c):
self.c = discrete_compensate(copy(c))
self.c = copy(c)
discrete_compensate(self.c)

def next(self):
r = self.c[0]
@@ -32,7 +26,8 @@ def __init__(self):

def set_coefficients(self, c):
self.c0 = c[0]
self.c[1:] = discrete_compensate(c[1:])
self.c[1:] = c[1:]
discrete_compensate(self.c[1:])

def clear(self):
self.c[0] = 0.0
@@ -128,17 +123,3 @@ def trigger(self):
except StopIteration:
self.line_iter = None
return r


def main():
from artiq.test.wavesynth import TestSynthesizer
import cairoplot

t = TestSynthesizer()
t.setUp()
x, y = t.drive()
cairoplot.scatter_plot("plot.png", [x, y])


if __name__ == "__main__":
main()
10 changes: 9 additions & 1 deletion artiq/wavesynth/interpolate.py
Original file line number Diff line number Diff line change
@@ -23,7 +23,15 @@ def _interpolate(time, data, sample_times, order=3):
return coeffs


def _zip_program(times, channels, target=):
def discrete_compensate(c):
if len(c) > 2:
c[1] += c[2]/2
if len(c) > 3:
c[1] += c[3]/6
c[2] += c[3]


def _zip_program(times, channels, target):
for tc in zip(times, *channels):
yield {
"duration": tc[0],