LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a beep at specific intervals

Highlighted

Hello,

 

I was only introduced to LabView today and must create a program that will produce a beep sound at (random) intervals and then repeat the cycle for a behavioral experiment I am conducting.

In other words, I have to create something with the following trial pattern: 3s silence, 1s beep, 2s silence, 1s beep, 5s silence, 1s beep (repeat cycle).

 

I got as far adding the beep.vi and making the necessary adjustments according to this tutorial: http://www.ehow.com/how_12122458_create-sound-numbers-labview.html

but another issue I came across is the lack of synchronization between the Boolean function and the sound production from the beep (It will continue to beep after pressing "stop"). Additionally, changing the frequency values did not change its tone...and a single beep.v's frequency would not be adjustable for the trial pattern I have mentioned above.

 

I would greatly appreciate any help (visuals would be much appreciated as well). I am a complete newbie to programming and my ineptitude has been stressing me out all day.

 

Thank you!!!!

0 Kudos
Message 1 of 9
(2,770 Views)

Hi unevolved,

 

Do you have a code which I can look into? Something which you have done so far and encountered that issue? Smiley Happy

 

Thanks

 

Warmest regards,

Lennard.C

 

 

Learning new things everyday...
0 Kudos
Message 2 of 9
(2,757 Views)

Hi,

 

You may want to refer to Help>>FindExamples menu.

 

In the Example Finder you could use "sound" as search criteria.believe GenerateSound.vi is close to what you are trying to achieve.

 

Hope this helps

0 Kudos
Message 3 of 9
(2,734 Views)

Hi unevolved,

 

Sorry, I forgot to add another question. May I ask what LabVIEW version that you are running on?

 

Based on what you mention on the first point: following trial pattern: 3s silence, 1s beep, 2s silence, 1s beep, 5s silence, 1s beep (repeat cycle), I believe you'll need to use something like a state machine. I believe this might explain about state machines: http://www.ni.com/white-paper/7595/en/ and http://www.youtube.com/watch?v=JyJxNrgABsI.

 

I have created a rough program based on your cycles. The below screenshot is what i can think of based on your requirements. Presuming that you have read about the state machines from the link I have provided, I'll explain the code   

 

Basically, I have created 3 states, cycle 1 (3s silence, 1s beep), cycle 2 (2s silence, 1s beep) and cycle 3 (5s silence, 1s beep). First and foremost, you'll need to create a basic state machine structure which consists of a enum (with the state names - http://labviewwiki.org/Enumerated_type), while loop, shift registers (which passes the value from the current iteration to the next) and case structure (each with their own state). 

 

As you can see, I have a main case structure which controls if the loop operation and within it is the nested case structure which is the state machine itself. For each case, I have an array of enums (which I have specified the names to be Silence and Beep) and a for loop which contains the case structure which does both silence and beep.

 

As you noticed that the for loop has a indexing tunnel. This allows the for loop to run 2 iterations. On the first iteration, the 1st index array: Silence will be as an input for the case structure and executes Silence case state. On the second iteration, the second index array: Beep will execute the Beep case state.

 

The below is the silence state for the 1st for loop iteration:

2.JPG

The below is the beep state for the 2nd for loop iteration:

1.JPG

 

For Silence, I have used wait(ms) to provide the pause before it goes to the next state "beep".

 

The whole operation will basically repeats from Cycle1 -> Cycle2 -> Cycle3 until you hit the stop button. If you hit the stop button, the main case structure will be as below:

3'.JPG

 

Which should stop the while loop. 

 

Hope it helps.

 

Warmest regards,

Lennard.C

Learning new things everyday...
Message 4 of 9
(2,729 Views)

Hey unevolved,

 

I though I'd add a small vi which does the task you suggested.

About your beep continuing on stop:

when you click stop during a beep it takes time to stop because the beep takes 1000 milliseconds before the UI responds, you can have a more responsive stop button if you have a smaller beep

 

I've added images

 

Hope this helps Smiley Happy

 

Derick Mathew
Message 5 of 9
(2,715 Views)

added the VI

Derick Mathew
Message 6 of 9
(2,709 Views)

Hello all,

 

I apologize for the late response. Thank you so much for your help, I really appreciate it.

 

I have LabView 12, and actually created the following timed loops (please see attached).

Together they work splendidly, but the only issue I am now having is stopping both timed loops at the same time.

I made one of the timed loops stop buttons a control and changed its mechanical action to "Switch Until Released." After doing so I created a local control of that stop button and added it in my second loop, and selected it as "Change to Read."

Supposedly this would allow the stop button of one of the loops to control both; however, the loops do not stop even after I press the stop button.

 

Any ideas on this?

 

Take care.

 

0 Kudos
Message 7 of 9
(2,639 Views)

Hello unevolved

 

 

Just in case you would need it i have attached my code in 2012.

 

About the stopping problem in your latest post, you need to use the "switch when pressed", if you use the "switch until released" you will need to press and hold the stop button for a long time (in fact you would need to hold it till the VI stops).

 

 

However using this is also no the optimal solution since based on the point of where the control is in the VI, there will be a certain wait after the button is pressed and the VI actually stops

Derick Mathew
0 Kudos
Message 8 of 9
(2,592 Views)

PS pls mark as solved if this helps and if it helps Kudos are appreciated Smiley Happy

Derick Mathew
0 Kudos
Message 9 of 9
(2,591 Views)