Skip to main content

A python package for instrumenting the FleaScope

Project description

Python library for instrumenting FleaScope

With this library, you can control and read your FleaScope(s).

Usage

Connect to your FleaScope

from pyfleascope.flea_scope import FleaScope

scope = FleaScope.connect() # for default hostname FleaScope
# scope = FleaScope.connect('scope1')
# scope = FleaScope.connect(port='/dev/ttyACM0')

Connecting by name will also take care of resetting the device if necessary.

Get your first reading from the BNC connector

df = scope.x1.read(timedelta(milliseconds=20))['bnc']

Calibration

Calibration values are by default read from flash upon connection. If necessary, recalibration can be performed via

# BNC probe in x1 mode
# Connect probe to GND
scope.x1.calibrate_0()
# Connect probe to 3.3V
scope.x1.calibrate_3v3()
scope.x1.write_calibration_to_flash()

# BNC probe in x10 mode
# Connect probe to GND
scope.x10.calibrate_0()
# Connect probe to 3.3V
scope.x10.calibrate_3v3()
scope.x10.write_calibration_to_flash()

Triggers

Trigger reading on analog edges

from pyfleascope.trigger_config import AnalogTrigger

df = scope.x1.read(
            timedelta(milliseconds=20),
            trigger=AnalogTrigger.start_capturing_when().rising_edge(volts=2),
)

or on digital signals

from pyfleascope.trigger_config import DigitalTrigger, BitState

df = scope.x1.read(
            timedelta(milliseconds=20),
            trigger=DigitalTrigger.start_capturing_when()
              .bit1(BitState.HIGH)
              .bit7(BitState.LOW)
              .starts_matching(),
)

Delay

Start capturing with a delay.

df = scope.x1.read(
            timedelta(milliseconds=20),
            trigger=AnalogTrigger.start_capturing_when().rising_edge(volts=2),
            delay=timedelta(milliseconds=0.2),
)

Waveform

Configure the built-in waveform generator.

from pyfleascope.flea_scope import Waveform

scope.set_waveform(Waveform.EKG, hz=1000)

Digital inputs

The digital input is captured in the column bitmask. The function extract_bits extracts boolean columns bit_$i for each bit.

df = scope.x1.read(
            timedelta(milliseconds=20),
            trigger=DigitalTrigger.start_capturing_when()
              .bit0(BitState.HIGH)
              .bit1(BitState.HIGH)
              .starts_matching(),
)
df = FleaScope.extract_bits(df)
df['bit_0'] = df['bit_0'].apply(int)

Using multiple FleaScopes

Multiple FleaScopes can be used at the same time. For exact timing alignment, the trigger signal can be forwarded.

scope1 = FleaScope.connect('scope1')
scope2 = FleaScope.connect('scope2')


capture_time = timedelta(microseconds=120)

# Capture data from two FleaScopes at the same time by forwarding the trigger
# TRIGGER_OUT on scope1 is connected to Bit 0 on scope2 via cable

def read_scope1():
    time.sleep(1) # give scope1 time to prepare
    return scope1.x1.read(
        capture_time,
        AnalogTrigger.start_capturing_when().auto(2),
    )

def read_scope2():
    return scope2.x1.read(
            capture_time,
            DigitalTrigger.start_capturing_when().bit0(BitState.HIGH).starts_matching(),
    )

with ThreadPoolExecutor(max_workers=8) as executor:
    f1 = executor.submit(read_scope1)
    f2 = executor.submit(read_scope2)
    df1 = f1.result()
    df2 = f2.result()

Cancel ongoing read

While waiting for the trigger or capturing values, the FleaScope is unresponsive. The ongoing read operation can be canceled via the unblock method.

scope.unblock()

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

pyfleascope-0.0.2.tar.gz (534.8 kB view details)

Uploaded Source

Built Distribution

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

pyfleascope-0.0.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file pyfleascope-0.0.2.tar.gz.

File metadata

  • Download URL: pyfleascope-0.0.2.tar.gz
  • Upload date:
  • Size: 534.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pyfleascope-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8c0a06ed5fff9d28547f01a4668aca33b42d49098dc960460f28ff2af52087e6
MD5 3cc539da5be395ad520bb47d81933d06
BLAKE2b-256 524c18c82a2e84b3426dad5c5c4c8a37ed9a592a5af9d1595cea0867415a58bc

See more details on using hashes here.

File details

Details for the file pyfleascope-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyfleascope-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pyfleascope-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 021a3fb424bc4c1f902f9a204ecb4d658e7e9b9d7b34a77cf9e1ff7f27bfe7ce
MD5 edcb445fec750a4592539bf7ed370006
BLAKE2b-256 af813fe124a28b59fe60746cb686df1ce9df42d1c61fa976e93452f225a28adc

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