LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple plots & Y-scales

Hello,

I am in the process of moving away from LabVIEW towards CVI.  The first task is to redo the HMI in CVI.  In our old code, we have a chart with multiple plots (each with their own scale / Y-axis), which are independently turned ON/OFF, Autoscaled, and so forth.  You can see that in attached picture.  I would like to ask how I can accomplish the same thing in CVI, be it with a Graph or a Chart.  And by the way, what are the differences between these two in CVI?

0 Kudos
Message 1 of 15
(5,720 Views)

If you're new to CVI I would suggest having a look at the example finder (Help/Find Examples). CVI comes with several examples of graph plotting, e.g., graphs.cws or 2yaxis.cws.

Basically, in your program you will need to read some controls (toggle switches, check boxes...) where the user can set the desired graph properties (autoscale yes/no, lin/log scale...) and then programmatically set the respective value.

 

However, if you want to have that many Y axes you will have to do some extra work, a good starting point is the contribution of RobertoBozzolo here

 

Also in CVI strip charts are intended for continuously updated data (e.g., adding one data point per time unit), whereas graphs are more general.

 

Feel free to ask more specific questions.

 

Message 2 of 15
(5,714 Views)

Thanks Wolfgang,

I realize that I want to plot a chart instead of a graph (want to input single values instead of arrays).  Question is: how do I superimposed multiple charts together?

0 Kudos
Message 3 of 15
(5,699 Views)

If you take a look at the sample I posted, linked to by Wolfgang, you'll see that I really plot all diagrams on a single graph, using other graphs just to show their scales, paired with the main graph. Unused graphs are painted in transparent to "hide" them.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 15
(5,694 Views)

Thanks Roberto,

I wonder how I can achieve the same thing with charts.  They are different from graphs.

0 Kudos
Message 5 of 15
(5,691 Views)

You're right, charts are different from graphs; what's more, your design scenario is different from mine, since you need to plot continuously while in my example all data processing is performed at process completion and plots are drawn in a single pass. 

 

Nevertheless, it seems to me that the paradigm I am using can be adapted to your application: the magic is to plot values on the graph/chart with appropriate scaling so that a point in the diagram matches with the corresponding scale on the inactive diagram. You should be able to correcly plot your measures by multiplying each value with the ratio diagram-full-scale / axis-full-scale.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 6 of 15
(5,671 Views)

Roberto,

Can you explain to me this:

 

Scan (msg, "%f[x]%f[x]%f[x]%f[x]%f[x]%f", &ii[i], &nn[i], &vv[i], &tt[i], &ww[i], &ee[i]);

 

What I do not understand from the command is the [x].  Looked into the .dat file and can see the numbers.  I suppose they are separated by the tab character?  Just curious why you did not use the comma ( , ) and have it as a CSV.  I come from the C# background, so please help me.

0 Kudos
Message 7 of 15
(5,657 Views)

 

I need help.  There are some other things I do not understand from the sample code:

 

1.  There are values defined in the .H file such as:

 

#define Main_vr             5
#define Main_diag        6
#define Main_s              7
#define Main_eLbl        8
#define Main_wLbl        9
#define Main_vLbl         10
#define Main_nLbl        11
#define Main_tLbl         12

 

then on the Panels palette I see items named:

 

vr

diag

s

eLbl

wLbl

vLbl

nLbl

tLbl

 

How are these items linked together?

 

2. From attached picture, you can see the format some elements are  ABC_something, with ABC defined in the beginning of each section.  Can someone explain to me this way of definition.  I do not quite understand this.

 

3. From the plotting code:

 

// SPEED
QScale1D (nn, ndata, yp, &max);

scaleN = Scala (max, normalType);
Set1D (c, ndata, scaleN); Div1D (nn, c, ndata, yp);
pH = PlotXY (panel, Main_diag, ii, yp, ndata, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, VAL_MAGENTA);
SetCtrlAttribute (panel, Main_s, ATTR_YAXIS_GAIN, scaleN);

 

QScale1D() outputs its value to work array 'yp'.  Then later on, Set1D() also outputs its values to 'yp'.  What is the point of doing this?

0 Kudos
Message 8 of 15
(5,654 Views)

The scan function has many different format codes, consisting of formatcode and identifiers, see here.

 

The [x] discards the termination character.

 

Note that this is not one of the ANSI C functions (scanf, fscanf) but one from the NI formatting and IO library.

0 Kudos
Message 9 of 15
(5,643 Views)

Controls in the CVI environment are addressed as PANELID_CONTROLID format so coming to mine example you have a panel named 'Main' and a control named 'vr': you address it as 'Main_vr'. This is the way CVI uses to define and use controls: you have no way of altering this paradigm. Please note that manual modification of the include file associated with the UIR file is to be avoided since it is automatically rebuilt when you modify some UI object.

 

Coming to your Q3,  Scale1D scales data in the range 0-1 in the output array yp which I don't use at this moment. The function also returns the maximum value found in 'max' variable, which I am using to define an appropriate scale for the axis in Scala function. Following Set1D + Div1D functions are used since there is no built-in function to divide an array with a scalar.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 10 of 15
(5,639 Views)