From: Dan White Date: Mon, 8 Apr 2013 18:04:19 +0000 (-0500) Subject: sine integration start with chip 14 arb0 X-Git-Tag: bootrom-initial-submission~29 X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=4151f0d81363746af3b620f7e62affdf0e0ef52a;p=430.git sine integration start with chip 14 arb0 --- diff --git a/python-lib/arb0-2013-04-08_130324_5.0-005-005.npz b/python-lib/arb0-2013-04-08_130324_5.0-005-005.npz new file mode 100644 index 0000000..a50ffdb Binary files /dev/null and b/python-lib/arb0-2013-04-08_130324_5.0-005-005.npz differ diff --git a/python-lib/arb0-2013-04-08_130324_5.0-005-005.pdf b/python-lib/arb0-2013-04-08_130324_5.0-005-005.pdf new file mode 100644 index 0000000..2a22774 Binary files /dev/null and b/python-lib/arb0-2013-04-08_130324_5.0-005-005.pdf differ diff --git a/python-lib/arb0-2013-04-08_130324_5.0-005-005.yaml b/python-lib/arb0-2013-04-08_130324_5.0-005-005.yaml new file mode 100644 index 0000000..2ca3a67 --- /dev/null +++ b/python-lib/arb0-2013-04-08_130324_5.0-005-005.yaml @@ -0,0 +1,335 @@ +amux: + csname: chain1_mux + otaA: {fast: 0, gain: 0, mode: 4, offset: 0} + otaB: {fast: 0, gain: 0, mode: 4, offset: 0} + selA: 16 + selB: 16 +arb: + csname: chain1_conf + harmonics: + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 1, fast: 0, gain: 15, offset: 117, se: 0, zero: 0} + otaB: {cint: 1, fast: 0, gain: 15, offset: 117, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + - cal: 0 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + otaB: {cint: 0, fast: 0, gain: 0, offset: 0, se: 0, zero: 0} + length: 16 +chain: + csname: chain0_conf + harmonics: + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 46, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 110, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 116, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 108, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 124, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 78, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 106, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 103, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 56, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 85, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 81, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 111, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 59, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 89, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 120, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 80, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 118, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 100, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 111, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 78, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 68, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 94, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 120, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 109, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 60, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 102, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 112, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 97, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 103, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 109, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 81, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 95, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 91, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 116, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 63, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 102, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 63, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 126, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 57, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 102, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 63, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 95, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 72, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 70, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 64, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 90, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 79, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 103, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 86, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 79, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 86, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 116, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 70, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 78, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 92, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 101, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 58, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 91, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 91, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 87, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 117, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 57, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 96, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 79, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 101, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 79, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 123, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 79, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 83, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 102, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 93, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 112, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 127, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 88, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 124, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 64, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 70, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 86, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 93, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 88, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 92, se: 1, zero: 0} + - cal: 1 + nco: {fcw: 0, rst: 0} + otaA: {cint: 0, fast: 1, gain: 0, offset: 106, se: 1, zero: 0} + otaB: {cint: 0, fast: 1, gain: 0, offset: 63, se: 1, zero: 0} + length: 48 +dac: {cs: dac, vbias_buf: 0.0, vbias_core: 0.0, vcmi: 1.24998935546875, vina: 1.24998935546875, + vinb: 1.24998935546875} +date: 2013-04-08_130325 +i2c: {delay: 0.0001, interface: 3, pid: 24593, scl: 0, sda: 1, timeout: 100, vid: 1027} +ibias: {addr: 0, gpo1: 0, gpo2: 0, posA: 128, posB: 128} +isupply: {AVdd_atoi: 0.0020597040039062498, DVdd_ns430: 0.0004111469628906249, Vdd_digi: 0.0203649951171875, + Vdd_ns430: 0.02031919677734375} +mux: + csname: chain0_mux + otaA: {fast: 1, gain: 15, mode: 2, offset: 44} + otaB: {fast: 1, gain: 15, mode: 2, offset: 81} + selA: 48 + selB: 48 +spi0: + cs: + _idle: [-1, 200] + _mask: [-1, 56] + adc: [1, 232] + convst: [1, 248] + dac: [1, 216] + flash: [3, 192] + freq: 1000000.0 + interface: 1 + latency: 1 + pid: 24593 + pindir: 251 + pinstate: 249 + vid: 1027 +spi1: + cs: + _idle: [-1, 248] + _mask: [-1, 248] + chain0_conf: [0, 240] + chain0_mux: [0, 232] + chain1_conf: [0, 216] + chain1_mux: [0, 184] + freq: 1000000.0 + interface: 2 + latency: 1 + pid: 24593 + pindir: 251 + pinstate: 184 + vid: 1027 +v430: + addr: 2 + aliases: {va: vdigi, vb: avdd} + gpo1: 0 + gpo2: 0 + posA: 201 + posB: 159 + va: 1.2008223529411763 + va_range: [0.5015, 1.3887] + vb: 2.5009129411764706 + vb_range: [1.9552, 2.8304] +vatoi: + addr: 2 + aliases: {va: vdigi, vb: avdd} + gpo1: 0 + gpo2: 0 + posA: 201 + posB: 159 + va: 1.2008223529411763 + va_range: [0.5015, 1.3887] + vb: 2.5009129411764706 + vb_range: [1.9552, 2.8304] diff --git a/python-lib/arb0-harmonic.pdf b/python-lib/arb0-harmonic.pdf new file mode 100644 index 0000000..41288ad Binary files /dev/null and b/python-lib/arb0-harmonic.pdf differ diff --git a/python-lib/sine-int.py b/python-lib/sine-int.py new file mode 100644 index 0000000..975235f --- /dev/null +++ b/python-lib/sine-int.py @@ -0,0 +1,273 @@ +#!/usr/bin/env python + +from time import sleep, time + +import IPython +from pylab import * + +import devboard as dev +dev.init_devboard(1) + +# requires devboard be already initialized +#import calibrate as cal +import calibrate +cal = calibrate.calibrate + + +# ?are we already under an IPython shell? +in_ipython = IPython.core.interactiveshell.InteractiveShell.initialized() + +# ?be interactive afterwards? +do_shell = True + + +chain = dev.chain +mux = dev.mux + +arb = dev.arb +amux = dev.amux + +a0 = arb.h[0] + +vina = dev.dac.vina +vinb = dev.dac.vinb +vcmi = dev.dac.vcmi + +dac = dev.dac +adc = dev.adc + + +amux.otaA.mode = amux.otaB.mode = amux.otaA.CAL_CMP +amux.otaA.fast = amux.otaB.fast = 0 +amux.otaA.gain = amux.otaB.gain = 0 +amux.selA = amux.selB = 16 + +amux.write() +######################### + + + + + + + + + + +a0.otaA.fast = 0 +a0.otaA.gain = 15 +a0.otaA.cint = 1 +a0.otaA.offset = 117 + +a0.otaB.fast = 0 +a0.otaB.gain = 15 +a0.otaB.cint = 1 +a0.otaB.offset = 117 + +arb.write() + + +def z(): + a0.otaA.zero = 1 + a0.otaB.zero = 1 + arb.write() + sleep(0.01) + a0.otaA.zero = 0 + a0.otaB.zero = 0 + arb.write() + + +def offset(v): + a0.otaA.offset = v + a0.otaB.offset = v + arb.write() + z() + + + +vios = 0.0 +vcm = 1.25 +vcmi(vcm) +def cal_vios(v): + global vios + vios = v + vina(vcmi() + v) + vinb(vcmi() - v) + z() + +#print '***************************************************************' +#print '***************************************************************' +#print '**** please calibrate a0.otaA, then exit the inner interp *****' +#print '**** please calibrate a0.otaA, then exit the inner interp *****' +#print '**** please calibrate a0.otaA, then exit the inner interp *****' +#print '**** please calibrate a0.otaA, then exit the inner interp *****' +#print '***************************************************************' +#print '***************************************************************' +#IPython.embed() + + +#print '*** calibrating a0 ***' +#cal('a0') + + + + + + +#vina = dev.dac.vina +#vinb = dev.dac.vinb +#vcmi = dev.dac.vcmi + +#arb = dev.arb +#a0 = arb.h[0] + +interactive(True) + + + + + +stime = 74e-6 +fs = 2000.0 + +def cal_sleep(ts, Ns=1): + global stime + global fs + + stime = ts * 1e-6 + samplerate = [] + for i in range(Ns): + Nsamples = 4000 + tstart = time() + for i in range(Nsamples): + d = 1.0 * sin(2*pi + 1.0) * sign(sin(2*pi*5.0)) + vina(1.25) + vinb(1.25) + sleep(stime) + tend = time() + + duration = tend - tstart + samplerate.append(Nsamples / duration) + print '%5.3f, %.1f, %3.0f' % (duration, samplerate[-1], stime*1e6) + fs = mean(samplerate) + print fs + +cal_sleep(74, 4) +#IPython.embed() + + + +adc.triggerMode(dev.adc.MODE_IDLE) +adc.channelMode(6, dev.adc.SE) #even channel only +adc.channelGain(6, 1) +adc.channelGain(7, 1) +adc.mux(6) +adc.triggerMode(dev.adc.MODE_MANUAL_MANUAL) +adc.read() + + +#sine integration +vout = [] +duration = [] + +z() +# from calibration above +#fs = 2000.0 +f0 = 5.0 +Nperiods = 1 + +fh = f0 * 1 +fsin = f0 * 1 + +Nrepeat = 10 + + +amplitude = 2.0 + +tsamps = arange(0, Nperiods / f0, 1.0/fs) +phase = arange(0, Nrepeat*2*pi, 2*pi/16) + + +for ph in phase: + print ph, + dur = 1e10 + while dur > 1.2 * (Nperiods / fsin): + z() + adc.read() + vstart = adc.read() + + tstart = time() + for t in tsamps: + d = amplitude * sin(2*pi*fsin*t + ph) * sign(sin(2*pi*fh*t)) + vina(vcm + vios + d/2, mode=dac.INPUT) + vinb(vcm - vios - d/2) + sleep(stime) + tend = time() + + vina(vcm + vios) + vinb(vcm - vios) + + adc.read() + out = adc.read() + + #save data only if in range + dur = tend - tstart + print '.', + print + + vout.append(out) + duration.append(dur) + + sleep(0.2) + + +def code2v(c): + return c * (2.5 / 2**16) + +vout = array(vout) +vout = code2v(vout) - code2v(vstart) +duration = array(duration) + +#normalize by exact duration +vout = vout * (Nperiods / f0) / duration + + +wrapphase = (phase % (2*pi)) +plot(wrapphase*180/pi, vout, 'x') +xlabel('relative starting phase (deg)') + +ylabel('Vout (V)') +ylim((-0.8, 0.8)) + +title('fh=%5.1f, fin=%5.1f, f0=%3.1f' % (fh, fsin, f0)) + + + + + +if 1: + import datetime as dt + datestr = dt.datetime.now().strftime('%Y-%m-%d_%H%M%S') + + savefig('arb0-%s_%3.1f-%03.0f-%03.0f.pdf' % (datestr, f0, fh, fsin)) + + savez('arb0-%s_%3.1f-%03.0f-%03.0f.npz' % (datestr, f0, fh, fsin), + vout=vout, + duration=duration, + f0=f0, + fh=fh, + fsin=fsin, + phase=phase, + fs=fs, + Nperiods=Nperiods) + + dev.save_config('arb0-%s_%3.1f-%03.0f-%03.0f.yaml' % (datestr, f0, fh, fsin)) + + + +############################################################################## +# drop into an IPython shell +# +if do_shell and not in_ipython: + IPython.embed() +