Skip to content

Anapico

Bases: VisaDriver

A driver for controlling Anapico signal generators via the VISA interface.

This class provides methods to control and query the Anapico signal generators, including setting and querying the frequency, power, and RF state of a specified channel.

Parameters:

Name Type Description Default
resource_location str

The VISA resource name used to connect to the device.

required

Initialize the Anapico object with the specified resource location.

The constructor configures the communication termination character as a newline character.

Parameters:

Name Type Description Default
resource_location str

The VISA resource name used to connect to the device.

required
Source code in driverlib/anapico/anapico.py
16
17
18
19
20
21
22
23
24
def __init__(self, resource_location: str):
    """Initialize the Anapico object with the specified resource location.

    The constructor configures the communication termination character as a newline character.

    Args:
        resource_location (str): The VISA resource name used to connect to the device.
    """
    super().__init__(resource_location, "\n")

idn property

idn

Retrieve the identification string.

Returns:

Name Type Description
str str

The identification string of the device.

close

close()

Close the connection to the device.

Source code in driverlib/visa_driver.py
114
115
116
def close(self):
    """Close the connection to the device."""
    self.rm.close()

get_error

get_error()

Retrieve the error message from the device.

Returns:

Name Type Description
str

The error message.

Source code in driverlib/visa_driver.py
127
128
129
130
131
132
133
def get_error(self):
    """Retrieve the error message from the device.

    Returns:
        str: The error message.
    """
    return self.ask("SYST:ERR?")

print_error

print_error()

Print eventual errors occurred.

Source code in driverlib/visa_driver.py
135
136
137
def print_error(self):
    """Print eventual errors occurred."""
    print(f"Errors: {self.get_error()}", end="")

reset

reset()

Reset instrument to factory default state. Does not clear volatile memory.

Source code in driverlib/visa_driver.py
139
140
141
142
def reset(self):
    """Reset instrument to factory default state. Does not clear volatile memory."""
    self.write("*RST")
    self.write("*WAI")

clear

clear()

Clear event register, error queue -when power is cycled-.

Source code in driverlib/visa_driver.py
144
145
146
147
def clear(self):
    """Clear event register, error queue -when power is cycled-."""
    self.write("*CLS")
    self.write("*WAI")

lookup_resources

lookup_resources()

Look for all the available resources.

Source code in driverlib/visa_driver.py
149
150
151
152
153
154
155
156
157
158
159
160
def lookup_resources(self):
    """Look for all the available resources."""
    instruments = self.rm.list_resources()
    print(f"Found {len(instruments)} instruments:")
    for location in instruments:
        try:
            with OpenResource(self.rm, location, self.endline) as instr:
                idn = instr.query("*IDN?")
        except VisaIOError:
            idn = None

        print(f"Resource named: {idn if idn else 'Unable to determine'} @ '{location}'")

get_frequency

get_frequency(channel)

Query the frequency of a specified channel.

Parameters:

Name Type Description Default
channel

The channel number.

required

Returns:

Name Type Description
float

The frequency of the specified channel in Hz.

Source code in driverlib/anapico/anapico.py
26
27
28
29
30
31
32
33
34
35
def get_frequency(self, channel):
    """Query the frequency of a specified channel.

    Args:
        channel: The channel number.

    Returns:
        float: The frequency of the specified channel in Hz.
    """
    return float(self.ask(f":SOURce{int(channel)}:FREQuency:CW?"))

set_frequency

set_frequency(channel, value)

Set the frequency of a specified channel.

Parameters:

Name Type Description Default
channel

The channel number.

required
value

The desired frequency in Hz.

required

Returns:

Name Type Description
self

Returns the instance itself to allow for method chaining.

Source code in driverlib/anapico/anapico.py
37
38
39
40
41
42
43
44
45
46
47
48
def set_frequency(self, channel, value):
    """Set the frequency of a specified channel.

    Args:
        channel: The channel number.
        value: The desired frequency in Hz.

    Returns:
        self: Returns the instance itself to allow for method chaining.
    """
    self.write(f":SOURce{int(channel)}:FREQuency:CW {float(value)}")
    return self

get_power

get_power(channel)

Query the power of a specified channel.

Parameters:

Name Type Description Default
channel

The channel number.

required

Returns:

Name Type Description
float

The power of the specified channel in dBm.

Source code in driverlib/anapico/anapico.py
52
53
54
55
56
57
58
59
60
61
def get_power(self, channel):
    """Query the power of a specified channel.

    Args:
        channel: The channel number.

    Returns:
        float: The power of the specified channel in dBm.
    """
    return float(self.ask(f":SOURce{int(channel)}:POWER?"))

set_power

set_power(channel, value)

Set the power of a specified channel.

Parameters:

Name Type Description Default
channel

The channel number.

required
value

The desired power in dBm. The Anapico cannot output less than -10 dBm.

required

Returns:

Name Type Description
self

Returns the instance itself to allow for method chaining.

Raises:

Type Description
ValueError

If the specified power value is less than -10 dBm.

Source code in driverlib/anapico/anapico.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def set_power(self, channel, value):
    """Set the power of a specified channel.

    Args:
        channel: The channel number.
        value: The desired power in dBm. The Anapico cannot output less than -10 dBm.

    Returns:
        self: Returns the instance itself to allow for method chaining.

    Raises:
        ValueError: If the specified power value is less than -10 dBm.
    """
    if value < -10:
        raise ValueError("Anapico cannot output less than -10 dBm")
    self.write(f":SOURce{int(channel)}:POWER {float(value)}")
    return self

get_rf_state

get_rf_state(channel)

Query the RF output state of a specified channel.

Parameters:

Name Type Description Default
channel

The channel number.

required

Returns:

Name Type Description
int

1 if the RF output is enabled (on), 0 if disabled (off).

Source code in driverlib/anapico/anapico.py
83
84
85
86
87
88
89
90
91
92
def get_rf_state(self, channel):
    """Query the RF output state of a specified channel.

    Args:
        channel: The channel number.

    Returns:
        int: 1 if the RF output is enabled (on), 0 if disabled (off).
    """
    return int(self.ask(f"OUTPut{int(channel)}:STATE?")[:1])

set_rf_state

set_rf_state(channel, state)

Sets the RF output state of a specified channel.

Parameters:

Name Type Description Default
channel

The channel number.

required
state

The desired state. True to enable (on) the RF output, False to disable (off).

required

Returns:

Name Type Description
self

Returns the instance itself to allow for method chaining.

Source code in driverlib/anapico/anapico.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
def set_rf_state(self, channel, state):
    """Sets the RF output state of a specified channel.

    Args:
        channel: The channel number.
        state: The desired state. True to enable (on) the RF output, False to disable (off).

    Returns:
        self: Returns the instance itself to allow for method chaining.
    """
    if state is True:
        state = "ON"
    else:
        state = "OFF"
    self.write(f"OUTPut{int(channel)}:STATE {state}")
    return self