From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

how to add or edit waveform data in a CTL Type Def file?

Solved!
Go to solution

I am in learning mode working with the newest RIO evaluation kit "Create Real Time Application" exercise.  I want to do something simple to modify the sound output function to produce waveforms that I make up besides included sounds "ding", "boing", etc.  I gather that (1) the data is contained in the file SoundOptions.CTL, and (2) I can use "export to clipboard" to view the existing array data, and (3) in the CTL Type Def front panel I can add a new item to the Enum.  My question: how do I associate my new item with a new1D array of data?  Or change the existing data to different waveforms?

 

Thanx!

JEB

0 Kudos
Message 1 of 13
(3,881 Views)

Hi JesseBuck,

 

Without having seen the particular example you're working with, it's hard to say exactly the best way to modify the waveforms. Is the example included in the LabVIEW Example Finder, or is it one that you found online?

 

In general, you would want to find the part of the program where the other waveforms are defined, and add a new row to the 2-d array to append new data to the list. If you can include code snippets or a link to the example you're using, I may be able to give you a better idea of the best method for your specific case.

 

Kathryn K.
Technical Support Engineer
National Instruments
http://ni.com/support
0 Kudos
Message 2 of 13
(3,862 Views)

Hi Kathryn, thanks for the feedback, I didn't find a link to the particular RIO Evaluation Kit example that I'm using, but I'll try to clarify with a picture of diagrams, attached.  The data being output to the FIFO is already stored in the CTL, somehow that I would like to understand.  Using the front panel for the CTL I find that I can add an item, as shown, but I don't see how add new data to the new item.  I do find copy and paste functions that appear to take the data from one item over to another item, but if I want to add new data I don't understand how to format it and get it pasted into the new item or something like that.  When I copy the Enum data I can't paste it into Notepad to check what's going on, but it does appear to allow pasting into another item.

 

Thanx

 

Jesse

0 Kudos
Message 3 of 13
(3,850 Views)

Hi Jesse,

 

Ok, so the Enum in this case is being used as the selector for the Case Structure. From what you included in the screenshot, it looks like you’ve added an entry to the Enum called “sssssss” but I can’t tell whether you’ve right clicked the Case Structure to make a case for each entry in the Enum yet.

 

If you’d like to post a snippet of just the Enum and the Case Structure, I can open it in LabVIEW on my end and poke around to see what else would need to be done to include a new sound in the list.

Kathryn K.
Technical Support Engineer
National Instruments
http://ni.com/support
0 Kudos
Message 4 of 13
(3,819 Views)

 Hi Kathryn,

 

Thanks for clarifying snippet usage, here is a corrected version I believe.  The SoundOptions type is SoundOptions.CTL and this file is also attached.  Thanks for reviewing the information!

 

JEB

Download All
0 Kudos
Message 5 of 13
(3,813 Views)

Hi Jesse,

 

It looks like you got about 90% of the way to accomplishing your goal, but you skipped one step. You've already modified the Type Def to add a new item to the Enum, which is probably the hardest part of the process, and now all you need to do is right-click on the Case Structure and use the option highlighted below to add a new case for "sssssss". You can model the contents of the new case after one of the pre-built cases, but it looks like just a 1-D array with values designed to be played at a given dt.

 

 

CaseStructureWithEnum.png

 

Let me know if you run into any other issues after making the new case, and I'll try to help!

 

Kathryn K.
Technical Support Engineer
National Instruments
http://ni.com/support
0 Kudos
Message 6 of 13
(3,800 Views)

Hi Kathryn,

 

I added the new case to the case structure but I'm not comprehending how to add new data.  I see the existing cases contain a 1D fixed point array, and in the newly created case the frame is empty.  It is not clear to me how the existing 1D arrays get their data from the CTL in the first place, or further how I would add some new data?  Note, I am an experienced procedural programmer but a novice with how LabVIEW gets things done.

 

Thanks,

 

Jesse

 

0 Kudos
Message 7 of 13
(3,798 Views)

Hi Jesse,

 

I can see how that would be confusing. The control's only job is to give a name to each case, so that you can tell the program from the front panel which case to run.

If we call your control an int, say, because an Enum just associates a string with a number (its placement in the list of items in the Enum), then the code would look similar to this:

 

switch(control)

case: 1

{

    int[] Sound = [-3, -3, 0, 0, 0, .....] //Ding

}

case: 2

{

    int[] Sound = [0, 0, 0, 0, 0, .....] //Boing

}

case: 3

{

    int[] Sound = [-.58, -.003, .0431, .0039, .....] //Buzzer

}

 

(Please excuse my syntax, it's been quite a while since I've done much text-based programming!)

 

What you've added is equivalent to

 

case: 4

{

}

 

Later in the program, when it pulls the info into the Audio FIFO, it's calling that Sound[] array. Because your 'sssssss' case is blank, it won't have an array to reference for that sound, and you'll probably get a broken run arrow. What you can do is copy and paste the array out of one of the other cases into your new case, and then just replace the fixed point numbers in the array with the numbers that correspond to the sound you want.

 

In terms of what numbers need to go into the array to generate the hissing sound, I'm not sure- I've honestly never worked with an Audio FIFO before- but it would be interesting to experiment. Let me know what you end up using, because I'm curious!

 

Kathryn K.
Technical Support Engineer
National Instruments
http://ni.com/support
0 Kudos
Message 8 of 13
(3,780 Views)

Hi Kathryn,

 

Thanks for clearing my disconnect on where the array data is being initialized.  I still need a hint about how to replace the numbers in the fixed point array with new numbers.  I see the options to copy and paste the entire array when I right click and select data operations, but I don't see how to change the array values.  This difficulty is probably why I thought the values were coming in from the CTL.  Also it would be nice if I could load the new array values from a text file or other type of data block that I can generate, as opposed to typing them in 1 at a time.

 

Thanks,

 

Jesse

 

Message 9 of 13
(3,772 Views)

Hey Jesse,

 

Just to make sure we're on the same page, you are trying to change the array constants in the case structure that then is wired into the data which is sent to the FIFO.

 

There is not straight forward way to do this, but I would try the methods listed in the document below.

 

Copy and Paste Data from Excel to LabVIEW - http://digital.ni.com/public.nsf/allkb/38AEA2B236E43837862574400064C7A7

 

Hope that helps!

JY
Application Engineer, RF and Communications
National Instruments
0 Kudos
Message 10 of 13
(3,744 Views)