LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I implement a variable rate beeper

I have a LV data acquistion program running in a timed loop every 2 seconds.  I need to be able to send a beep to the PC speakers whose frequency and rep rate are controlled by variables from this main timing loop.  I built a prototype of this using a timed loop containing the beeper function, sent it local variables from another timed loop and it worked ok  . I then added this same beeper loop to the DAQ executable program but it takes over and the main loop doesn't run and the PC hangs.    How can I implement this so the beeper runs in the background accepting new rates and frequencies without affecting the main loop?
I have attached the working prototype.  You can change the input value to see how the beeper works.  Note , it does not start beeping until the error magniture gets above or below 6.
Thanks,
Phil
0 Kudos
Message 1 of 10
(3,873 Views)
I'm pretty new to LabVIEW myself, but I think the problem may lie in where you are placing your timed loop in your main VI.  The loops in the VI you posted are essentially infinite loops (which I would suggest you want to control with a stop button in your main VI to stop all the loops), and if they are placed inside your data acquisition loop, once they start, the DAQ loop will never finish its iteration and will stall.  You might try to place the error loops outside the DAQ loop so they can run simultaneously.  Again, I'm not sure where you have them placed currently in your main VI, but it sounded like the main loop might be dependent on the error loop finishing in your current situation.
 
Hope this helps,
 
Mike
0 Kudos
Message 2 of 10
(3,859 Views)
Mike,
I have put the beeper loop in various places in the program but never inside the main DAQ loop.   I tried putting the beeper  right next to the main loop and I tried putting it in the initialization that happens once when the program starts and it didn't work in either location.
Btw, I am using LV ver 8.0.  I read somewhere that there might be a confict between updating waveform graphs and timer loops.  The main loop does a lot of continuous graphing and data saving each loop.  None of that happens when I add the beeper loop as if it stays in that loop and never executes the main loop. 
Phil
0 Kudos
Message 3 of 10
(3,849 Views)

Phil,

I tried adding a seperate timeloop that contained various tasks to do, such as creating a waveform graph from a simulated signal, and I was unable to replicate the stalling problem you describe.  I think it might help for you to post your main VI if possible.

Mike

0 Kudos
Message 4 of 10
(3,843 Views)
Well, the whole program is large and does not run without simulated RS485 data and some of it is sensitive (meaning proprietary to my client) so I am reluctant to post it.  I will look to see if I am doing something really stupid.   I'll let you know what I try and if it works.  Thanks for looking into this Mike
Phil
0 Kudos
Message 5 of 10
(3,831 Views)

Hi Phil,

In general running parallel operations should not be a problem. However, what Mike mentioned about the fact that the loops in your example program have no exit which would stall an outer loop. Could you possibly post pseudocode of sorts that describes you program in more detail and where the DAQ plays in with the beep? I imagine it is something simple and understanding the program flow will help solve the problem. Thanks!

Stephanie

0 Kudos
Message 6 of 10
(3,801 Views)
Stephanie,
Attached is a brief description of the main loop. 
Phil
0 Kudos
Message 7 of 10
(3,782 Views)
Could you possibly strip the proprietary code out while still demonstrating the problem and then post that code?
0 Kudos
Message 8 of 10
(3,778 Views)
I stripped out all the beeper code and redid it and it started to work (sort of) but I don't see what changed to make it work.  I did find that the Stop Timed structure was not working for some reason so I created another boolean global to send a stop condition to the beeper loop and that worked.  Right now it's all working but I don't trust it yet since I don't know what was wrong before.  It may be that I thought I was setting the beeper loop to a reasonable period but it was actually zero at the start.  I imagine that would cause it to never relinquish time for the main loop and cause the symptom I was seeing. 
Thanks for all the suggestions.
Phil
0 Kudos
Message 9 of 10
(3,738 Views)

Glad to hear its working! Let us know if you do run into any issues. Smiley Wink

Stephanie

0 Kudos
Message 10 of 10
(3,727 Views)