Hi,

I am trying to understand the workings of ARTIQ-SINARA by running some simple codes and seeing their outputs. I am facing a problem with our SINARA TTL ports. None of the 8 ports work as either input or output.

When I try to generate a pulse through the TTL and measure it on a picoscope, I get a flat voltage line of nearly 1V.

The code is as follows:

from artiq.experiment import *

class Tutorial(EnvExperiment):
    def build(self):
        self.setattr_device("core")
        self.setattr_device("ttl0")

    @kernel
    def run(self):
        self.core.reset()
        self.ttl0.output()
        for i in range(1000000):
            delay(2*us)
            self.ttl0.pulse(2*us)

Also, the LEDs on the TTL panel are always in the IN mode and not the OUT mode.

I tried to see if at least the input is working or not by using the TTL ports as a trigger to generate a RF signal using the urukul module (This module works as I have tried a separate code to generate RF signals of a given frequency and attenuation). Here is the code:

from artiq.experiment import *

class TTL_Input_As_Trigger(EnvExperiment):
    """TTL Input Edge as Trigger"""
    def build(self):

        self.setattr_device("core")
        self.setattr_device("ttl0")
        self.setattr_device("urukul0_ch3")
        
    @kernel #this code runs on the FPGA
    def run(self):
        self.core.reset()
        
        self.ttl0.input()
        self.core.reset()
        self.urukul0_ch3.cpld.init()
        self.urukul0_ch3.init()

        delay(2*us)
        
        freq1 = 2*MHz
        attenuation = 30.

        t_end = self.ttl0.gate_rising(10*ms)
        t_edge = self.ttl0.timestamp_mu(t_end)  #sets variable t_edge as time(in MUs) at which first edge is detected
                                                #if no edge is detected, sets t_edge to -1
        print(t_edge)

        if t_edge > 0:
            self.urukul0_ch3.sw.on()
            self.urukul0_ch3.set(freq1, phase = 0.0)
            self.urukul0_ch3.set_att(attenuation)
            delay(2*ms)
            # self.urukul0_ch3.sw.off()

        self.ttl0.count(t_end)

The print statement is always -1. I have tried with all the InOut ttl ports (ttl0 - 3). I even made a small change in the device_db and made the ttl4-7 ports from Out to InOut and checked them as well. I kept the code at ttl0 and checked with all the other ports as well. Nothing seems to work. The LEDs are still in the IN mode.

I don't know what to do now or how to proceed. Any help will be greatly appreciated. If any more information is required, I can provide it.

