Skip to content

Use correct sense function for sense parameters in Keysight 344xxA driver#6723

Merged
jenshnielsen merged 14 commits intomicrosoft:mainfrom
janekfleper:Keysight-344xxA
Apr 15, 2025
Merged

Use correct sense function for sense parameters in Keysight 344xxA driver#6723
jenshnielsen merged 14 commits intomicrosoft:mainfrom
janekfleper:Keysight-344xxA

Conversation

@janekfleper
Copy link
Contributor

The Keysight344xxA class implements the sense parameters without checking the sense function.

The parameters in the SENSE subsystem have to be handled based on the current sense function. By default the VISA path is always "SENSe:VOLTage:DC" and the parameters will only get/set the values for the DC voltage measurement. The actual sense function that is currently used by the instrument completely ignored.

I was not entirely sure how to implement this. I had the following other ideas how to solve this:

  1. Create a SenseParameter class that overrides get_raw() and set_raw() to read the sense function just before calling either get() or set(), but according to the documentation you cannot use both get_raw() and get_cmd at the same time. And it would also be overkill since I actually just need a decorator for the methods get_raw() and set_raw(), I don't need to completely modify them. Is there a way to add such a decorator?
  2. Create an instrument module Keysight344xxASense for all the sense parameters to move them from the root instrument to self.sense. I could then override the methods ask() and write() in the module to "inject" the correct sense function path just before actually sending the command to the VISA handle.
  3. Pass callable methods to the parameters get_cmd and set_cmd and manually call self.ask() and self.write() with the correct commands.

The merge request currently implements solution 3 for the parameters NPLC, autorange, autozero, aperture_mode and aperture_time. The parameters range and resolution are still missing since their validators require some extra work.

Are you happy with the current approach or would you prefer one of the other two solutions? Or is there something that I am missing completely that would make the implementation a lot more straight forward?

I am looking forward to your feedback!

@janekfleper janekfleper requested a review from a team as a code owner December 16, 2024 17:38
@janekfleper janekfleper changed the title Use correct sense function for sense parameters Use correct sense function for sense parameters in Keysight 344xxA driver Dec 16, 2024
@janekfleper
Copy link
Contributor Author

@microsoft-github-policy-service agree company="University of Bonn"

@jenshnielsen
Copy link
Collaborator

@einsmein Could you review this since I think you looked at the 344xx not that long ago

@einsmein
Copy link
Contributor

@janekfleper The second option would be ideal. It reflects the instrument interface where we specify measurement types with every sense function.
That being said, this approach makes sense given the interface we have now. (The non-ideal part is that by setting sense_function parameter, we implicitly modify the behavior of other parameters. But we can address that in the future.)

Have you tested this code on the instrument? In that case LGTM

Copy link
Contributor

@astafan8 astafan8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a tiny correction :)

@janekfleper
Copy link
Contributor Author

I have tested the changes on the model 34465A and I would also have the models 34470 and 34411A available for further testing. But since these models are all equally affected by the changes, I don't think it is necessary here.

@jenshnielsen jenshnielsen enabled auto-merge March 21, 2025 14:58
auto-merge was automatically disabled March 21, 2025 16:18

Head branch was pushed to by a user without write access

@jenshnielsen jenshnielsen enabled auto-merge April 3, 2025 12:38
This only includes the six sense functions implemented in the instrument driver. The other sense functions do not all support the parameters NPLC, autorange, autozero,  aperture_mode and aperture_time.
auto-merge was automatically disabled April 14, 2025 15:16

Head branch was pushed to by a user without write access

@codecov
Copy link

codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Project coverage is 59.91%. Comparing base (fc91544) to head (d4504b3).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...ers/Keysight/private/Keysight_344xxA_submodules.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6723      +/-   ##
==========================================
+ Coverage   59.89%   59.91%   +0.02%     
==========================================
  Files         342      342              
  Lines       31459    31475      +16     
==========================================
+ Hits        18841    18857      +16     
  Misses      12618    12618              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jenshnielsen jenshnielsen enabled auto-merge April 15, 2025 12:28
@jenshnielsen jenshnielsen added this pull request to the merge queue Apr 15, 2025
Merged via the queue into microsoft:main with commit 04eb19f Apr 15, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants