Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PSL/Peripherals.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def capture(self, address, location, sample_length, total_samples, tg, *args):

>>> from pylab import *
>>> I=sciencelab.ScienceLab()
>>> x,y1,y2,y3,y4 = I.capture_multiple(800,1.75,'CH1','CH2','MIC','SEN')
>>> x,y1,y2,y3,y4 = I.capture_multiple(800,1.75,'CH1','CH2','MIC','RES')
>>> plot(x,y1)
>>> plot(x,y2)
>>> plot(x,y3)
Expand Down
118 changes: 59 additions & 59 deletions PSL/README.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions PSL/achan.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"CH3",
"MIC",
"CAP",
"SEN",
"AN8",
"RES",
"VOL",
)

INPUT_RANGES = {
Expand All @@ -33,8 +33,8 @@
"CH3": (-3.3, 3.3), # external gain control analog input
"MIC": (-3.3, 3.3), # connected to MIC amplifier
"CAP": (0, 3.3),
"SEN": (0, 3.3),
"AN8": (0, 3.3),
"RES": (0, 3.3),
"VOL": (0, 3.3),
}

PIC_ADC_MULTIPLEX = {
Expand All @@ -43,9 +43,9 @@
"CH3": 1,
"MIC": 2,
"AN4": 4,
"SEN": 7,
"RES": 7,
"CAP": 5,
"AN8": 8,
"VOL": 8,
}


Expand All @@ -54,7 +54,7 @@ class AnalogInput:

Parameters
----------
name : {'CH1', 'CH2', 'CH3', 'MIC', 'CAP', 'SEN', 'AN8'}
name : {'CH1', 'CH2', 'CH3', 'MIC', 'CAP', 'RES', 'VOL'}
Name of the analog channel to model.
device : :class:`Handler`
Serial interface for communicating with the PSLab device.
Expand Down
8 changes: 4 additions & 4 deletions PSL/commands_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@
GET_STATE = Byte.pack(1)
GET_STATES = Byte.pack(2)

ID1 = Byte.pack(0)
ID2 = Byte.pack(1)
ID3 = Byte.pack(2)
ID4 = Byte.pack(3)
LA1 = Byte.pack(0)
LA2 = Byte.pack(1)
LA3 = Byte.pack(2)
LA4 = Byte.pack(3)
LMETER = Byte.pack(4)

# /*------TIMING FUNCTIONS-----*/
Expand Down
6 changes: 3 additions & 3 deletions PSL/digital_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

DIGITAL_INPUTS = ("ID1", "ID2", "ID3", "ID4", "SEN", "EXT", "CNTR")
DIGITAL_INPUTS = ("LA1", "LA2", "LA3", "LA4", "RES", "EXT", "FRQ")

