LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Opening file in NI-HWS (Hierarchical Waveform Storage)

Hi
we have created waveform using analog waveform editor . We are tring to generate this wave form using PXI6711 in CVI . The Code used for generating is as follows
niHWS_OpenFile ("D:\USB Project\pace500.hws", niHWS_Val_ReadOnly,
&fileHandle);
niHWS_GetWfmReference (fileHandle, "NULL", "NULL", &wfmReference );
niHWS_ReadAnalogI16 (wfmReference, 10000, samples, wave1);
//niHWS_WriteAnalogI16 (wfmReference , 1000, samples);
AO_Configure (1, chanel, 0, 0, 10.0, 0);
memcpy (wave_two, samples, sizeof(samples));
memcpy (wave_two + 50, samples, sizeof(samples));
WFM_Scale (device, 0, 1000, 1.0, wave_two, wave_bin_two);
WFM_Load (device, 1, chan,wave_bin_two, 1000, 0, 0);

WFM_Group_Control (device, 1
, 1);

In niHWS_OpenFile we need to define the file path accordingly path is defind but it is not reffering the file and throughing any error . I have tried giving some arbitrory file which is not exit still it is not throughing error . Would like know is there definit format define the file name .Pl help

Apriciate your help

Regards,

Sharanu
0 Kudos
Message 1 of 6
(4,325 Views)
I'm not familiar with the HWS API, but from a strictly C sense, your path is incorrect because you are not escaping your backslashes. Instead of "D:\USB Project\pace500.hws", you should specify "D:\\USB Project\\pace500.hws".

Regarding the lack of an error, it is possible that the HWS library does not have CVI user protection code, which is what shows you errors at run time. The functions do, however, return status codes. You should check the return values of the functions to determine if an error occurs. For example:

tHWS_Status status;
tHWS_FileHandle fileHandle;
status = niHWS_OpenFile("D:\\USB Project\\pace500.hws", niHWS_Val_ReadOnly, &fileHandle);
if (status != 0)
{
// error handling code here
// e.g. call niHWS_GetErrorString to get
and
// display the error message
}

One more thing I'd like to point out is that CVI's interactive execution window, which is tied to the function panels, is a convenient way to interactively experiment with an API to help you debug issues. Let us know if this helps.
Message 2 of 6
(4,325 Views)
Thanks for your input .Now i have the status valu=0 for file opening But the next step is giving error as negative value . Could you pl help me with the issue

istatus =niHWS_GetWfmReference (fileHandle, "NULL", "NULL", &wfmReference );

Apriciate your help

Regards,
Sharanu
0 Kudos
Message 3 of 6
(4,325 Views)
From the niHWS_GetWfmReference documentation, it looks like you need to pass NULL or the empty string for the second and third parameters if there is only 1 group and only 1 waveform. You are passing the string "NULL" rather than the value NULL. You need to change this to

istatus = niHWS_GetWfmReference (fileHandle, NULL, NULL, &wfmReference);

This assumes that there is only 1 group and only 1 waveform in the file.
0 Kudos
Message 4 of 6
(4,325 Views)
We apriciate your quick resopnse . Now we are able to see the samples read from the file . Do we have to convert the samples to binary? We tried converting with the following functions

memcpy (wave_two, samples, sizeof(samples));
WFM_Scale (device, 0, 1000, 1.0, wave_two, wave_bin_two);
WFM_Load (device, 1, chan,wave_bin_two, 1000, 0, 0);

With the above function the samples converted "wave_bin_two" shows "0" .

Is there any other method to out put the samples?

Pl help me with this

Apriciate your help again

Thanks & Regards,

Sharanu
0 Kudos
Message 5 of 6
(4,325 Views)
Again, I'm not very familiar with the waveform editor or the libraries you are using, so someone else might be able to answer your question more directly, but here's what I see.

You use niHWS_ReadAnalog16 to read the data from the waveform file as an array of 16-bit integers. The documentation states that you can use this function to read this data only if the data is stored in the file in this format. Is this how you stored the waveform? I assume that there is a configuration setting in the analog waveform editor that you can use to specify the data format.

You call WFM_Load to write the data out to the DAQ board. You have to pass the data as an array of 16-bit integers to WFM_Load. So, if the data in the file is an array
of 16-bit integers, and you read the data out using the function that populates an array of 16-bit integers, it seems that you should be able to pass that array directly on to WFM_Load.

The purpose of WFM_Scale is to convert an array of doubles to an array of 16-bit integers. With your current implementation, you don't have an array of doubles, so you shouldn't need WFM_Scale.

One other thing is not clear to me from your code. What is the data type of samples? It needs to be an array of 16-bit integers, large enough to hold all of the data returned from niHWS_ReadAnalog16.
0 Kudos
Message 6 of 6
(4,325 Views)