LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

plotting the samples on labWindows

 

Hi all

 

I have a simple question. Suppose i have a buffer which has a capacity of 32K samples. If  the samples of  1st Sine wave are in the odd positions of the buffer and if the samples of  the 2nd sine wave are in the even positions of the same  buffer. How can i plot the two sine waves on the same graph accurately. The x-axis is the no. of samples and y-axis the amplitude of sine waves.

 

Regards

0 Kudos
Message 1 of 8
(4,888 Views)

Have you looked at the help for PlotWaveform() ? It seems that you can call it twice, using values of 0 and 2 for the initialX and xIncrement parameters on the first call, then using values of 1 and 2 on the second call. With your choice of line styles, colours etc to suit each plot. Haven't tried it myself but it appears to do what you want.

 

JR

0 Kudos
Message 2 of 8
(4,878 Views)

Hi JR,

 

I beg to differ... PlotWaveform uses an array of Y values. For graphic visualization the function needs some information about the horizontal axis, i.e. an offset (initialX) and an incremental value (xIncrement), according to xi = (i × xIncrement) + initialX 

 

I would assume that it is necessary to split the buffer into two.

 

Wolfgang

0 Kudos
Message 3 of 8
(4,872 Views)

I stand corrected - there is a similar facility when plotting Stripcharts and being without my CVI system to try it, I assumed there was also one for Graphs. Sorry.

 

Back to my mid-afternoon coffee!

 

JR

0 Kudos
Message 4 of 8
(4,869 Views)

It might be worth a feature request - cloning the function PlotStripChart to a new function PlotYGraph...

0 Kudos
Message 5 of 8
(4,864 Views)

In any case, splitting an insterleaved array is easy using Decimate () function: Decimating factor must ewual the munber of signals interleaved in input array and Averaging parameter must be 0.

In mhs case these two instructions should be enough to split measures:

 

    Decimate (MeasArray, nSamples * 2, 2, 0, OutArray1);

    Decimate (MeasArray + 1, nSamples * 2, 2, 0, OutArray2);

 

where:

MeasArray is the interleaved array

nSamples is the numer of samples-per-channel

OutArrayX are the output arrays



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 6 of 8
(4,849 Views)

hi  JR and Roberto

 

 

I am using the plotwaveform but still there is the problem

 

the odd and even samples are mixing with each other. my statements are

 

 

void SetRealBuffer(float far *lpBuf, long num);

 

void SetRealBuffer(float far *lpBuf, long num)
 
{
    int i, r;
    //float magnitude,mem_mag=2;
 double offset=0;
 
 
     //GetCtrlVal(panelHandle,PANEL_POINTS,&points);
       //GetCtrlVal(panelHandle,PANEL_AMPLITUDE,&magnitude);
     //GetCtrlVal(panelHandle,PANEL_OFFSET,&offset);
    
    
             for (i = 0; i < num;i+=2)
    {
               *(lpBuf+i) = (float)( magnitude1
                            * sin(6.28318*(double)i/2048)
                            + offset);
     
    }

 

 

 

 PlotWaveform(panelHandle,PANEL_WAVEFORM, (LONG far *)lpBuf,32768,VAL_FLOAT,1,0,1,2,VAL_CONNECTED_POINTS,VAL_SIMPLE_DOT,VAL_SOLID,1,VAL_BLUE); 


 PlotWaveform(panelHandle,PANEL_WAVEFORM,(LONG far *)lpBuf,32768,VAL_FLOAT,1,0,0,2,VAL_CONNECTED_POINTS,VAL_SIMPLE_DOT,VAL_SOLID,1,VAL_RED );

 

 

I also use the decimate function but it didnt work , plz reply

0 Kudos
Message 7 of 8
(4,785 Views)

As Wolfgang pointed out, my suggestion to try to use initialx to separate the data points was incorrect. The Decimate() function recommended by Roberto requires double data types, whereas your code uses floats. Perhaps you could try again using matching data types and if it still doesn't work post the code that uses the Decimate() function.

 

JR

0 Kudos
Message 8 of 8
(4,775 Views)