Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into jeff/prologix-startech-stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
39bytes authored Nov 30, 2023
2 parents e1a694b + 11dc693 commit 23843c9
Show file tree
Hide file tree
Showing 86 changed files with 15,285 additions and 327 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from flojoy import VisaDevice, flojoy, TextBlob
from flojoy.connection_manager import DeviceConnectionManager


@flojoy
def CONNECT_DMM7510(
device: VisaDevice,
) -> TextBlob:
"""Open a VISA connection to a Keithley DMM7510.
Also sets the communication language to TSP.
Parameters
----------
device: VisaDevice
The connected VISA device.
Returns
-------
device_addr: TextBlob
The IP or VISA address of the VISA device.
"""

device_addr = device.get_address()

dmm = DeviceConnectionManager.tm.add_dmm(device_addr)
dmm.write("*LANG TSP")
lang = dmm.query("*LANG?")
if lang != "TSP":
raise ValueError(
"Command set language not set correctly. Try setting to 'TSP' manually."
)

DeviceConnectionManager.register_connection(device, dmm)

return TextBlob(text_blob=device_addr)
643 changes: 643 additions & 0 deletions blocks/HARDWARE/MULTIMETERS/KEITHLEY/DMM7510/CONNECT_DMM7510/app.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"docstring": {
"long_description": "Also sets the communication language to TSP.",
"short_description": "Open a VISA connection to a Keithley DMM7510.",
"parameters": [
{
"name": "device",
"type": "VisaDevice",
"description": "The connected VISA device."
}
],
"returns": [
{
"name": "device_addr",
"type": "TextBlob",
"description": "The IP or VISA address of the VISA device."
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
In this example, a DC voltage measurement was extracted from a Keithley DMM7510.

First the necessary blocks were added:

- `CONNECT_DMM7510`
- `RESET_DMM7510`
- `FUNCTION_DMM7510`
- `DIGITS_DMM7510`
- `MEASUREMENT_PARAMS_DMM7510`
- `MEASUREMENT_FILTER_DMM7510`
- `READ_DMM7510`
- `BIG_NUMBER`

The instrument address was set for each `DMM7510` block. The `FUNCTION_DMM7510` block was changed in order to extract the correct measurement. The parameters in `DIGITS_DMM7510`, `MEASUREMENT_PARAMS_DMM7510`, and `MEASUREMENT_FILTER_DMM7510` blocks were changed as necessary. The `READ_DMM7510` block was connected to the `BIG_NUMBER` block in order to view the reading.

The blocks were connected as shown and the app was run.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from typing import Optional, Literal
from flojoy import VisaConnection, flojoy, DataContainer, OrderedPair


@flojoy(inject_connection=True)
def DIGITIZED_TIME_DMM7510(
connection: VisaConnection,
input: Optional[DataContainer] = None,
function: Literal[
"Digitize voltage",
"Digitize current",
] = "Digitize voltage",
num_samples: int = 100,
sample_rate: float = 1e3,
range: float = 1,
) -> OrderedPair:
"""Measures digitized data vs time.
Requires a CONNECT_DMM7510 block to create the connection.
Parameters
----------
connection : VisaConnection
The VISA address (requires the CONNECTION_DMM7510 block).
function : select, default=Digitize voltage
Select the measurement function
num_samples : int, default=100
The number of points/samples to measure.
sample_rate : float, default=1000
The number of samples per second.
range : float, default=1
The range of the function measurement.
Returns
-------
OrderedPair
x: time
y: measurements
"""

dmm = connection.get_handle()

if function == "Digitize voltage":
dmm.write("dmm.digitize.func = dmm.FUNC_DIGITIZE_VOLTAGE")
else:
dmm.write("dmm.digitize.func = dmm.FUNC_DIGITIZE_CURRENT")

dmm.write(f"dmm.digitize.range = {range}")
dmm.write(f"dmm.digitize.samplerate = {sample_rate}")
dmm.write(f"dmm.digitize.count = {num_samples}")

dmm.write("dmm.digitize.aperture = dmm.APERTURE_AUTO")
dmm.commands.dmm.digitize.inputimpedance = "dmm.IMPEDANCE_AUTO"

dmm.commands.buffer_var["defbuffer1"].capacity = num_samples
dmm.write("defbuffer1.clear()")
dmm.write("dmm.digitize.read()")

time = []
y = []
for cnt in range(1, num_samples + 1):
y.append(float(dmm.commands.buffer_var["defbuffer1"].readings[cnt]))
time.append(
float(dmm.commands.buffer_var["defbuffer1"].relativetimestamps[cnt])
)

return OrderedPair(x=time, y=y)
Loading

0 comments on commit 23843c9

Please sign in to comment.