• Asking for help
  • Generating TTL pulses by running a standard python program.

Hi

I have a Kasli FPGA carrier and an 8-channel SMA TTL card.

According to the manual, I have written a program rtio.py to generate TTL pulses. The program is shown below. To run this program, I need to run "artiq_run rtio.py" in the anaconda command prompt. However, I want to integrate the ARTIQ with the python program I am using to control all the other devices in my experimental setup. I run my python program using either Pycharm/VSCode.

Could you please advise how I can write commands in PyCharm/VSCode to control the artiq? It is necessary to integrate the artiq in the same python program as all other devices in my setup, for the right synchronization and control flow.

Please let me know if this is possible. I would deeply appreciate your help.

Best Regards,
Madhav Gupta

Code for rtio.py:

`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)`

Please edit your forum post to format it correctly.

Read the source code of the artiq_run tool, and implement the same operations in your program.

Hi Sebastian. Thanks a lot for your reply.

Can you please tell me where I can find the source code of the artiq_run tool?

It would really helpful if I can get an example python program if someone has tried to run artiq using python directly before.

Thanks a lot!

Cheers,
Madhav

Hi

Thanks a lot for you reply.

I wanted to request you if you could please send me an example python program? There must be someone who would have tried to use ARTIQ using a standard python interpreter like PyCharm/VSCode before.

I went through the source code of artiq_run.py but I am still quite confused how I can implement all of the same operations in my python program, and then execute rtio.py to generate TTL pulses.

To summarize: I am currently using rtio.py from the manual to generate TTL pulses. To implement it I have to execute "artiq_run rtio,py" from the command terminal. Instead of the running from the command terminal, I want to be able to use standard python commands to control the artiq, so that it can be integrated into the python program which I am using for the whole experimental setup.

I would deeply appreciate it if you could send me an example program, or give me some more guidance on how I can implement the source code of artiq_run.py myself.

Thanks a lot for your help again.

Best Regards,
Madhav Gupta
(HKU)

Since I use ARTIQ through the dashboard and interface with other components from ARTIQ (instead of having a program that needs to use ARTIQ functionality like you describe), I am not too familiar with using ARTIQ through the command line, but wouldn't an easy first step be to call artiq_run with the appropiate experiment in your python program? I see how this might cause some limitations though.

About reimplementing artiq_run: you can see from the source code linked by LTGiardino that when executing artiq_run, the run function is called and sets up the device manager and datasets. After that, it generates the experiment and executes it. So I think you need to reimplement the run function with the libraries supplied by ARTIQ the same way as in the source code.

If there is anything wrong about my view on this, please correct me, I am more used to using ARTIQ with the tools given by M-Labs instead of reimplementing them.