MODES = {
"sixteen rising": 5,
Expand All @@ -20,13 +20,13 @@ class DigitalInput:

Parameters
----------
name : {"ID1", "ID2", "ID3", "ID4", "SEN", "EXT", "CNTR"}
name : {"LA1", "LA2", "LA3", "LA4", "RES", "EXT", "FRQ"}
Name of the digital channel to model.

Attributes
----------
name : str
One of {"ID1", "ID2", "ID3", "ID4", "SEN", "EXT", "CNTR"}.
One of {"LA1", "LA2", "LA3", "LA4", "RES", "EXT", "FRQ"}.
number : int
Number used to refer to this channel in the firmware.
datatype : str
Expand Down
58 changes: 29 additions & 29 deletions PSL/logic_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def __init__(self, device: packet_handler.Handler = None):
self._channels = {
d: digital_channel.DigitalInput(d) for d in digital_channel.DIGITAL_INPUTS
}
self.trigger_channel = "ID1"
self._trigger_channel = self._channels["ID1"]
self.trigger_channel = "LA1"
self._trigger_channel = self._channels["LA1"]
self.trigger_mode = "disabled"
self._trigger_mode = 0
self._prescaler = 0
self._channel_one_map = "ID1"
self._channel_two_map = "ID2"
self._channel_one_map = "LA1"
self._channel_two_map = "LA2"
self._trimmed = 0

def measure_frequency(
Expand All @@ -68,7 +68,7 @@ def measure_frequency(

Parameters
----------
channel : {"ID1", "ID2", "ID3", "ID4"}
channel : {"LA1", "LA2", "LA3", "LA4"}
Name of the digital input channel in which to measure the frequency.
simultaneous_oscilloscope: bool, optional
Set this to True if you need to use the oscilloscope at the same time.
Expand Down Expand Up @@ -145,7 +145,7 @@ def measure_interval(
Parameters
----------
channels : List[str]
A pair of digital inputs, ID1, ID2, ID3, or ID4. Both can be the same.
A pair of digital inputs, LA1, LA2, LA3, or LA4. Both can be the same.
modes : List[str]
Type of logic event to listen for on each channel. See
:class:`DigitalInput` for available modes.
Expand Down Expand Up @@ -209,7 +209,7 @@ def measure_duty_cycle(self, channel: str, timeout: float = 1) -> Tuple[float]:

Parameters
----------
channel : {"ID1", "ID2", "ID3", "ID4"}
channel : {"LA1", "LA2", "LA3", "LA4"}
Digital input on which to measure.
timeout : float, optional
Timeout in seconds before cancelling measurement. The default value is
Expand Down Expand Up @@ -251,8 +251,8 @@ def capture(
Parameters
----------
channels : {1, 2, 3, 4}
Number of channels to capture events on. Events will be captured on ID1,
ID2, ID3, and ID4, in that order.
Number of channels to capture events on. Events will be captured on LA1,
LA2, LA3, and LA4, in that order.
events : int, optional
Number of logic events to capture on each channel. The default and maximum
value is 2500.
Expand Down Expand Up @@ -302,7 +302,7 @@ def capture(
start_time = time.time()

for e, c in enumerate(
[self._channel_one_map, self._channel_two_map, "ID3", "ID4"][:channels]
[self._channel_one_map, self._channel_two_map, "LA3", "LA4"][:channels]
):
c = self._channels[c]
c.events_in_buffer = events
Expand Down Expand Up @@ -396,10 +396,10 @@ def _capture_four(self, e2e_time: float):
self._device.send_byte(CP.START_FOUR_CHAN_LA)
self._device.send_int(CP.MAX_SAMPLES // 4)
self._device.send_int(
self._channels["ID1"]._logic_mode
| (self._channels["ID2"]._logic_mode << 4)
| (self._channels["ID3"]._logic_mode << 8)
| (self._channels["ID4"]._logic_mode << 12)
self._channels["LA1"]._logic_mode
| (self._channels["LA2"]._logic_mode << 4)
| (self._channels["LA3"]._logic_mode << 8)
| (self._channels["LA4"]._logic_mode << 12)
)
self._device.send_byte(self._prescaler)

Expand All @@ -408,7 +408,7 @@ def _capture_four(self, e2e_time: float):
self._trigger_channel.number
] | self._trigger_mode
except KeyError:
e = "Triggering is only possible on ID1, ID2, or ID3."
e = "Triggering is only possible on LA1, LA2, or LA3."
raise NotImplementedError(e)

self._device.send_byte(trigger)
Expand All @@ -433,7 +433,7 @@ def fetch_data(self) -> List[np.ndarray]:
counter_values = []
channels = list(
OrderedDict.fromkeys(
[self._channel_one_map, self._channel_two_map, "ID3", "ID4"]
[self._channel_one_map, self._channel_two_map, "LA3", "LA4"]
)
)
for c in channels:
Expand Down Expand Up @@ -530,7 +530,7 @@ def get_initial_states(self) -> Dict[str, bool]:
-------
dict of four str: bool pairs
Dictionary containing pairs of channel names and the corresponding initial
state, e.g. {'ID1': True, 'ID2': True, 'ID3': True, 'ID4': False}.
state, e.g. {'LA1': True, 'LA2': True, 'LA3': True, 'LA4': False}.
True means HIGH, False means LOW.
"""
return self._get_initial_states_and_progress()[0]
Expand All @@ -552,7 +552,7 @@ def get_xy(self, timestamps: List[np.ndarray]) -> List[np.ndarray]:
xy = []

for e, c in enumerate(
[self._channel_one_map, self._channel_two_map, "ID3", "ID4"][
[self._channel_one_map, self._channel_two_map, "LA3", "LA4"][
: len(timestamps)
]
):
Expand All @@ -575,10 +575,10 @@ def _get_initial_states_and_progress(self) -> Tuple[Dict[str, bool], List[int]]:
progress[3] = (self._device.get_int() - initial) // 2 - 3 * CP.MAX_SAMPLES // 4
s = self._device.get_byte()
initial_states = {
"ID1": (s & 1 != 0),
"ID2": (s & 2 != 0),
"ID3": (s & 4 != 0),
"ID4": (s & 8 != 0),
"LA1": (s & 1 != 0),
"LA2": (s & 2 != 0),
"LA3": (s & 4 != 0),
"LA4": (s & 8 != 0),
}
self._device.get_byte() # INITIAL_DIGITAL_STATES_ERR
self._device.get_ack()
Expand All @@ -596,7 +596,7 @@ def configure_trigger(self, trigger_channel: str, trigger_mode: str):

Parameters
----------
trigger_channel : {"ID1", "ID2", "ID3", "ID4"}
trigger_channel : {"LA1", "LA2", "LA3", "LA4"}
The digital input on which to trigger.
trigger_condition : {"disabled", "falling", "rising"}
The type of logic level change on which to trigger.
Expand Down Expand Up @@ -640,18 +640,18 @@ def get_states(self) -> Dict[str, bool]:
-------
dict of four str: bool pairs
Dictionary containing pairs of channel names and the corresponding current
state, e.g. {'ID1': True, 'ID2': True, 'ID3': True, 'ID4': False}.
state, e.g. {'LA1': True, 'LA2': True, 'LA3': True, 'LA4': False}.
True means HIGH, False means LOW.
"""
self._device.send_byte(CP.DIN)
self._device.send_byte(CP.GET_STATES)
s = self._device.get_byte()
self._device.get_ack()
return {
"ID1": (s & 1 != 0),
"ID2": (s & 2 != 0),
"ID3": (s & 4 != 0),
"ID4": (s & 8 != 0),
"LA1": (s & 1 != 0),
"LA2": (s & 2 != 0),
"LA3": (s & 4 != 0),
"LA4": (s & 8 != 0),
}

def count_pulses(
Expand All @@ -664,7 +664,7 @@ def count_pulses(

Parameters
----------
channel : {"ID1", "ID2", "ID3", "ID4"}
channel : {"LA1", "LA2", "LA3", "LA4"}
Digital input on which to count pulses.
interval : float, optional
Time in seconds during which to count pulses. The default value is
Expand Down
8 changes: 4 additions & 4 deletions PSL/oscilloscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def capture(self, channels: int, samples: int, timegap: float,) -> np.ndarray:
channels : {1, 2, 4}
Number of channels to sample from simultaneously. By default, samples are
captured from CH1, CH2, CH3 and MIC. CH1 can be remapped to any other
channel (CH2, CH3, MIC, CAP, SEN, AN8) by setting the channel_one_map
channel (CH2, CH3, MIC, CAP, RES, VOL) by setting the channel_one_map
attribute of the Oscilloscope instance to the desired channel.
samples : int
Number of samples to fetch. Maximum 10000 divided by number of channels.
Expand Down Expand Up @@ -93,7 +93,7 @@ def capture(self, channels: int, samples: int, timegap: float,) -> np.ndarray:
ValueError
If :channels: is not 1, 2 or 4, or
:samples: > 10000 / :channels:, or
:channel_one_map: is not one of CH1, CH2, CH3, MIC, CAP, SEN, AN8, or
:channel_one_map: is not one of CH1, CH2, CH3, MIC, CAP, RES, VOL, or
:timegap: is too low.
"""
xy = np.zeros([channels + 1, samples])
Expand Down Expand Up @@ -227,7 +227,7 @@ def fetch_data(self, channel: str) -> np.ndarray:

Parameters
----------
channel : {'CH1', 'CH2', 'CH3', 'MIC', 'CAP', 'SEN', 'AN8'}
channel : {'CH1', 'CH2', 'CH3', 'MIC', 'CAP', 'RES', 'VOL'}
Name of the channel from which to fetch captured data.

Example
Expand Down Expand Up @@ -290,7 +290,7 @@ def configure_trigger(self, channel: str, voltage: float, prescaler: int = 0):

Parameters
----------
channel : {'CH1', 'CH2', 'CH3', 'MIC', 'CAP', 'SEN', 'AN8'}
channel : {'CH1', 'CH2', 'CH3', 'MIC', 'CAP', 'RES', 'VOL'}
The name of the trigger channel.
voltage : float
The trigger voltage in volts.
Expand Down
Loading