Signal Generators

cancel
Showing results for 
Search instead for 
Did you mean: 

Import MATLAB generated ascii file into Analog Waveform Editor

Solved!
Go to solution

Hi All,

 

I have been trying to create new waveforms by the Analog Waveform Editor. I have some waveform generated from MATLAB and saved as ASCII files, following the instruction on this NI webpage, but it didn't work correctly. For example, if I produce a column filling with 0.5, and import the file into the Analog Waveform Generator, all I get is a huge series of random number. Did I miss some steps in importing the waveform?

 

Thanks!!

0 Kudos
Message 1 of 9
(7,843 Views)

Hi Boto,

 

The webpage you linked is actually a KnowledgeBase article that talks about transferring data to LabVIEW Development environment, but this may be different for the NI Analog Waveform Editor.

 

There are instructions for importing awaveform in the NI Analog Waveform Editor Help file and there also are special considerations for importing ASCII files. Here is the ASCII import excerpt:

 

ASCII Import Considerations

  1. To import ASCII data, the data must be in column format.
  2. Only one waveform can be imported at a time. However, the file can contain multiple waveforms as long as they are separated by tabs or commas. You can specify the Column Number of the desired waveform during import using the File Import dialog box.
  3. If header information is present in the file, you can use the File Import dialog box to specify a Start Row other than one to offset to the beginning of the data.

 

Would you mind uploading the ASCII file you are testing to the forum?

 

What version of the NI Analog Waveform Editor are you using?

Sam Burhans
Senior Product Manager
National Instruments
0 Kudos
Message 2 of 9
(7,821 Views)

Hi Sam,

 

Thanks for your reply.

Please see the attachment for one of the the ascii files I was trying to import as tests. I did make the data into a column and there was no header. The file was saved in Matlab using: save(filename,'x','-ascii','-double','-tabs').

I am away from the machine right now so am not sure what version of Analog Waveform Editor it is, but I remember installing it with the DVD/CD that shipped together with NI PXI-5412 and completed some updates afterward. I will let you know the version number tomorrow when I am in the lab again.

 

Thanks for your help!

Boto

 

 

0 Kudos
Message 3 of 9
(7,805 Views)

Hi again, Sam,

 

The version of Analog Waveform Editor I am using is 1.2.1.

 

Thanks,

Boto

0 Kudos
Message 4 of 9
(7,780 Views)

Boto,

 

When you open AWE 1.2.1, a wizard appears asking if you want to select an existing waveform or a blank waveform. Select Blank Waveform and click OK. Select the desired Sample Rates (S/s) and device you are using then click OK. The select File >> Import, and browse/select your file. Keep the default settings for Delimiter and Decimal Point and clikc OK.  I have tried the following on your file that you attached, and it imports without error this way.

 

Regards,

 

Jason L.

 

Product Support Engineer
National Instruments
0 Kudos
Message 5 of 9
(7,764 Views)

 

Hi Boto,

 

I took the same steps as Jason to open the ASCII file in the Analog Waveform Editor (version 1.2.1) and received a period of a triangle waveform (note the timing may be off because I only used the default sample rate):

ASCII_Test.PNG

Sam Burhans
Senior Product Manager
National Instruments
0 Kudos
Message 6 of 9
(7,757 Views)

Hi both,

 

Thanks very much for your help! I followed the same steps as you described and was able to load the waveform without problem. I am not sure what went wrong when I tried last time, but it could be I selected the wrong device.

 

I have an associated question: In the program, is there a real difference between 1) using the .HWS files generated by the Analog Waveform Editor, and 2) reading in the ascii file using Read From Spreadsheet File.vi and use niFgen Creat Waveform (DBL).vi to create the waveform? Is there any specific advantages in terms of using the HWS file and niFgen Creat Waveform From File (HWS).vi directly?

 

Thanks again!

Boto

0 Kudos
Message 7 of 9
(7,741 Views)

Boto,

 

HWS are heirarchal binary files where as your file is ASCII. Remember, with ASCII you have a binary number that represents a character, so for each character you have in '1.6666666666666666e-04' in your file, you will have a binary number representing the ascii value. A separate binary value will be reperesenting the ascii characters of '1', '.', each '6', 'e', '-', etc. 

 

With a binary file format, you can represent the value of 1.6666666666666666e-04 with much less bits. This means that ascii are going to be easier for a human to read (you can use notepad) but HWS will be easier for a computer to read, because numbers are just saved as 0's and 1's and there is less of a translation for your computer to make to convert each ascii character string into a single number. You (and your computer) can only interpret HWS and other binary formats with existing knowledge of how the 0's and 1's were saved in the file. This API to save and load HWS is built into AWE and the driver already so your computer is going to process HWS files a lot faster and they will have a smaller footprint on your computer's hard drive space. 

 

Regards,

 

Jason L.

Product Support Engineer
National Instruments
0 Kudos
Message 8 of 9
(7,736 Views)
Solution
Accepted by topic author boto

Just for your reference, I was able to almost halve the size of your file just by saving it as .hws. Also to address your previous point, you may have issues opening/importing your .txt file because it may have been open in another program at the same time. Make sure you have it closed in notepad or Excel or any other programs that may still be latching onto the reference.

 

Regards,

 

Jason L. 

Product Support Engineer
National Instruments
0 Kudos
Message 9 of 9
(7,735 Views)