Skip to content

PROLOGIX_MODE

Set the control mode of the Prologix USB-to-GPIB controller. 1 for CONTROLLER mode and 0 for DEVICE mode. If the device is stuck with the LISTEN light on, unplug the device from the instrument and PC, and plug back into the computer. Run this Block to change into CONTROLLER mode. You may have to repeat unplugging and replugging into the computer. From the Prologix manual: ` In Controller mode, the GPIB-USB Controller acts as the Controller-In-Charge (CIC) on the GPIB bus. When the controller receives a command over the USB port terminated by the USB terminator - CR (ASCII 13) or LF (ASCII 10) - it addresses the GPIB instrument at the currently specified address (See ++addr command) to listen, and passes along the received data. In Device mode, Prologix GPIB-USB Controller acts as another peripheral on the GPIB bus. In this mode, the controller can act as a GPIB TALKER or GPIB LISTENER only. Since Prologix GPIB-USB Controller is not the Controller-In-Charge while in this mode, it expects to receive commands from a GPIB controller. When Device mode is enabled Prologix GPIB-USB controller configures itself as a GPIB Listener. All data received by the controller over the GPIB port is passed along to the USB port without buffering. ` Requires an OPEN_SERIAL block. Params: connection : Serial The open serial connection with the instrument. mode : select Choose the operation mode for the Prologix adapter. Returns: out : String Response from the Prologix USB-to-GPIB controller.
Python Code
import serial
from flojoy import flojoy, SerialConnection, DataContainer, String
from typing import cast, Optional, Literal


@flojoy(inject_connection=True)
def PROLOGIX_MODE(
    connection: SerialConnection,
    default: Optional[DataContainer] = None,
    mode: Literal["CONTROLLER", "DEVICE"] = "CONTROLLER",
) -> String:
    """Set the control mode of the Prologix USB-to-GPIB controller.

    1 for CONTROLLER mode and 0 for DEVICE mode.

    If the device is stuck with the LISTEN light on, unplug the device from
    the instrument and PC, and plug back into the computer. Run this Block
    to change into CONTROLLER mode. You may have to repeat unplugging and
    replugging into the computer.

    From the Prologix manual:

    `
    In Controller mode, the GPIB-USB Controller acts as the
    Controller-In-Charge (CIC) on the GPIB bus. When the controller receives a
    command over the USB port terminated by the USB terminator - CR (ASCII 13)
    or LF (ASCII 10) - it addresses the GPIB instrument at the currently
    specified address (See ++addr command) to listen, and passes along the
    received data.

    In Device mode, Prologix GPIB-USB Controller acts as another peripheral on
    the GPIB bus. In this mode, the controller can act as a GPIB TALKER or GPIB
    LISTENER only. Since Prologix GPIB-USB Controller is not the
    Controller-In-Charge while in this mode, it expects to receive commands
    from a GPIB controller. When Device mode is enabled Prologix GPIB-USB
    controller configures itself as a GPIB Listener. All data received by the
    controller over the GPIB port is passed along to the USB port without
    buffering.
    `

    Requires an OPEN_SERIAL block.

    Parameters
    ----------
    connection: Serial
        The open serial connection with the instrument.
    mode: select
        Choose the operation mode for the Prologix adapter.

    Returns
    -------
    String
        Response from the Prologix USB-to-GPIB controller.
    """

    # Start serial communication with the instrument
    ser = cast(serial.Serial, connection.get_handle())

    if ser is None:
        raise ValueError("Serial communication is not open")

    mode_integer = 0
    if mode == "CONTROLLER":
        mode_integer = 1

    cmd = "++mode " + str(mode_integer) + "\n"
    ser.write(cmd.encode())

    s = ser.read(256)

    return String(s)

Find this Flojoy Block on GitHub

Videos

Control Agilent 34410A multimeter with Flojoy

Example

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

This app prepares the Prologix GPIB-USB adapter for use with a VISA instrument. The user can then send a SCPI command to a VISA instrument using the GPIB-USB adapter.

Parameters:

  • Connection on all of the Blocks should be the COM port of the adapter.
  • PROLOGIX AUTO: auto = off
  • PROLOGIX MODE: mode = CONTROLLER
  • PROLOGIX EOI: EOI = true, EOS = None (instrument dependent)
  • GPIB address should match the instrument’s (see the instrument’s manual on how to find it)
  • OPEN SERIAL: writing “*IDN?” with bytes encoding and a LF terminator

This app has two rows that are run seperately:

  1. The top, setup, row with AUTO, MODE and EOI blocks.
  2. The bottom row with WRITE and READ.

The two constants on the bottom left control which row runs. If they are equal, the setup row runs. Otherwise, the read/write row runs. The setup should be run before connecting the adapter to the instrument.

Note that the PROLOGIX READ should be used to recieve a response from the instrument. The AUTO mode can be turned on which recieves a response upon every command (PROLOGIX AUTO block controls this setting). However, this causes errors in some VISA instruments.