LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create arbitrary waveform with PXI-5412 Arbitrary Waveform Generator in LabVIEW VI?

I am attempting to use the PXI-5412 to create an arbitrary waveform based on a .csv with 1048576 values, all of which are between 1 and -1. I am able to create the waveform fine in the NI-FGEN Soft Front Panel and then read the waveform with a PXIe-5122 oscilloscope. However, when I attempt to generate the waveform in a LabVIEW VI using the same csv file I get an error saying "File size is not a multiple of 8 bytes." I am trying to use the "niFgen Create Waveform From File (DBL)" vi to import the data from the file, is it because the data is not double-precision floating-point? If so how would I convert the data to that format? I'm not 100% clear on the differences. I have attached a screenshot of my VI and of a small portion of the data.

 

Edit: When I adjust the data to make the file a multiple of 8 bytes I then get the error "Requested waveform length is invalid, because the number of samples is not an integer multiple of the waveform length increment. Requested Value: 20315462 Waveform Length Increment: 4" 

Download All
0 Kudos
Message 1 of 17
(2,598 Views)

Hi Trekkie,

 


@Trekkie123 wrote:

However, when I attempt to generate the waveform in a LabVIEW VI using the same csv file I get an error saying "File size is not a multiple of 8 bytes." I am trying to use the "niFgen Create Waveform From File (DBL)" vi to import the data from the file, is it because the data is not double-precision floating-point? If so how would I convert the data to that format?

Edit: When I adjust the data to make the file a multiple of 8 bytes I then get the error "Requested waveform length is invalid, because the number of samples is not an integer multiple of the waveform length increment. Requested Value: 20315462 Waveform Length Increment: 4" 


Even though I didn't work with this device and its driver so far there are several problems visible in your message - see the highlighted words…

 

You use a CSV file but the function expects a "File (DBL)": I guess (aka I don't know for sure as I didn't read the help for this function) the file should contain just DBL values as created using the WriteBinaryFile function. This assumption also fits to the error message of expected "File size multiple of 8"…

 

How did you adjust the "data to multiple of 8 bytes"? Did you just edit the Excel worksheet?

 


@Trekkie123 wrote:

I'm not 100% clear on the differences.


A CSV file is a text file, containing data separated by delimiters. A file containing DBL values most probably is created using WriteBinaryFile…

 


@Trekkie123 wrote:

I have attached a screenshot of my VI and of a small portion of the data.


While it was ok for me to look at those pictures to help to understand your messages most often you will be asked to provide real code and real data file.

You wouldn't go to a garage to have your car repaired with just a photo of your car!?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 17
(2,533 Views)

Thanks for the response. I was able to write it to a binary file using the write binary file vi. However, now I receive the error

"Requested waveform length is invalid, because the number of samples is not an integer multiple of the waveform length increment.

Requested Value: 2
Waveform Length Increment: 4"

 

Multiplying the data by two does not seem to resolve the error. Any idea what might be causing it?

 

Edit: I attached the VI

0 Kudos
Message 3 of 17
(2,529 Views)

Hi Trekkie,

 


@Trekkie123 wrote:

However, now I receive the error

"Requested waveform length is invalid, because the number of samples is not an integer multiple of the waveform length increment.

Requested Value: 2
Waveform Length Increment: 4"

Multiplying the data by two does not seem to resolve the error. Any idea what might be causing it?


How many DBL values did you save to the file?

Why should it help to "multiply" all those values with 2?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 17
(2,505 Views)

There were 1048576 values in the file.

0 Kudos
Message 5 of 17
(2,501 Views)

Hi Trekkie,

 

I don't have the fGEN toolkit installed, so you need to check on your own:

It seems you are using an example VI provided by NI for your task. Which file did that example use before and how many samples does it contain?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 17
(2,495 Views)

It wasn't using a file, it was creating its own waveform in the vi and using it to generate an arbitrary waveform. I switched it to read data from a file.

0 Kudos
Message 7 of 17
(2,488 Views)

Hi Trekkie,

 


@Trekkie123 wrote:

It wasn't using a file, it was creating its own waveform in the vi and using it to generate an arbitrary waveform.


Again: how many samples did the wavefrom contain?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 17
(2,463 Views)

Hi Trekkie,

 

what happens when you also start with an array of 256 DBL values?

 

Do this more or less the same way as shown in the example by using the UtilCreate function.

When this works then you replace the UtilCreate function by its "DBL" instance.

When this works then you change the number of samples to larger values. Determine which #samples still works.

When you are satisfied with the results you replace the UtilCreate function by a simple FOR loop creating the same amount of samples.

When this works you replace the FOR loop by a ReadFromFile function to (again) create an array of samples of the required amount…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 17
(2,449 Views)