CONNECT_AFG31000
Connect Flojoy to a AFG31000 function generator. The connection is made with the VISA address in the Flojoy UI.
This block should also work with compatible Tektronix AFG31XXX instruments. Params: device : VisaDevice The VISA address to connect to. Returns: device_addr : String The IP or VISA address of the VISA device.
Python Code
from flojoy import VisaDevice, flojoy, String
from flojoy.connection_manager import DeviceConnectionManager
from pyvisa import ResourceManager
from usb.core import USBError
@flojoy
def CONNECT_AFG31000(
device: VisaDevice,
) -> String:
"""Connect Flojoy to a AFG31000 function generator.
The connection is made with the VISA address in the Flojoy UI.
This block should also work with compatible Tektronix AFG31XXX instruments.
Parameters
----------
device: VisaDevice
The VISA address to connect to.
Returns
-------
device_addr: String
The IP or VISA address of the VISA device.
"""
rm = ResourceManager("@py")
addr = device.get_id()
try:
afg = rm.open_resource(addr)
except USBError as err:
raise Exception(
"USB port error. Trying unplugging+replugging the port."
) from err
afg.read_termination = "\n"
afg.write_termination = "\n"
DeviceConnectionManager.register_connection(device, afg)
return String(s=addr)
Videos
Control the AFG31000 Function Generator with Flojoy
Example
Having problems with this example app? Join our Discord community and we will help you out!
In this example, an Tektronix AFG31000 is used to generate two waveforms.
First the necessary blocks were added:
CONNECT_AFG31000
RESET_AFG31000
- 2x
FUNCTION_AFG31000
ALIGN_PHASES_AFG31000
OUTPUT_AFG31000
SAVE_STATE_AFG31000
The instrument address was set for each AFG31000
block. Ensure the OUTPUT_AFG31000
block has both channels turn on.
The blocks were connected as shown and the app was run. The SAVE_STATE_AFG31000
block can be used to save and recall the current state of the AFG. However, you must use a OUTPUT_AFG31000
block to turn the outputs back on.
An oscilloscope was connected to the AFG31000 resulting in waveform: