Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting based on time

Measurement Studio Standard Version.
 
I collect 3 sets of data from a PLC each set of data is collected by the PLC over a given time period.
 
For example:
My first set of data is collected over 10 seconds.
My second set of data is collected for 3 seconds starting after 2 seconds.
My third set of data is collected for 4 seconds starting after 4 seconds.
 
I need to plot these 3 data sets on a graph.
 
The number of data points in each set is random. In other words. Dataset #1 may contain 10 values or it may contain 100. I read the PLC to find the length of each data set.
 
The X scale should always read from 0 to the longest time, in this case 10 seconds.
 
Lets say that dataset 1 has 100 values, data set 2 has 30 values and dataset 3 has 60 values.
 
I know that dataset 1 has 100 values collected over 10 seconds, so there are 10 data points per second.
I know that dataset 2 has 30 values collected over 3 seconds, so there are 10 data points per second.
I know that dataset 3 has 60 values collected over 4 seconds, so there are 15 data points per second.
 
I need to plot these 3 data sets so that data set 1 will start plotting on Plot#1, after 3 seconds dataset 2 will start plotting on Plot#2 and after 4 seconds data set 3 will start plotting on Plot#3.
 
In summary,
 
Plot#1 will have 100 y-axis values plotted between 0 an 10 on the x-axis scale.
Plot#2 will have 30 y-axis values plotted between 3 and 5 on the x-axis scale. 
Plot#3 will have 60 y-axis values plotted between 4 and 8 on the x-axis scale.
 
Is this possible?
 
Thanks,
Bob Hiller
 
0 Kudos
Message 1 of 5
(6,630 Views)
Bob,

The CWPlot.PlotY function accepts two optional parameters:  xFirst and xInc.  You can use these parameters to start the plot not on the origin.  For instance:

CWGraph1.Plots(1).PlotY plot1, 0
CWGraph1.Plots(2).PlotY plot2, 40
CWGraph1.Plots(3).PlotY plot3, 60

This will display three different plots starting at the 0, 40, and 60 x value.

Attached is an example that plots three different sets of data of varying lengths at different starting points.

Let me know if you have any questions.

Tyler Tigue
NI


0 Kudos
Message 2 of 5
(6,615 Views)
Tyler,
I modified your Command1_Click as follows:
 
Private Sub Command1_Click()
    CWGraph1.Plots(1).PlotY plot1, 0        'Plot plot1 starting at 0
    CWGraph1.Plots(2).PlotY plot2, 30       'Plot plot2 starting at 30
    CWGraph1.Plots(3).PlotY plot3, 40       'Plot plot3 starting at 40
End Sub
 
This matches my example of:
    Plot#1 will have 100 y-axis values plotted between 0 an 10 on the x-axis scale.
    'Plot#2 will have 30 y-axis values plotted between 3 and 5 on the x-axis scale.
    'Plot#3 will have 60 y-axis values plotted between 4 and 8 on the x-axis scale.
0 Kudos
Message 3 of 5
(6,612 Views)

Tyler,

I will try again. I modified you Command1_Click sub as follows:

Private Sub Command1_Click()
   
    CWGraph1.Plots(1).PlotY plot1, 0        'Plot plot1 starting at 0
    CWGraph1.Plots(2).PlotY plot2, 30       'Plot plot2 starting at 30
    CWGraph1.Plots(3).PlotY plot3, 40       'Plot plot3 starting at 40
End Sub

This reflects my sample data:

    Plot#1 will have 100 y-axis values plotted between 0 an 10 on the x-axis scale.
    Plot#2 will have 30 y-axis values plotted between 3 and 5 on the x-axis scale.
    Plot#3 will have 60 y-axis values plotted between 4 and 8 on the x-axis scale.

First in this example I need the X axis to Read 0 to 10, not 0 to 100. In other words I would like to specify what the X-Axis scale reads.

Secondly, The 2 and third plots start in the correct place on the x-axis but they do not end up in the correct place.

Pleae read this agian and let me know if it is possible

    Plot#1 will have 100 y-axis values plotted between 0 an 10 on the x-axis scale.
    Plot#2 will have 30 y-axis values plotted between 3 and 5 on the x-axis scale.
    Plot#3 will have 60 y-axis values plotted between 4 and 8 on the x-axis scale.

Thank you,

Bob Hiller

0 Kudos
Message 4 of 5
(6,612 Views)
Bob,

The third parameter of PlotY is xInc, which can be used to plot the points between a range.  Replace the three plot commands with the following:

CWGraph1.Plots(1).PlotY plot1, 0, ((10 - 0) / 100)                  'Graph 100 points between 0 and 10
CWGraph1.Plots(2).PlotY plot2, 3, ((5 - 3) / 30)                      'Graph 30 points between 3 and 5
CWGraph1.Plots(3).PlotY plot3, 4, ((8 - 4) / 60)                      'Graph 60 points between 4 and 8

The general formula for plotting points should be

CWGraph1.Plots(plot).PlotY plotData, xStart, ((xEnd - XStart) / numPoints)

Tyler Tigue

0 Kudos
Message 5 of 5
(6,577 Views)