generated from PyMoDAQ/pymodaq_plugins_template
-
Notifications
You must be signed in to change notification settings - Fork 4
mise à jour en mode signal_recovery #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
francoisBmallet
wants to merge
3
commits into
PyMoDAQ:main
Choose a base branch
from
francoisBmallet:fm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
178 changes: 178 additions & 0 deletions
178
src/pymodaq_plugins_stanford_research_systems/daq_move_plugins/daq_move_Lockin_SR830.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| from typing import Tuple | ||
|
|
||
| from pymodaq.control_modules.move_utility_classes import ( | ||
| DAQ_Move_base, | ||
| DataActuator, | ||
| DataActuatorType, | ||
| comon_parameters_fun, | ||
| main | ||
| ) | ||
| from pymodaq.utils.parameter import Parameter | ||
|
|
||
| from pymeasure.adapters import VISAAdapter, PrologixAdapter | ||
|
|
||
| import pyvisa | ||
|
|
||
| from pymodaq_plugins_stanford_research_systems.hardware.sr_830_thread_safe import SR830ThreadSafe | ||
|
|
||
| def build_dict_from_float_list( | ||
| time_constants: list[float], | ||
| unit: str = "") -> dict: | ||
| d = {} | ||
| for tc in time_constants: | ||
| d[f"{tc:.2e} {unit}"] = tc | ||
| return d | ||
|
|
||
|
|
||
| rm = pyvisa.ResourceManager() | ||
| VISA_RESOURCES = rm.list_resources() | ||
| ADAPTERS = dict(VISA=VISAAdapter, Prologix=PrologixAdapter) | ||
| SHIELD = {"Grounded": 0, "Floating": 1} | ||
| COUPLING = {"AC": 0, "DC": 1} | ||
| TIME_CONSTANTS = build_dict_from_float_list(SR830ThreadSafe.TIME_CONSTANTS, "s") | ||
| SENSITIVITIES = build_dict_from_float_list(SR830ThreadSafe.SENSITIVITIES, "V") | ||
| FILTER_SLOPES = build_dict_from_float_list(SR830ThreadSafe.FILTER_SLOPES, "") | ||
| #print(SR830ThreadSafe.INPUT_COUPLINGS) | ||
|
|
||
| class DAQ_Move_Lockin_SR830(DAQ_Move_base): | ||
| """Plugin for the Signal Recovery DSP 7265 Instrument | ||
|
|
||
| Does not currently support differential measurement. | ||
| """ | ||
| _controller_units = ['Hz','V'] | ||
| is_multiaxes = True | ||
| _axis_names = ['Freq','Amp'] | ||
| _epsilon = 0.01 | ||
| data_actuator_type = DataActuatorType.DataActuator | ||
|
|
||
| params = [ | ||
| {'title': 'Adapter', 'name': 'adapter', 'type': 'list', | ||
| 'limits': list(ADAPTERS.keys())}, | ||
| {'title': 'VISA Address:', 'name': 'address', 'type': 'list', | ||
| 'limits': VISA_RESOURCES}, | ||
| {'title': 'Filter time constant', 'name': 'time_constant', | ||
| 'type': 'list', 'limits': list(TIME_CONSTANTS.keys())}, | ||
| {'title': 'Full-scale sensitivity', 'name': 'sensitivity', | ||
| 'type': 'list', 'limits': list(SENSITIVITIES.keys())}, | ||
| {'title': 'Filter slope', 'name': 'filter_slope', | ||
| 'type': 'list', 'limits': list(FILTER_SLOPES.keys())}, | ||
| ] + comon_parameters_fun(is_multiaxes, axis_names=_axis_names, epsilon=_epsilon) | ||
|
|
||
| def ini_attributes(self) -> None: | ||
| self.controller: SR830ThreadSafe = None | ||
|
|
||
| def get_actuator_value(self) -> DataActuator: | ||
| """Get the current value from the hardware with scaling conversion. | ||
|
|
||
| Returns | ||
| ------- | ||
| float: The frequency obtained after scaling conversion. | ||
| """ | ||
| if self.axis_value == 'Amp': # Amp axis | ||
| val = DataActuator(data=self.controller.sine_voltage) | ||
| elif self.axis_value == 'Freq': # Frequency axis | ||
| val = DataActuator(data=self.controller.frequency) | ||
| val = self.get_position_with_scaling(val) | ||
| return val | ||
|
|
||
| def close(self) -> None: | ||
| """Terminate the communication protocol""" | ||
| self.controller.shutdown() | ||
|
|
||
| def commit_settings(self, param: Parameter) -> None: | ||
| """Apply the consequences of a change of value in the detector settings | ||
|
|
||
| Parameters | ||
| ---------- | ||
| param: Parameter | ||
| A given parameter (within detector_settings) whose value has been | ||
| changed by the user | ||
| """ | ||
| if param.name() == "time_constant": | ||
| self.controller.time_constant = TIME_CONSTANTS[param.value()] | ||
| elif param.name() == "sensitivity": | ||
| self.controller.sensitivity= SENSITIVITIES[param.value()] | ||
| elif param.name() == "filter_slope": | ||
| self.controller.filter_slope= FILTER_SLOPES[param.value()] | ||
| else: | ||
| pass | ||
|
|
||
| def ini_stage(self, controller: object = None) -> Tuple[str, bool]: | ||
| """Actuator communication initialization | ||
|
|
||
| Parameters | ||
| ---------- | ||
| controller: (object) | ||
| custom object of a PyMoDAQ plugin (Slave case). None if only one | ||
| actuator by controller (Master case) | ||
|
|
||
| Returns | ||
| ------- | ||
| info: str | ||
| Id of the lockin | ||
| initialized: bool | ||
| False if initialization failed otherwise True | ||
| controller: object | ||
| Controller of the daq_move | ||
| """ | ||
| self.ini_stage_init(slave_controller=controller) | ||
|
|
||
| if self.is_master: | ||
| adapter = ADAPTERS[self.settings.child('adapter').value()]( | ||
| self.settings.child('address').value() | ||
| ) | ||
| self.controller = SR830ThreadSafe(adapter) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| try: | ||
| info = self.controller.id | ||
| initialized = True | ||
| except: | ||
| info = "" | ||
| initialized = False | ||
|
|
||
| return info, initialized | ||
|
|
||
| def move_abs(self, f: DataActuator) -> None: | ||
| """ Move the actuator to the absolute target defined by value | ||
|
|
||
| Parameters | ||
| ---------- | ||
| value: (float) value of the absolute target value | ||
| """ | ||
| f = self.check_bound(f) | ||
| f = self.set_position_with_scaling(f) | ||
| if self.axis_value == 'Amp': # Amp axis | ||
| self.controller.sine_voltage = f.value() | ||
| elif self.axis_value == 'Freq': # Frequency axis | ||
| self.controller.frequency = f.value() | ||
|
|
||
| self.target_value = f | ||
| self.current_value = self.target_value | ||
|
|
||
| def move_rel(self, f: DataActuator) -> None: | ||
| """ Move the actuator to the relative target actuator value defined by | ||
| value | ||
|
|
||
| Parameters | ||
| ---------- | ||
| value: (float) value of the relative target frequency | ||
| """ | ||
| f = (self.check_bound(self.current_value + f) | ||
| - self.current_value) | ||
| self.target_value = f + self.current_value | ||
| f = self.set_position_relative_with_scaling(f) | ||
| self.move_abs(self.target_value) | ||
|
|
||
| def move_home(self): | ||
| """Call the reference method of the controller | ||
|
|
||
| Set oscillator to 1kHz | ||
| """ | ||
| self.move_abs(DataActuator(1e3)) | ||
|
|
||
| def stop_motion(self): | ||
| """Stop the actuator and emits move_done signal""" | ||
| pass | ||
|
|
||
| if __name__ == '__main__': | ||
| main(__file__, init=False) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can actually remove this line and add the one below