Commit c511a4ee authored by Lucas Giardino's avatar Lucas Giardino

archivos iniciales

parent 95cb7271
#autogenerated for the liaf variant
core_addr = "192.168.1.75"
device_db = {
"core": {
"type": "local",
"module": "artiq.coredevice.core",
"class": "Core",
"arguments": {"host": core_addr, "ref_period": 1e-09}
},
"core_log": {
"type": "controller",
"host": "::1",
"port": 1068,
"command": "aqctl_corelog -p {port} --bind {bind} " + core_addr
},
"core_cache": {
"type": "local",
"module": "artiq.coredevice.cache",
"class": "CoreCache"
},
"core_dma": {
"type": "local",
"module": "artiq.coredevice.dma",
"class": "CoreDMA"
},
"i2c_switch0": {
"type": "local",
"module": "artiq.coredevice.i2c",
"class": "PCA9548",
"arguments": {"address": 0xe0}
},
"i2c_switch1": {
"type": "local",
"module": "artiq.coredevice.i2c",
"class": "PCA9548",
"arguments": {"address": 0xe2}
},
}
# standalone peripherals
device_db["ttl0"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLInOut",
"arguments": {"channel": 0x000000},
}
device_db["ttl1"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLInOut",
"arguments": {"channel": 0x000001},
}
device_db["ttl2"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLInOut",
"arguments": {"channel": 0x000002},
}
device_db["ttl3"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLInOut",
"arguments": {"channel": 0x000003},
}
device_db["ttl4"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x000004},
}
device_db["ttl5"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x000005},
}
device_db["ttl6"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x000006},
}
device_db["ttl7"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x000007},
}
device_db["eeprom_urukul0"]={
"type": "local",
"module": "artiq.coredevice.kasli_i2c",
"class": "KasliEEPROM",
"arguments": {"port": "EEM1"}
}
device_db["spi_urukul0"]={
"type": "local",
"module": "artiq.coredevice.spi2",
"class": "SPIMaster",
"arguments": {"channel": 0x000008}
}
device_db["ttl_urukul0_io_update"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x000009}
}
device_db["ttl_urukul0_sw0"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x00000a}
}
device_db["ttl_urukul0_sw1"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x00000b}
}
device_db["ttl_urukul0_sw2"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x00000c}
}
device_db["ttl_urukul0_sw3"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x00000d}
}
device_db["urukul0_cpld"] = {
"type": "local",
"module": "artiq.coredevice.urukul",
"class": "CPLD",
"arguments": {
"spi_device": "spi_urukul0",
"sync_device": None,
"io_update_device": "ttl_urukul0_io_update",
"refclk": 125000000.0,
"clk_sel": 2
}
}
device_db["urukul0_ch0"] = {
"type": "local",
"module": "artiq.coredevice.ad9910",
"class": "AD9910",
"arguments": {
"pll_n": 32,
"chip_select": 4,
"cpld_device": "urukul0_cpld",
"sw_device": "ttl_urukul0_sw0"
}
}
device_db["urukul0_ch1"] = {
"type": "local",
"module": "artiq.coredevice.ad9910",
"class": "AD9910",
"arguments": {
"pll_n": 32,
"chip_select": 5,
"cpld_device": "urukul0_cpld",
"sw_device": "ttl_urukul0_sw1"
}
}
device_db["urukul0_ch2"] = {
"type": "local",
"module": "artiq.coredevice.ad9910",
"class": "AD9910",
"arguments": {
"pll_n": 32,
"chip_select": 6,
"cpld_device": "urukul0_cpld",
"sw_device": "ttl_urukul0_sw2"
}
}
device_db["urukul0_ch3"] = {
"type": "local",
"module": "artiq.coredevice.ad9910",
"class": "AD9910",
"arguments": {
"pll_n": 32,
"chip_select": 7,
"cpld_device": "urukul0_cpld",
"sw_device": "ttl_urukul0_sw3"
}
}
device_db["led0"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x00000e}
}
device_db["led1"] = {
"type": "local",
"module": "artiq.coredevice.ttl",
"class": "TTLOut",
"arguments": {"channel": 0x00000f}
}
from artiq.experiment import *
import time
import numpy as np
class MgmtTutorial(EnvExperiment):
"""Management tutorial"""
def build(self):
self.setattr_argument("count", NumberValue(ndecimals=0, step=1))
def run(self):
self.set_dataset("parabola", np.full(self.count, np.nan), broadcast=True)
for i in range(self.count):
self.mutate_dataset("parabola", i, i*i)
time.sleep(1)
from artiq.experiment import *
# EXTRACTED LOOSELY FROM: https://github.com/cnourshargh/Bham-ARTIQ-examples/blob/master/Urukul_SingleOutput.py
class Urukul_Frequency_Pulse(EnvExperiment):
"""Urukul Single Frequency Pulse:
Initial Urukul test:
Outputs a single sine wave of specified frecuency and duration.
"""
def build(self):
# sets core device drivers as attributes
self.setattr_device("core")
# sets urukul0, channel 0 device drivers as attributes
# this name is the same as seen in the device_db.py
self.setattr_device("urukul0_ch0")
# This is not the 'Urukul' phy, but actually is the one corresponding to
# the inside DDS chip, which has the methods described in:
# https://m-labs.hk/artiq/manual-legacy/core_drivers_reference.html#artiq.coredevice.ad9910.AD9910
# BEWARE the manual-legacy thing.
# self.freq = NumberValue(21, unit='MHz', scale=1e6)
self.setattr_argument("freq", NumberValue(21, unit='MHz', scale=1e6))
@kernel
def run(self):
self.core.reset()
# initialises CPLD on channel 0
self.urukul0_ch0.cpld.init()
self.urukul0_ch0.init()
### Variable declaration:
# Defines frequency variable, range: 1 MHz - 400MHz
# defines amplitude variable as an amplitude scale factor(0 to 1)
amp = 1.0
# defines attenuation variable from 0 (no attenuation) to max val (check) -31,5dB
attenuation= 3.0*dB
duration = 10 * (1/self.freq)
delay(10 * ms)
# writes attenuation to urukul channel
self.urukul0_ch0.set_att(attenuation)
#self.urukul0_ch0.set_phase(0.0)
# writes frequency and amplitude variables to urukul channel thus outputting function
self.urukul0_ch0.set(self.freq, amplitude = amp)
# We can access this switch thanks to the entry in this constructor method:
# ...
# sw_device – Name of the RF switch device. The RF switch is a TTLOut channel available as the sw attribute of this instance.
# ...
self.urukul0_ch0.sw.on()
delay(duration)
delay(20*s)
self.urukul0_ch0.sw.off()
delay(duration)
from artiq.experiment import *
class Set_All_Urukul_Freqs(EnvExperiment):
"""Urukul frecuencies setter
Set the frecuencies/amplitudes of every Urukul channel
"""
def build(self):
# sets core device drivers as attributes
self.setattr_device("core")
for ch in range(4):
# sets urukul0, channel 0-3 device drivers as attributes
self.setattr_device(f"urukul0_ch{ch}")
### This two attributes will be shown in the GUI grouped by channel
# use/don't use each channel
self.setattr_argument(f"state_ch{ch}", BooleanValue(ch==0), f"canal_{ch}")
# each channel's frequency
self.setattr_argument(f"freq_ch{ch}",
NumberValue(200.0*MHz, unit='MHz', scale=MHz, min=1*MHz, max=400*MHz),
f"canal_{ch}")
self.all_channels = [self.urukul0_ch0, self.urukul0_ch1, self.urukul0_ch2, self.urukul0_ch3]
self.states = [self.state_ch0, self.state_ch1, self.state_ch2, self.state_ch3]
self.all_freqs = [self.freq_ch0, self.freq_ch1, self.freq_ch2, self.freq_ch3]
self.use_freqs = []
self.use_channels = []
for state, ch_n, freq_n in zip(self.states, self.all_channels, self.all_freqs):
if state:
self.use_channels.append(ch_n)
self.use_freqs.append(freq_n)
@kernel
def run(self):
self.core.reset()
# initialises CPLD all the selected channels
for channel in self.use_channels:
channel.cpld.init()
channel.init()
# defines global amplitude, for all channels
amp = 1.0
# defines attenuation variable from 0 (no attenuation) to max val (check) -31,5dB
attenuation= 3.0*dB
delay(10 * ms)
# attenuation and frecuency to all channels
for channel, freq in zip(self.use_channels, self.use_freqs):
channel.set_att(attenuation)
# writes frequency and amplitude variables to urukul channel thus outputting function
channel.set(freq, amplitude = amp)
# turn on every selected channel
for channel in self.use_channels:
channel.sw.on()
let
# pkgs contains the NixOS package collection. ARTIQ depends on some of them, and
# you may want some additional packages from there.
pkgs = import <nixpkgs> {};
artiq-full = import <artiq-full> { inherit pkgs; };
in
pkgs.mkShell {
buildInputs = [
(pkgs.python3.withPackages(ps: [
# List desired Python packages here.
artiq-full.artiq
artiq-full.artiq-comtools
ps.pandas
ps.numpy
ps.scipy
ps.matplotlib.override { enableQt = true; }
ps.ipython
#ps.spyder # esto lo rompe
]))
#pkgs.spyder # esto lo rompe
pkgs.qt5.full
pkgs.gtkwave # para ver los vcd que saca el artiq
];
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment