mirror of https://github.com/m-labs/artiq.git
interpolate: refactor discrete_compensate
This commit is contained in:
parent
75dfa95b4d
commit
9fd4594c53
|
@ -6,6 +6,9 @@ import struct
|
|||
|
||||
import serial
|
||||
|
||||
from artiq.wavesynth.interpolate import discrete_compensate
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -53,24 +56,13 @@ class Segment:
|
|||
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 @@ class Segment:
|
|||
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]
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
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]
|
||||
from artiq.wavesynth.interpolate import discrete_compensate
|
||||
|
||||
|
||||
class Spline:
|
||||
|
|
|
@ -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],
|
||||
|
|
Loading…
Reference in New Issue