Skip to main content

Custom electron gun slow control Python communication library and GUI utlity

Work in progress

Communication library

The communication library from eguncom.py implements most of the communication protocol with the electron beam slow-control system.

class ElectronGunControl

The ElectronGunControl class implements asynchronous and synchronous communication with the serially / USB attached control system. The port file is passed to the constructor

ctrl = ElectronGunNotConnected(portFile = '/dev/...')

When no port file is passed it defaults to /dev/ttyU0.

The exposed public methods are:

Method Description Synchronous Asynchronous callback
id() Queries the current version with sync = True cbIdentify(controller, versionDate, versionRevision)
getPSUVoltage(channel) Queries the current voltage on the given channel with sync = True cbVoltage(controller, channel, voltageVolts)
getPSUCurrent(channel) Queries the current current on the given channel with sync = True cbCurrent(controller, channel, currentMicroamps)
getPSUModes() Checks if PSUs are off, in voltage limited or current limited mode with sync = True cbPSUMode(controller, states)
getFilamentCurrent() Queries the filament current with sync = True cbFilamentCurrent(controller, current)
off() Disabled all high voltage and filament currents
setPSUPolarity(channel, polarity) Sets polarity to POLARITY_POS or POLARITY_NEG
setPSUEnable(channel) Enables the given PSU channel
setPSUDisable(channel) Disables the given PSU channel
setPSUVoltage(channel, voltage) Sets the given channel to the given voltage
setFilamentCurrent(currentMa) Sets the filament current or target current to the specified milliamps
setFilamentOn() Enabled the filament supply
setFilamentOff() Disabled the filament supply
runInsulationTest() Runs an insulation test with low current limits with sync = True cbInsulation(isOk, listOfShorts)
beamOn() Runs the slow beam on sequence (slowly heating filament to previously set setFilamentCurrent, ramping up voltages) with sync = True cbBeamon()

Usage example

Synchronous sample (USB / serial)

Example to perform a synchronous:

  • Insulation check
  • Startup for 100 mA beam current
  • Looping through focus voltages
  • Shutting down
with ElectronGunControl() as ctrl:
    # Currently a hack to wait for the control system to reset when using the
    # primary port

    time.sleep(5)

    # We want to see the voltages reported by the system so we
    # define a lambda that just prints the voltages while ramping up
    # during insulation test and beam on sequence

    ctrl.cbVoltage = lambda c,chan,v : print("Voltage for channel {} is {} V".format(chan, v))

    # Query it's identity
    ret = ctrl.id(sync = True)
    print("ID call returned {}".format(ret))

    # Run insulation test
    print("Running insulation test")
    ret = ctrl.runInsulationTest(sync = True)
    print("Insulation test returned: {}".format(ret))

    # Run beam on sequence ...
    ret = ctrl.beamOn(sync = True)
    print("Beam on successfully returned: {}".format(ret))

    print("Sweeping focus voltage")
    for focusVoltage in range(1750,1950):
        print("New focus voltage {}".format(focusVoltage))
        ctrl.setPSUVoltage(3, focusVoltage)
        time.sleep(1)

    ctrl.off()
    print("Off, done ...")

Metadata

Release files for electronsourcecontroller2-tspspi 0.0.48

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for electronsourcecontroller2-tspspi 0.0.48
File Size Uploaded
electronsourcecontroller2-tspspi-0.0.48.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for electronsourcecontroller2-tspspi 0.0.48
File Interpreter ABI Platform
electronsourcecontroller2_tspspi-0.0.48-py3-none-any.whl Python 3 none any Details

Total release size: 35.6 kB

Release files / electronsourcecontroller2-tspspi-0.0.48.tar.gz

Download URL electronsourcecontroller2-tspspi-0.0.48.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5433e34fb4d1fce088748c6a295436ae621df6b65a96adce496f5a4a9a1a5717
BLAKE2b-256 checksum
How to use checksums
237e81d3d4a2170887b61e73ba09d83b9d63903d53c005c27880f3bb22d44b34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release files / electronsourcecontroller2_tspspi-0.0.48-py3-none-any.whl

Download URL electronsourcecontroller2_tspspi-0.0.48-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52874e4b71bf1f25943f91f8d52a7788f0bd4c7d31e0095fdc47b0504f5fbae5
BLAKE2b-256 checksum
How to use checksums
8a37b1856f1cba8f428082db9f2edb6538a1fda62744a4c021113f4c16ea442d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page