Thanks in advance.

    5 days later

    AadityaR I even made a small change in the device_db and made the ttl4-7 ports from Out to InOut and checked them as well.

    Your device database needs to be in sync with the gateware. Maybe this is your initial problem.

      sb10q How do we do that?

      Here is my device_db file for reference.

      # Autogenerated for the wien variant
      core_addr = "10.34.16.100"
      
      device_db = {
          "core": {
              "type": "local",
              "module": "artiq.coredevice.core",
              "class": "Core",
              "arguments": {
                  "host": core_addr,
                  "ref_period": 1e-09,
                  "analyzer_proxy": "core_analyzer",
                  "target": "rv32g",
                  "satellite_cpu_targets": {}
              },
          },
          "core_log": {
              "type": "controller",
              "host": "::1",
              "port": 1068,
              "command": "aqctl_corelog -p {port} --bind {bind} " + core_addr
          },
          "core_moninj": {
              "type": "controller",
              "host": "::1",
              "port_proxy": 1383,
              "port": 1384,
              "command": "aqctl_moninj_proxy --port-proxy {port_proxy} --port-control {port} --bind {bind} " + core_addr
          },
          "core_analyzer": {
              "type": "controller",
              "host": "::1",
              "port_proxy": 1385,
              "port": 1386,
              "command": "aqctl_coreanalyzer_proxy --port-proxy {port_proxy} --port-control {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": "I2CSwitch",
              "arguments": {"address": 0xe0}
          },
          "i2c_switch1": {
              "type": "local",
              "module": "artiq.coredevice.i2c",
              "class": "I2CSwitch",
              "arguments": {"address": 0xe2}
          },
      }
      
      # standalone peripherals
      
      device_db["eeprom_urukul0"] = {
          "type": "local",
          "module": "artiq.coredevice.kasli_i2c",
          "class": "KasliEEPROM",
          "arguments": {"port": "EEM0"}
      }
      
      device_db["spi_urukul0"] = {
          "type": "local",
          "module": "artiq.coredevice.spi2",
          "class": "SPIMaster",
          "arguments": {"channel": 0x000000}
      }
      
      device_db["ttl_urukul0_sync"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLClockGen",
          "arguments": {"channel": 0x000001, "acc_width": 4}
      }
      
      device_db["ttl_urukul0_io_update"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000002}
      }
      
      device_db["ttl_urukul0_sw0"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000003}
      }
      
      device_db["ttl_urukul0_sw1"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000004}
      }
      
      device_db["ttl_urukul0_sw2"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000005}
      }
      
      device_db["ttl_urukul0_sw3"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000006}
      }
      
      device_db["urukul0_cpld"] = {
          "type": "local",
          "module": "artiq.coredevice.urukul",
          "class": "CPLD",
          "arguments": {
              "spi_device": "spi_urukul0",
              "sync_device": "ttl_urukul0_sync",
              "io_update_device": "ttl_urukul0_io_update",
              "refclk": 125000000.0,
              "clk_sel": 2,
              "clk_div": 0
          }
      }
      
      device_db["urukul0_ch0"] = {
          "type": "local",
          "module": "artiq.coredevice.ad9910",
          "class": "AD9910",
          "arguments": {
              "pll_n": 32,
              "pll_en": 1,
              "chip_select": 4,
              "cpld_device": "urukul0_cpld",
              "sw_device": "ttl_urukul0_sw0",
              "sync_delay_seed": "eeprom_urukul0:64",
              "io_update_delay": "eeprom_urukul0:64"
          }
      }
      
      device_db["urukul0_ch1"] = {
          "type": "local",
          "module": "artiq.coredevice.ad9910",
          "class": "AD9910",
          "arguments": {
              "pll_n": 32,
              "pll_en": 1,
              "chip_select": 5,
              "cpld_device": "urukul0_cpld",
              "sw_device": "ttl_urukul0_sw1",
              "sync_delay_seed": "eeprom_urukul0:68",
              "io_update_delay": "eeprom_urukul0:68"
          }
      }
      
      device_db["urukul0_ch2"] = {
          "type": "local",
          "module": "artiq.coredevice.ad9910",
          "class": "AD9910",
          "arguments": {
              "pll_n": 32,
              "pll_en": 1,
              "chip_select": 6,
              "cpld_device": "urukul0_cpld",
              "sw_device": "ttl_urukul0_sw2",
              "sync_delay_seed": "eeprom_urukul0:72",
              "io_update_delay": "eeprom_urukul0:72"
          }
      }
      
      device_db["urukul0_ch3"] = {
          "type": "local",
          "module": "artiq.coredevice.ad9910",
          "class": "AD9910",
          "arguments": {
              "pll_n": 32,
              "pll_en": 1,
              "chip_select": 7,
              "cpld_device": "urukul0_cpld",
              "sw_device": "ttl_urukul0_sw3",
              "sync_delay_seed": "eeprom_urukul0:76",
              "io_update_delay": "eeprom_urukul0:76"
          }
      }
      
      device_db["spi_sampler0_adc"] = {
          "type": "local",
          "module": "artiq.coredevice.spi2",
          "class": "SPIMaster",
          "arguments": {"channel": 0x000007}
      }
      device_db["spi_sampler0_pgia"] = {
          "type": "local",
          "module": "artiq.coredevice.spi2",
          "class": "SPIMaster",
          "arguments": {"channel": 0x000008}
      }
      device_db["ttl_sampler0_cnv"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000009},
      }
      device_db["sampler0"] = {
          "type": "local",
          "module": "artiq.coredevice.sampler",
          "class": "Sampler",
          "arguments": {
              "spi_adc_device": "spi_sampler0_adc",
              "spi_pgia_device": "spi_sampler0_pgia",
              "cnv_device": "ttl_sampler0_cnv",
              "hw_rev": "v2.2"
          }
      }
      
      device_db["ttl0"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLInOut",
          "arguments": {"channel": 0x00000a},
      }
      
      device_db["ttl1"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLInOut",
          "arguments": {"channel": 0x00000b},
      }
      
      device_db["ttl2"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLInOut",
          "arguments": {"channel": 0x00000c},
      }
      
      device_db["ttl3"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLInOut",
          "arguments": {"channel": 0x00000d},
      }
      
      device_db["ttl4"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x00000e},
      }
      
      device_db["ttl5"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x00000f},
      }
      
      device_db["ttl6"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000010},
      }
      
      device_db["ttl7"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000011},
      }
      
      device_db["spi_mirny0"]={
          "type": "local",
          "module": "artiq.coredevice.spi2",
          "class": "SPIMaster",
          "arguments": {"channel": 0x000012}
      }
      
      device_db["ttl_mirny0_sw0"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000013}
      }
      
      device_db["ttl_mirny0_sw1"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000014}
      }
      
      device_db["ttl_mirny0_sw2"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000015}
      }
      
      device_db["ttl_mirny0_sw3"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000016}
      }
      
      device_db["mirny0_ch0"] = {
          "type": "local",
          "module": "artiq.coredevice.adf5356",
          "class": "ADF5356",
          "arguments": {
              "channel": 0,
              "sw_device": "ttl_mirny0_sw0",
              "cpld_device": "mirny0_cpld",
          }
      }
      
      device_db["mirny0_almazny0"] = {
          "type": "local",
          "module": "artiq.coredevice.almazny",
          "class": "AlmaznyChannel",
          "arguments": {
              "host_mirny": "mirny0_cpld",
              "channel": 0,
          },
      }
      
      device_db["mirny0_ch1"] = {
          "type": "local",
          "module": "artiq.coredevice.adf5356",
          "class": "ADF5356",
          "arguments": {
              "channel": 1,
              "sw_device": "ttl_mirny0_sw1",
              "cpld_device": "mirny0_cpld",
          }
      }
      
      device_db["mirny0_almazny1"] = {
          "type": "local",
          "module": "artiq.coredevice.almazny",
          "class": "AlmaznyChannel",
          "arguments": {
              "host_mirny": "mirny0_cpld",
              "channel": 1,
          },
      }
      
      device_db["mirny0_ch2"] = {
          "type": "local",
          "module": "artiq.coredevice.adf5356",
          "class": "ADF5356",
          "arguments": {
              "channel": 2,
              "sw_device": "ttl_mirny0_sw2",
              "cpld_device": "mirny0_cpld",
          }
      }
      
      device_db["mirny0_almazny2"] = {
          "type": "local",
          "module": "artiq.coredevice.almazny",
          "class": "AlmaznyChannel",
          "arguments": {
              "host_mirny": "mirny0_cpld",
              "channel": 2,
          },
      }
      
      device_db["mirny0_ch3"] = {
          "type": "local",
          "module": "artiq.coredevice.adf5356",
          "class": "ADF5356",
          "arguments": {
              "channel": 3,
              "sw_device": "ttl_mirny0_sw3",
              "cpld_device": "mirny0_cpld",
          }
      }
      
      device_db["mirny0_almazny3"] = {
          "type": "local",
          "module": "artiq.coredevice.almazny",
          "class": "AlmaznyChannel",
          "arguments": {
              "host_mirny": "mirny0_cpld",
              "channel": 3,
          },
      }
      
      device_db["mirny0_cpld"] = {
          "type": "local",
          "module": "artiq.coredevice.mirny",
          "class": "Mirny",
          "arguments": {
              "spi_device": "spi_mirny0",
              "refclk": 125000000.0,
              "clk_sel": "mmcx"
          },
      }
      
      device_db["led0"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000017}
      }
      
      device_db["led1"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000018}
      }
      
      device_db["led2"] = {
          "type": "local",
          "module": "artiq.coredevice.ttl",
          "class": "TTLOut",
          "arguments": {"channel": 0x000019}
      }

      I even tried running the artiq_sinara_tester but the TTL ports do not work as either input or output. I even reflashed the system but to no avail.

        AadityaR How do we do that?

        You want to be sure that the gateware/firmware you are flashing with was generated for the correct system configuration (one that matches your device database and physical configuration). See for example this section of the manual.

          architeuthis You want to be sure that the gateware/firmware you are flashing with was generated for the correct system configuration (one that matches your device database and physical configuration).

          Yes. the system description file I used was the one directly provided by M-Labs for our variant. I even verified it by using the afws_client get_json command.

          In spite of reflashing the SINARA, the lights corresponding to the TTL4-7 are stuck in the IN mode.

          However, TTL0-3 started working as Inputs after the reflashing, which they weren't before.

          srenblad
          Yes, this solved the problem. the bottom ones were in the IN switch position which is why the TTL ports were not working as outputs. Reversing the switches made them work.

          Thanks a lot for the solution!