eez-open / studio

Cross-platform low-code GUI and automation
https://www.envox.eu/studio/studio-introduction/
GNU General Public License v3.0
469 stars 87 forks source link

Unable to modify X axis units and start point on graphs #190

Open kawalkQCWski opened 2 years ago

kawalkQCWski commented 2 years ago

Current graph only allow for the x units to be in time units (s). Some instruments like spectrum analyzers, Vector network analyzers , frequency generators operate in Hz units . It would be very nice to have an option to switch between units on the X axis of graphs. This function will only be useful if additionally one can specify the start point. For example a vector network analyzer will never start at 0Hz but might start for example at 5MHz and provide data at fixed frequency points. The number of points vary : 51, 101, 201 , 401, 801, 1601 ..... preferred input would be Start frequency (Hz) , frequency step(Hz), Y values
Here is an example of a frequency response of a device measured by such a unit:

Screen capture

Here is what a graph of that data looks like in the current graphing application

graph working

here is Y data (401 points ) Start is 5MHz and End is 55MHz therefore the step size is (55-5)/(401-1)=0.125Mhz

Y values .txt

kawalkQCWski commented 2 years ago

I was able to use the current graphing by padding my data to move it and my using ps=Hz ns=kHz us=MHz ms=GHz Just changing the units would be 75% of the work

image

kawalkQCWski commented 2 years ago

Current script to read data from 8714 and display it: connection.acquire();

connection.command("FORMat ASCII, 6");

var StartF = await connection.query("SENSe1:FREQuency:STARt?");
var StopF = await connection.query("SENSe1:FREQuency:STOP?");
var PointsF = await connection.query("SENSe1:SWEep:POINts?");
var StepF = ((StopF-StartF)/(PointsF-1));
var dB_Char = ("CALCulate1:FORMat?");
var freq = []; 
var level = await connection.query("TRAC? CH1FDATA");
var level_array = level.split(',');
var pad = StartF/StepF;
let data = "";       
for (var k=0; k < pad; ++k){
    data += "-80" + "\n"; 
}
for (var i =0; i < PointsF; ++i){
    freq.push(StartF + i * StepF);
    data += level_array[i] + "\n";
}

 const description = "Frequency response";

const samplingRate = (1/StepF*1000000000000); // graph units of time seconds per division)

const offset = 0;//Y offset const scale = 1;//Y muliplier

const unit = "decibel"; // voltage, current, power, decibel

const color = "yellow"; //color of trend const colorInverse = "red";

const label = "Watchout ! 1us=1Mhz, 1ms = 1GHz";

const timeScale =StopF/10000000000000; //number s on screen const channelScale = 10 session.addChart({ description, data, samplingRate, offset, scale, format: 4, // CSV string unit, color, colorInverse, label, viewOptions: { axesLines: { type: "fixed", majorSubdivision: { horizontal:10, vertical: 10 }, minorSubdivision: { horizontal: 5, vertical: 5 } } }, horizontalScale: timeScale, verticalScale: channelScale });

connection.release();

kawalkQCWski commented 1 year ago

Is there a way to get to display Hz in the X axis and can the axis start from the first data point instead of 0?