LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with tone generator with onset and offset cosine ramping

Highlighted

 

I am trying to use an event structure to enable 40ms onset and offset ramping of tones produced by left and right channels of the sound card when the respective buttons are pressed and released. I want the tone to be on as long as the button stays pressed.  My issue is that when the time out terminal of the event structure is specified as 100 ms ( I am using 100ms tone samples), only offset ramping occurs, but when I reduce the time out to say 10 ms, only onset ramping occurs. If the time out is about 40 to 50 ms, onset and offset ramping occurs but not consistently. I am new to event structures and I cant figure out why this is happening. Any advice will be very helpful.

Here is the main and the sub VIs (onset and offset cosine ramping).

Thank you so much.

 

 

0 Kudos
Message 1 of 3
(144 Views)
Highlighted

Hi Kumar,

 

why don't you cleanup your VIs to assist in debugging (and understanding) all those VIs?

It also helps to provide "nice" icons to all subVIs - avoid those icons with "open" borders like your onset/offset VIs: they are hard to select!

Never delete the labels of FP items!

 

Your main VI could look like this:

There also is a race condition between your event structure and the terminals of the Left/Right buttons: the boolean button values are (most probably) read before the event occurs…

 

(I included a proposed new subVI to create your cosine signal: you can use this in both onset & offset VI to simplify their code!)

Btw. these onset/offset VIs should take a waveform as input/output instead of plain 1D arrays! This way they can easily adapt to changed samplerates/dt of the waveforms, no need for constants in your code!

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 3
(64 Views)
Highlighted

 

Hi GerdW,

 

Many thanks for your advice. I have now cleaned up the VIs and used your suggested codes to simplify the onset and offset VIs. They worked well.

 

Sorry, I did not understand this..."Btw. these onset/offset VIs should take a waveform as input/output instead of plain 1D arrays! This way they can easily adapt to changed samplerates/dt of the waveforms, no need for constants in your code!".... 

 

Thanks for pointing out the possibility of the race condition. Is it possible to use a sequence structure to make sure the event occurs before the left/right boolean values are read?

 

Btw, I tried to check the waveform of the data that comes out of the event structure (labelled waveform 1 as indicated in the screenshot) and it does what I intended to do, cosine ramps occurring both at onset and offset of the tone. But the shaping (at onset) does not occur after the data passes through the right/left case structure. 

 

Thank you so much for your time. Glad there is a forum to ask for help. 

 

Regards

Kumar

screenshot2.png

 

 

 

 

0 Kudos
Message 3 of 3
(36 Views)