Thanks to visit codestin.com
Credit goes to pkg.go.dev

prologix

package module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 6 Imported by: 3

README

prologix

Go package to communicate with either a Prologix GPIB-ETHERNET (GPIB-LAN) controller or a GPIB-USB (HPIB-USB) controller.

GoDoc Go Report Card License Badge

Overview

Prologix offers two GPIB controllers that enable a computer to communicate over GPIB using either an Ethernet or USB interface. Both the GPIB-ETHERNET controller and the GPIB-USB controller can operate either in controller mode or device mode. In controller mode, the GPIB-ETHERNET or GPIB-USB is the Controller-In-Charge (CIC) on the GPIB bus. In device mode, the GPIB-ETHERNET or GPIB-USB acts a GPIB device that is either a talker or a listener.

For more information, please see the User Manual and FAQ for either the GPIB-ETHERNET controller or the GPIB-USB controller.

Status

  • GPIB-USB Direct Driver: Not implemented
  • GPIB Controller Mode: Implemented. Provide an io.ReadWriter from a serial port to use the Prologix GPIB-USB Controller as a Virtual COM Port (VCP) or provide an io.ReadWriter from a network connection to use the Proglogix GPIB-ETHERNET Controller.
  • GPIB Device Mode: Not implemented

IVI Support

The prologix package can be used in conjunction with the ivi package, which is a Go-based implementation of the Interchangeable Virtual Instrument (IVI) standard. The IVI Specifications developed by the IVI Foundation provide standardized APIs for programming test instruments.

The main advantage of using the ivi package is not having to learn the SCPI commands for each individual piece of test equipment. For instance, both the Agilent 33220A function generator and the Stanford Research Systems DS345 function generator can be programmed using one standard API with IVI.

Methods for Communication

The Prologix GPIB controller strips all unescaped LF (\n, ASCII 10), CR (\r, ASCII 13), ESC (ASCII 27), and + (ASCII 43) characters. Therefore, to send binary data including one of those characters, they must be escaped.

  • Read(p []byte) (n int, err error) — Use for reading binary or text data from the instrument or Prologix controller.
  • Write(p []byte) (n int, err error) — Use to send binary data to the instrument. The CR, LF, ESC, and + characters will be automatically escaped.
  • WriteString(s string) (n int, err error — Use to send ASCII data to the instrument or commands to the Prologix controller.
  • Command(format string, a ...interface{}) error — Use to send a SCPI command to the instrument that has no response. A newline character will automatically be appended to the SCPI command sent to the instrument.
  • Query(cmd string) (string, error) — Use to send a SCPI query command to the instrument and receive a string response. A newline character will automatically be appended to the SCPI command sent to the instrument. If the Prologix controller is not in auto read-after-write mode, then a ++read eos will also be sent before reading.

GPIB-USB

The GPIB-USB controller communicates with a computer either directly using the D2XX driver or as a Virtual COM Port (VCP) using the FTDI FT245R driver.

GPIB-USB VCP Driver Installation

The appropriate VCP driver for your operating system can be downloaded from the FTDI VCP Drivers webpage. Alternatively, on macOS you can use Homebrew to install the VCP driver as follows:

$ brew cask install ftdi-vcp-driver
GPIB-USB D2XX Direct Driver Installation

The appropriate D2XX Direct Driver for your operating system can be downloaded from the FTDI D2XX Direct Drivers webpage. Alternatively, on macOS you can use Homebrew to install the D2XX direct driver as follows:

$ brew install libftdi

Contributing

To contribute, please fork the repository, create a feature branch, and then submit a pull request.

License

prologix is released under the MIT license. Please see the LICENSE.txt file for more information.

Documentation

Overview

Package prologix communicates with either the Prologix GPIB-USB or GPIB-ETHERNET controller. Communication with the GPIB-USB controller can either be via the FTDI Virtual COM Port (VCP) driver or via the FTDI D2XX direct driver. The Prologix GPIB controller can operate as a GPIB Controller-in-Charge (CIC), a GPIB Talker Device, or a GPIB Listener Device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller models a GPIB controller-in-charge.

func NewController

func NewController(rw io.ReadWriter, addr int, clear bool) (*Controller, error)

NewController creates a GPIB controller-in-charge at the given address using the given Prologix driver, which can either be a Virtual COM Port (VCP), USB direct, or Ethernet. Enable clear to send the Selected Device Clear (SDC) message to the GPIB address.

func (*Controller) AssertEOI added in v0.2.0

func (c *Controller) AssertEOI() (bool, error)

AssertEOI determines if the Prologix controller is configured to assert the EOI signal at the end of any command sent over the GPIB port.

func (*Controller) ClearDevice added in v0.2.0

func (c *Controller) ClearDevice() error

ClearDevice sends the `clr` command to the Prologix controller which sends the Selected Device Clear (SDC) message to the currently selected GPIB address.

func (*Controller) ClearInterface added in v0.2.0

func (c *Controller) ClearInterface() error

ClearInterface sends the `ifc` command to the Prologix controller which asserts the GPIB Interface Clear (IFC) signal for 150 microseconds making the Prologix GPIB controller the Controller-In-Charge.

func (*Controller) Command

func (c *Controller) Command(format string, a ...any) error

Command formats according to a format specifier if provided and sends a SCPI/ASCII command to the instrument at the currently assigned GPIB address. All leading and trailing whitespace is removed before appending the USB terminator to the command sent to the Prologix.

func (*Controller) CommandController added in v0.3.0

func (c *Controller) CommandController(cmd string) error

CommandController sends the given command to the Prologix controller. To indicate this is a command for the Prologix controller, thereby not transmitting to the instrument over GPIB, two plus signs `++` are prepended. Addtionally, a new line is appended to act as the USB termination character.

func (*Controller) FrontPanel

func (c *Controller) FrontPanel(enable bool) error

FrontPanel enables or disables front panel operation for the instrument at the current GPIB address. This is accomplished by either sending the Prologix `loc` local command to enable the front panel or by sending the Prologix `llo` local lockout command to disable the front panel.

func (*Controller) GPIBTermination added in v0.2.0

func (c *Controller) GPIBTermination() (GpibTerm, error)

GPIBTermination uses the Prologix `eos` command to query the GPIB terminator.

func (*Controller) InstrumentAddress

func (c *Controller) InstrumentAddress() (int, error)

InstrumentAddress returns the GPIB address for the instrument under control.

func (*Controller) Query

func (c *Controller) Query(cmd string) (string, error)

Query queries the instrument at the currently assigned GPIB using the given SCPI/ASCII command. The cmd string does not need to include a new line character, since all leading and trailing whitespace is removed before appending the USB terminator to the command sent to the Prologix. When data from host is received over USB, the Prologix controller removes all non-escaped LF, CR and ESC characters and appends the GPIB terminator, as specified by the `eos` command, before sending the data to instruments. To change the GPIB terminator use the SetGPIBTermination method.

func (*Controller) QueryController added in v0.3.0

func (c *Controller) QueryController(cmd string) (string, error)

QueryController sends the given command to the Prologix controller and returns its response as a string. To indicate this is a command for the Prologix controller, thereby not transmitting over GPIB, two plus signs `++` are prepended. Addtionally, a new line is appended to act as the USB termination character.

func (*Controller) Read

func (c *Controller) Read(p []byte) (n int, err error)

Read reads from the instrument at the currently assigned GPIB address into the given byte slice.

func (*Controller) ReadAfterWrite

func (c *Controller) ReadAfterWrite() (bool, error)

ReadAfterWrite determines if the Prologix controller is configured to automatically read after a write.

func (*Controller) ReadTimeout

func (c *Controller) ReadTimeout() (int, error)

ReadTimeout queries the read timeout value in milliseconds from the Prologix GPIB controller.

func (*Controller) Reset added in v0.2.0

func (c *Controller) Reset() error

Reset performs a power-on reset of the controller. The process takes about 5 seconds. All input received during this time are ignored.

func (*Controller) ServiceRequest

func (c *Controller) ServiceRequest() (bool, error)

ServiceRequest sends the `srq` command to the Prologix controller to determine if the GPIB SRQ signal is asserted or not.

func (*Controller) SetAssertEOI added in v0.2.0

func (c *Controller) SetAssertEOI(enable bool) error

SetAssertEOI sets the Prologix controller to assert the EOI signal after the last character of a command sent over the GPIB port.

func (*Controller) SetGPIBTermination added in v0.2.0

func (c *Controller) SetGPIBTermination(term GpibTerm) error

SetGPIBTermination uses the Prologix `eos` command to set the character to be appended as the GPIB terminator to all data sent from the Prologix Controller to the instrument.

func (*Controller) SetInstrumentAddress

func (c *Controller) SetInstrumentAddress(addr int) error

SetInstrumentAddress sets the GPIB address for the instrument under control.

func (*Controller) SetReadAfterWrite

func (c *Controller) SetReadAfterWrite(enable bool) error

SetReadAfterWrite sets the Proglogix controller to automatically read after write.

func (*Controller) SetReadTimeout

func (c *Controller) SetReadTimeout(timeout int) error

SetReadTimeout sets the Proglogix controller's read timeout in milliseconds. The timeout must be between 1 and 3000 milliseconds.

func (*Controller) Version

func (c *Controller) Version() (string, error)

Version returns the version string from the Prologix GPIB controller.

func (*Controller) Write

func (c *Controller) Write(p []byte) (n int, err error)

Write writes the given data to the instrument at the currently assigned GPIB address.

func (*Controller) WriteString

func (c *Controller) WriteString(s string) (n int, err error)

WriteString writes a string to the instrument at the currently assigned GPIB address.

type GpibTerm added in v0.2.0

type GpibTerm int

GpibTerm provides the type for the available GPIB terminators.

const (
	AppendCRLF GpibTerm = iota
	AppendCR
	AppendLF
	AppendNothing
)

Available GPIB terminators for the Prologix Controller.

func (GpibTerm) String added in v0.2.0

func (term GpibTerm) String() string

Directories

Path Synopsis
driver
vcp
examples
vcp/e3631a command
vcp/fluke45 command
vcp/key33220a command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL