Hi All,
At the moment I'm acquiring data from a NI DAQ at 1 kHz per channel for up to 16 channels. Because of the required speed, I'm saving the data in a binary format. To be able to process the data, I'd like to convert is to e.g. ASCII. At first I tried using the FileToArray and ArrayToFile functions to read binary and write ASCII, untille I noticed that ArrayToFile only supports up to 6 digits output. I the dicided to write my own conversion, but I'm having some problems with the data arrangement. In the piece of code below the way I read my binary file is shown. This is working fine:
GetFileInfo (filename_read, &size);
points = (int)size/sizeof(double);
strcpy(temp,filename_read);
temp[strlen(temp)-4]='\0';
sprintf(filename_read_cfg,"%s.cfg",temp);
result = cfg_file_read_int(filename_read_cfg, "Number of channels", &columns);
data = malloc(points*sizeof(float64));
FileToArray (filename_read, data, VAL_DOUBLE, points, columns, VAL_DATA_MULTIPLEXED,
VAL_GROUPS_AS_COLUMNS, VAL_BINARY);
For the ASCII part I tried using something like this:
i=0;
do
{
ProcessSystemEvents();
transfer = cluster*columns;
if (cluster*columns*(i+1)>points) transfer = points - cluster*columns*i;
file_wr = fopen (filename_write, "a");
for (j=0; j<transfer; j++) r=fprintf(file_wr,"%e,", (double) data[cluster*columns*i+j]);
fclose(file_wr);
// r = ArrayToFile (filename_write, &data[cluster*columns*i], VAL_DOUBLE, transfer, columns,
// VAL_DATA_MULTIPLEXED, VAL_GROUPS_AS_COLUMNS,
// VAL_SEP_BY_COMMA, 10, VAL_ASCII, VAL_APPEND);
ProcessSystemEvents();
SetCtrlVal(panelProgressHandle,PANEL4_PROGRESS_BAR,((double)(cluster*columns*i)/(double)points*100.0));
if(r<0) break;
i++;
if((cluster*columns*i)>=points) break;
}
while (!r && !ProgressCancel);
as you can see, I was first using ArrayToFile, with VAL_DATA_MULTIPLEXED and VAL_GROUPS_AS_COLUMNS options. I don't know how to incorporate these options in the fprintf part, and without them the output is a complete mess. If someone could give me a pointer, I would appreciate that very much...
Greeting,
Ward
Message Edited by Ward on 11-28-2005 02:59 AM
Message Edited by Ward on 11-28-2005 03:00 AM