04-20-2015 05:27 AM
Hello, I'm trying to draw an x-array and a y-array using ploXY function; but an inclined line is composing on my graph. I'm using that code:
plot_handle = PlotXY (testler, TESTLER_GRAPH, inputNumber, amplitude, 1024, VAL_INTEGER, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_DOT, 1, VAL_RED);
In this code, inputNumber is an integer, amplitude is a double value. I'm drawing a point in the each 'for' loop using the plotXY in the above; but an inclined line that is between 0 and the last produced point, is also composing together with my correct points.
How can I prevent this inclined line?
04-20-2015 05:52 AM
Hello,
I am not sure if I understand you correctly but you should provide data arrays, not individual points: PlotXY will plot all the data in the two arrays by itself, you do not need an extra loop. So inputNumber should be an array of integers: inputNumber [ 1024 ].
04-20-2015 07:56 AM
I want to draw my graph instantly. I take my data from e3631a dc power supply. I can draw the graph after obtaining my all data; but I want to draw my graph simultaneously while taking my data from e3631a. During drawing this graph, I'm encountering unexpectedly with an inclined line from 0 to the value that is read in current.
What can I do to avoid this unexpected line?
The following is a part of my code:
double sonuc;
int plot_handle;
int CVICALLBACK CBBasla (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
FILE *fp;
switch (event)
{
case EVENT_COMMIT:
int i;
fp=fopen(fileName,"a");
fprintf(fp,"\n\n Input Number Amplitude Upper Level Lower Level Status\n\n");
for(i=0;i<1024;i++)
{
hpe363xa_queryOutputCurr3631 (vi, 1, &sonuc);
lowerlevel[i]=-3;
upperlevel[i]=3;
amplitude[i] = sonuc;
if (amplitude[i] > upperlevel[i] || amplitude[i] < lowerlevel[i])
{
status[i]='F';
}
else
{
status[i]='P';
}
fprintf(fp," %d %9.5f %9.5f %9.5f %c\n",inputNumber[i], amplitude[i], upperlevel[i], lowerlevel[i], status[i]);
inputNumber[i]=i+1;
plot_handle = PlotXY (testler, TESTLER_GRAPH, inputNumber, amplitude, 1024, VAL_INTEGER, VAL_DOUBLE, VAL_SCATTER, VAL_EMPTY_SQUARE, VAL_DOT, 1, VAL_RED);
}
fclose(fp);
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
}
04-20-2015 08:06 AM
If you really want to update your graph so many times (note that it might slow down your data acquisition) you only should plot the data you have acquired, i.e., use something like
plot_handle = PlotXY (testler, TESTLER_GRAPH, inputNumber, amplitude, i+1, VAL_INTEGER, VAL_DOUBLE, VAL_SCATTER, VAL_EMPTY_SQUARE, VAL_DOT, 1, VAL_RED);
Right now you are plotting all 1024 data points, even if you have measured only 5 - the other data values probably are zero, and because you are plotting all of them, you see a line to ( 0, 0 ).
04-21-2015 03:08 AM
Hi Eren.
is your problem solved?
If no, what's missing?
If yes, good Then please mark the appropriate answer as solution.
04-21-2015 06:49 AM - edited 04-21-2015 06:53 AM
There is always the good old way, maybe not brilliant but working
oldX = 0.0; oldY = 0.0; while (condition) { // Acquire new measures // Values stored in X, Y variables PlotLine (..., ..., oldX, oldY, X, Y, ...); // Save last values acquired oldX = X; oldY = Y; }
04-21-2015 07:45 AM
Hi Wolfgang,
I solved my problem with your solution. Thank you vey much.
Regards.