05-13-2014 10:37 PM
Hello every,
I use CVI to collect save and display data, which from Serial port (Data from a custom equipment. Use a NI RS422 board and NI industrial PC to receive).
The baud data is 256k (parity:0, dataBits:8, stopBits:1), and the real transmission speed is 15kB/S,each group of data contains 3 bytes.
After processing the requirements of the curve displly rate is 10Kpoints/s.
Data collection and saving are going well (that means save data at 15kB/S to files is OK), but when I add show curve funciton ( PlotStripChart()), the runing become so slowly (the speed down to 2kB/s). So up to 80% of the data is lost.
Due to the integrity of the data related to the integrity of the waveform,so it is not feasible to reduce cuve of sampling points.
So ,I can only separate data acquisition and waveform display, to ensure the integrity of the waveform.
But it can only realize the waveform playback, and unable to realize to the real-time display of waveform.
I want to know what controls or methods in CVI can realize the real-time display of the waveform(10Kpoints/S).
The following is the code of serial port callback
void uartcallback(int portNo,int eventMask,void *callbackData)
{
...
if(i<=SIZE_BUF)
{
ComRd (COMNU, buff, i);
flag_err=0;
}
else
{
err_count++;
flag_err=1;
SetCtrlVal (panelHandle, PANEL_NUMERIC3, err_count);
}
...
for(k=0;k<i;)
{
//Head parsing
if(buff[k]==170)
{
//data processing
value[0]=(double)fabs((buff[k+1]-(64+0)))*10*0.038912;
value[1]=(double)fabs((buff[k+2]-(64+0)))*10*0.038912-3;
//data save
fprintf(fp_ys, "%d", buff[k+1]);
fprintf(fp_ys, ",%3d\n", buff[k+2]);
fprintf(fp_ch, "%f", value[0]);
fprintf(fp_ch, ",%3f\n", value[1]+3);
//show curve,lead data lost
PlotStripChart (panelHandle, PANEL_STRIPCHART, value, 2,0, 0, VAL_DOUBLE);
k=k+3;
}
...
}
Thanks!
05-14-2014 04:57 AM - edited 05-14-2014 05:02 AM
First of all, try setting the stripchart to match your process characteristics if possible. With that I mean:
- disable autoscaling on Y axis and set axis limits appropriately
- set the number of points to the total number of measures you plan to acquire
this will exclude that part of the processor power and time is spent in reformatting the stripchart and possibly will permit you to follow your process.
If this does not satisfies your requirements, the closest alternative that implies less code modifications is to use PlotPoint on a graph instead of a stripchart: 10k points on whichever screen you may have should be enough to correctly represent the phenomenon.
Another alternative is to use PlotLine: you will need to remember on every point acquired previous X and Y values to pass to the function.
In any case, you may have a significant increase in displaying speed by reducing the number of points plotted: if your process does permit so, you could only plot for example 1 measure every 10 acquired in real time, leaving the ability to plot the entire set of data in post processing. This could apply also to the stripchart.
Finally, changing the way you are saving data to disk will help in making your code cleaner: as a general rule, file I/O access in large chunks is better that a moltitude of fprintf a few bytes each. I suggest you to consider moving save-to-file lines out of the acquisition loop, keeping them in memory should not be problematic with nowadays machine which are plenty of memory.