Skip to content
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

Critical Bug: Use of %f instead of %e for values truncates values #821

Open
maor1993 opened this issue Jan 5, 2023 · 7 comments
Open

Critical Bug: Use of %f instead of %e for values truncates values #821

maor1993 opened this issue Jan 5, 2023 · 7 comments
Labels

Comments

@maor1993
Copy link

maor1993 commented Jan 5, 2023

Hey, I've been working with this library for a while using the DSOX1102G I noticed that once I use a value smaller than 1e-6, the scope does not receive it correctly and uses the smallest value possible.

This issue occurs as the python default %f max decimal points is 6:
image

The more concise solution would be to use %e which is always supported by SCPI devices:
image

Looking at the repo there are about 19 devices use %f and not %e

This is uncaught by testing as it was never tested for.

@BenediktBurger
Copy link
Member

BenediktBurger commented Jan 5, 2023

Thanks for raising this issue.

If your device is able to understand exponential notation, you can change it there.

I'm not sure, that every device understands exponential notation (not even all SCPI ones). Some might truncate at "e" producing undesired results, others might raise an error.
Therefore it is not that easy changing all occurrences.

Another idea: %g produces normal output (%f) if the exponent is between 5 and -4 and exponential output (%e) if outside this range.

Maybe we should put a corresponding note into the documentation as well.

@bilderbuchi
Copy link
Member

Thanks for raising this! I agree that %g is probably the more sensible default choice.

For all instruments where you want to move away from %f, you'll have to check (with a device if available, or in the manual) if the resulting numbers format is accepted by the device.

@maor1993
Copy link
Author

maor1993 commented Jan 5, 2023

Thanks for the quick reply.
the list is as follows:
image

I think I might have a moment to check the programming manuals, will update.

@maor1993
Copy link
Author

maor1993 commented Jan 5, 2023

Okay done:

device link supports exp? Notes
AWG401x ? ? Can't find programming manual
agillent33220A http://ecelabs.njit.edu/student_resources/33220_user_guide.pdf YES
agilent33500 https://www.testequipmentdepot.com/usedequipment/pdf/33500b-33600a-series_manual.pdf YES
agilent33521A https://www.testequipmentdepot.com/usedequipment/pdf/33500b-33600a-series_manual.pdf YES
anritsuMS9710C https://dl.cdn-anritsu.com/en-au/test-measurement/files/Manuals/Operation-Manual/MS9710C_W1580AE_remote_opm_e_4_0.pdf YES
danfysik8500 https://www.danfysik.dk/media/1182/software-manual-sys8500.pdf NO?
keithley24xx https://download.tek.com/manual/2400S-900-01_K-Sep2011_User.pdf YES
keithley6517b https://download.tek.com/manual/6517B-901-01D_Feb_2016.pdf YES* some fields do and some don't
keysightDSOXxx https://www.keysight.com/il/en/assets/9018-07554/programming-guides/9018-07554.pdf YES
keysightN7776C https://www.keysight.com/il/en/assets/9018-70058/programming-guides/9018-70058.pdf YES
ips120_10 https://muquip.triumf.ca/sites/default/files//instruction_manuals/mnl_spec_bNMR_oxford_powerSupply_IPS-120-10.PDF NO Uses decimal point only
itc503 http://lmu.web.psi.ch/docu/manuals/bulk_manuals/OxfordInstruments/ITC503.pdf NO Uses decimal point only
cnt91 https://www.manualslib.com/manual/1375130/Pendulum-Cnt-90.html YES
sr570 https://www.thinksrs.com/downloads/pdfs/manuals/SR570m.pdf NO
sr830 https://www.thinksrs.com/downloads/pdfs/manuals/SR830m.pdf NO
sr860 https://www.thinksrs.com/downloads/pdfs/manuals/SR860m.pdf NO
ibeamsmart ? ? Can't find programming manual

@LongnoseRob
Copy link
Contributor

@maor1993 AGW401x - is probably this product.
But I could not find a public available programming manual on manufacturers website

@BenediktBurger
Copy link
Member

Let's put a hint in #779 regarding small numbers.

@BenediktBurger
Copy link
Member

Thanks for looking up the manuals.

Would you mind opening a PR with the changes, @maor1993 ?

You do not have to change all instruments possible.
I'd guess, that it does not occur that often, that you want to set a value to below 1e-5. And if it occurs, we can still fix that device (with a person being able to test the change).

It is more important, that devices continue to work (down to 1e-5) than to break at any input. If you're in doubt, whether it will work for a given instrument, leave as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants