GithubHelp home page GithubHelp logo

Comments (3)

j123b567 avatar j123b567 commented on May 31, 2024

Temperature units would require a linear conversion, so a multiplication and an addition.

This is true, but it is very simple to define new unit "fahrenheit". You then implement ParamTemperature on your own and do the conversion yourself. In your function, there must be also specified, what is default unit for temperature. So if the user send command with parameter "20", is it "20 °F", "20 °C" or even "20 K"?

Logarithmic units often used for signal power in spectrum analyzers would require logarithmic operations.

There are two problems:

  • definition of logarithmic units using dB prefix, there are also suffixes RMS, PP, ... and this make everythink more complex
  • do we always need the real value? If I specify some RF parameter in dBm and friends, isn't it better to leave it in dBm for some internal calculations in the instrument?

from scpi-parser.

jeras avatar jeras commented on May 31, 2024

Here I added units for angle (phase) it is not yet ready for merging, and tests are missing:
RedPitaya@fb6979d

For now I used the quantity in the enumeration name in types.h, using the unit name seemed a bit strange, since unit names for angle do not have much in common.

Did you have in mind a SCPI_Result* function, which would accept a unit and recalculate the value before printing it?

I will have a look at the source to see if I can do this LOG/MUL/SUM unit recalculation without too much trouble. The inverse operation of log might not be obvious. If the base unit is not linear, POW should also be available.

Regarding a use case, the user might wish to define the output amplitude of a signal generator in volts of decibel, depending on what is beeing measured.

from scpi-parser.

j123b567 avatar j123b567 commented on May 31, 2024

Here I added units for angle (phase) it is not yet ready for merging, and tests are missing:
RedPitaya@fb6979d

For now I used the quantity in the enumeration name in types.h, using the unit name seemed a bit strange, since unit names for angle do not have much in common.

I prefer name of unit over name of measure.

For everyone, base unit is different. Everyone in continental europe will use meter for distance, but everyone in US will use inches, etc. For me (european), "1 distance" will be 1 meter, but somebody in US will presume, that "1 distance" is "1 inch" and it is wrong approach. If the enumeration name will be SCPI_UNIT_METER, everything is clear for everyone.

It is the same as "1 ANGLE". What does it mean? I think, that it is common to use "radian" or "degree". After looking into units.c I see, that it is "1 radian". So I prefer naming everything by its right name - SCPI_UNIT_RADIAN, SCPI_UNIT_DEGREE. If you are mathematician, you will prefere radians, but if you are engineer, you may prefer degrees or revolutions.

There is problem with "MIN" and "SEC", because it can colide with time.

Did you have in mind a SCPI_Result* function, which would accept a unit and recalculate the value before printing it?

There is already SCPI_NumberToStr so I can introduce SCPI_ResultNumber to produce what you want. For now with base unit only.

I will have a look at the source to see if I can do this LOG/MUL/SUM unit recalculation without too much trouble. The inverse operation of log might not be obvious. If the base unit is not linear, POW should also be available.

I think, that we can produce some helper functions for conversions, but I don't like the idea of automatic non trivial recalculations while processing of the unit. So having conversion functions for dB, °C/°F, RAD/DEG/REV, etc. is nice, but doing this inside SCPI_ParamNumber is not so ince for me.

We can have table, how to convert some units to other units. This conversion table can support log/exp, multiplication and addition.

Regarding a use case, the user might wish to define the output amplitude of a signal generator in volts of decibel, depending on what is beeing measured.

But I still think, that it is up to developer of the generator, how he internally represent output value. If he prefer dBV, it is his choice. I don't want to force him to use V, so he must recalculate it back to dBV to do some internal calculations.

from scpi-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.