Skip to main content

module to interface AR488 boards

Project description

PyAR488

PyAR488 is a Python package to interact with AR488 GPIB-USB interface boards.
It provides a thin abstraction layer over the serial interface to simplify communication with GPIB instruments.


Installation

pip install PyAR488

Requirements

  • Python 3.6+
  • pyserial (installed automatically as a dependency)

Quickstart

from PyAR488.PyAR488 import AR488

# Open the interface (replace COM5 with your serial port)
interface = AR488("COM5")

# Set GPIB address and read
interface.address(22)
print(interface.read())

Using PyAR488 in Custom Instrument Classes

A recommended pattern is to inject the AR488 interface into your instrument classes:

from PyAR488.PyAR488 import AR488

class HP3468A:
    def __init__(self, gpib_address: int, interface: AR488):
        self.address = gpib_address
        self.interface = interface

    def read_measurement(self):
        self.interface.address(self.address)
        return self.interface.read()

interface = AR488("COM5")
meter = HP3468A(22, interface)

reading = meter.read_measurement()
print(reading)

Safer Pattern: Enforcing Address Before Each Operation

If multiple instruments share the same interface, ensure the GPIB address is set before every read/write:

class MyInstrument:
    def __init__(self, interface: AR488, address: int):
        self.interface = interface
        self.address = address

    def read(self, message: str = ""):
        self.interface.address(self.address)
        return self.interface.read(message)

This prevents accidental cross-talk when the interface address is changed elsewhere in your code.


Debugging

Enable debug mode to print communication traffic:

interface = AR488("COM5", debug=True)

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyar488-1.7.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyar488-1.7.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file pyar488-1.7.1.tar.gz.

File metadata

  • Download URL: pyar488-1.7.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for pyar488-1.7.1.tar.gz
Algorithm Hash digest
SHA256 de5cc42bf61871283198912555add597881f13a88bcaab8648f4d521c881944b
MD5 39d001d9013e40cda26ce7358ba562f4
BLAKE2b-256 3cd619407844a8de2cdbf849ffc1b1d23e84b3425ab120357a644618e63a6b95

See more details on using hashes here.

File details

Details for the file pyar488-1.7.1-py3-none-any.whl.

File metadata

  • Download URL: pyar488-1.7.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for pyar488-1.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0cdf24f80b3498a4a7ed16d4e9ee3d395ccfdc15c8904edf8ce2531c2d43473f
MD5 ee4f146d7438518026422d3adb8b6bb7
BLAKE2b-256 ce0429a7373afcd0154d6b419f719085ffa7e091d77137fc9353564a10309352

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page