LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

save data

Please see attached *.jpg file, how to save data to a file?
 
 float64     *data=NULL; 
........
ArrayToFile ("result1.dat", data, VAL_DOUBLE, COUNT, 1,
                         VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS,
                        VAL_CONST_WIDTH, 10, VAL_ASCII, VAL_APPEND);
..........
FATAL RUN-TIME ERROR:  "temp", line 2165, col 30, thread id 0x000001C0:   Array argument too small (800 bytes).  Argument must contain at least 25600 bytes (25600 elements).
0 Kudos
Message 1 of 6
(3,572 Views)
The attachment is missing but it is probably not essential to the discussion.
I am not familiar with float64 units, but the error you reported suggests the array is not correctly dimensioned according to the number of elements you pass to ArrayToFile function.
Can you please attach some code more, i.e. the allocation of *data array?


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 2 of 6
(3,567 Views)

float64     *data=NULL;
     
DAQmxErrChk (Read_AcqAndGraphVoltageExtClk(taskHandle,data,sampsPerChan*numChannels,&numRead));

ArrayToFile ("result1.dat", data, VAL_DOUBLE, COUNT, 1,
                          VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS,
                          VAL_CONST_WIDTH, 10, VAL_ASCII, VAL_APPEND); 

The code is from Help-Finder, if I write "data" to a file, error occurred. Whe the example does not give the dimension? Is there a default size? How to define a specified size to data?  Thanks a lot.

 

 

0 Kudos
Message 3 of 6
(3,560 Views)
Hello,
it seems that dimension of your  "data" is sampsPerChan*numChannels.
I think in your code you should find a memory allocation like "data = malloc(sampsToRead*numChannels*sizeof(float64))" or an allocation using "calloc" function.
Practically your data size is composed by: number of samples to read, number of channels, and the size of the variable data (float64).
 
 
You can increase or reduce the data size changing one of these parameters.
 
To write your data in a file, you must select the "data type" as "double precision" (VAL_DOUBLE), and the Number of elements as "sampsToRead*numChannels".
Message 4 of 6
(3,554 Views)


@mwibm wrote:

float64     *data=NULL;
     
DAQmxErrChk (Read_AcqAndGraphVoltageExtClk(taskHandle,data,sampsPerChan*numChannels,&numRead));

ArrayToFile ("result1.dat", data, VAL_DOUBLE, COUNT, 1,
                          VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS,
                          VAL_CONST_WIDTH, 10, VAL_ASCII, VAL_APPEND); 

The code is from Help-Finder, if I write "data" to a file, error occurred. Why the example does not give the dimension? Is there a default size? How to define a specified size to data?  Thanks a lot.



The answer to this question is possibly COUNT keyword: NI examples frequently are hard-coded in that some parameters are defined as macros at the top of the source code. So, where is COUNT defined and which value is assigned to it?


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?
Message 5 of 6
(3,550 Views)
Also, Read_AcqAndGraphVoltageExtClk is a front-end to native DaqMx function: inside this function are probably located functions for dynamic allocation of *data array from which you can derive its size.


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 6
(3,546 Views)