Getting Started
Prerequisites
Using ARDI requires an installation of Python. We have tested ARDI with Python 3.12, but it can be expected to work with earlier versions of Python 3 as well. That said, if you encounter any issues using ARDI with earlier versions of Python, please try updating Python first. Python is pre-installed on many systems by default. To verify that Python is available, open a terminal and run:
python --version
If the desired version is not installed on your system, you can download Python from the official website. Alternatively, on Windows, Python can be installed with the winget
tool from the terminal:
winget install -e --id Python.Python.3.12
Installation
The ARDI Python package can be downloaded from our releases page. The package is distributed as a tarball, for example, ardi_py.0.3.1.tar.gz
, which can be installed using pip
- Python’s package manager:
pip install ardi_py.0.3.1.tar.gz
Note that the above command must be run from the directory containing the downloaded tarball. Alternatively, you can always provide the full path to the file, for example:
pip install ~/Downloads/ardi_py.0.3.1.tar.gz
On some systems you may need to use python3
instead of python
and pip3
instead of pip
. Using virtual environments can help simplify this.
Once installed, ARDI can be run from the command line as an interactive Python session with the following command:
python -i -m ardi
With no power supply connected, launching ARDI this way will produce an error, but is a useful way to test the installation. To close an interactive Python session, run the exit()
command. On Windows, you may also press Ctrl+Z
followed by Enter
to exit. On other systems, simply Ctrl+Z
or Ctrl+D
will suffice.
Virtual Environments (Optional)
Dependency management for multiple projects is a common source of headaches in Python. If you have multiple versions of Python installed, or use the same Python installation for numerous projects, it may beneficial to use a virtual environments to manage dependencies. For more information on this topic, please refer to Python’s documentation on virtual environments.
To create a virtual environment, run the following command, specifying the path where you would like to create the environment:
python -m venv path/to/myenv
Then, to activate the virtual environment, run:
source path/to/myenv/bin/activate
Once activated, you can install ARDI as described above. To deactivate the virtual environment, simply run:
deactivate
Please note that the virtual environment will have to be re-activated when eg. opening a new terminal window or restarting the computer. To avoid this, you can add the source path/to/myenv/bin/activate
command to your shell configuration file, such as .bashrc
or .zshrc
.
Define an Alias (Optional)
The command python -i -m ardi
can be used to start an interactive session with ARDI. If using this tool often, it may be helpful to create an alias for it in your shell configuration file, such as .bashrc
or .zshrc
. To create an alias called ardi
that runs the above command, add the following line to your shell configuration file:
alias ardi='python -i -m ardi'
Don’t forget to restart the terminal or source the configuration file after making changes to it:
source ~/.bashrc
Now, you should be able to start an interactive session with ARDI by simply running:
ardi
Interactive Usage
The command python -i -m ardi
can be used to start an interactive session with ARDI. If using this tool often, it may be helpful to create an alias for it in your shell configuration file, such as .bashrc
or .zshrc
. To create an alias called ardi
that runs the above command, add the following line to your shell configuration file:
alias ardi='python -i -m ardi'
Don’t forget to restart the terminal or source the configuration file after making changes to it:
source ~/.bashrc
To start an interactive session with ARDI, first connect and turn on the power supply. Then, open a terminal and run:
python -i -m ardi
Or, simply ardi
if you have defined an alias as described above.
This will connect to the first device it detects, bind it to the variable psu
, and then provide an interactive prompt through which to control it. When loaded in this way, ARDI will also read all available channels from the device, and bind them to matching variables, for example rail
, ch1
, ch2
, etc. for unipolar firmware, or rail
, ch12
, ch34
, etc. for bipolar firmware. To replicate this behavior within your own scripts, call psu.autoconfig()
like below:
import ardi
psu = ardi.autoconnect()
psu.autoconfig() # bind all channel objects to matching global variables
# eg. the channel named 'ch1' will be bound to the variable 'ch1'
# Note that the python linter will complain about undefined variables. It is wrong.
However, when scripting, it is better practice to manually bind the channels to variables like so:
import ardi
psu = ardi.autoconnect() # connect to the power supply
ch1 = psu.ch(1) # define channel 1
ch2 = psu.ch(2) # define channel 2
# etc.
# note that variable names aren't required to match!
x = psu.ch(3)
When using ARDI, we can interact with each output channel or with the power supply itself through these objects. For example, to check the firmware version of the power supply, we could run:
psu.ask('firmware')
Or, to read a channel’s voltage monitor:
ch1.ask('v_mon')
The full set of commands available for each channel type is documented in the Parameters page.
To close an interactive Python session, run the exit()
command. On Windows, you may also press Ctrl+Z
followed by Enter
to exit. On other systems, simply Ctrl+Z
or Ctrl+D
will suffice.
Scripting
ARDI can also be used normally as a Python library. This enables the usage of scripts to define more complex behaviors. Consider the following script, example.py
, which is meant to be run with the unipolar firmware:
import ardi
psu = ardi.autoconnect() # connect to the power supply
ch1 = psu.ch(1) # define channel 1
ch2 = psu.ch(2) # define channel 2
# define a function to output two unipolar sinusoids
# on channels A and B, separated by a phase delay
def pattern(psu, chA, chB, freq, amp, phase):
chA.sin(freq, amp)
chB.sin(freq, amp, phase)
# call the function to output the pattern on channels 1 and 2
pattern(ch1, ch2, 10, 5000, 180)
This script loads the ARDI library, defines a function pattern
that outputs two sinusoids on channels A and B with a phase delay, and then if run directly, calls the function with the power supply handle, channels 1 and 2, a frequency of 10 Hz, an amplitude of 5 kV, and a phase delay of 180 degrees. Assuming this script is saved as example.py
, it can be run from the terminal:
python example.py
Scripting with Multiple Power Supplies
ARDI scripts can be used to interact with multiple power supplies simultaneously. To do this, you will need to know the serial number of each power supplys internal microcontroller. This can most easily be found using a utility called tyCommander. These numbers are unique to each device.
import ardi
psu1 = ardi.connect(1234567) # connect to the power supply with serial number 1234567
psu2 = ardi.connect(7654321) # connect to the power supply with serial number 7654321
ch1_1 = psu1.ch(1) # define channel 1 on the first power supply
ch1_2 = psu2.ch(1) # define channel 1 on the second power supply
Hardware Setup
Please continue reading the hardware setup guide for information on connecting the power supply to your computer and actuators.