LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

front panel button slows application

Hello,

I'm writing an app that uses a state machine.  It is a data acquisition system that uses custom USB hardware.  Under normal circumstances, it runs just fine.  Data are read from the USB device and processed in time to prevent backing up and overflowing the USB device buffer.  The problem is, when I start streaming data to the hard drive.  It backs up and overflows the buffer.  This is not constant, but only at the start.  After the start, the buffer is immediately read back down to minimum, so I know the code that streams to the hard drive is not executing too slow.  Also, I already have the file open, so it isn't that.  With some experimentation, I've been able to determine that the problem is the time the computer takes up when I click on the 'record' button.  The longer I hold the left mouse button down, the more the buffer backs up.  If I link a hot key to it, it does the same thing when I press the hot key.  I'm relatively inexperienced with LabVIEW, and I was wondering if there might be a trick to get around this.

Thanks.

 

0 Kudos
Message 1 of 17
(3,704 Views)

Hi Rickford66,

 

How are you handling the events associated with the record button? Are you continuously polling the button or using an event structure?

 

From your description it seems like the “mechanical action” property of the record button may not be properly set. The “switch/latch when pressed” and “switch/latch when released” settings work differently. Right-click the control to set the “mechanical action” property. Can you upload a copy of your code?

0 Kudos
Message 2 of 17
(3,690 Views)

Hi,

 

Thanks for the post!

 

How are you testing the state of the button, polling or event structure?

 

I guess it would help to see your code if possible. 

 

Kind Regards,

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 3 of 17
(3,687 Views)

At this point, the code is very complex, so I'd rather not post it.  If I have to, I'll make a simple version, but I'll cross that bridge if I have to.  Anyway, I am polling the buttons in state '-1', (again, it's a state machine), building an array, then searching the array for the T button.  The acquisition T/F is at the end of the array, so its case executes if nothing else does.  All buttons are set to latch until pressed again, so that no states are ever missed.  I manually set them to false in the case that services them.

0 Kudos
Message 4 of 17
(3,684 Views)

Hi,

 

Thanks for the reply.

 

I would suggest looking into event structures (see examples in the example finder), as these are less processor intensive.

 

They handle registoring the button press for you - and then you can excute the relavent code related to the button press. 

 

Kind Regards,

Message Edited by Hillman on 10-27-2008 04:54 PM
Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 5 of 17
(3,681 Views)

There is no "Latch until pressed".  Perhaps you have Latched until released?

 

Try latched when released..

0 Kudos
Message 6 of 17
(3,676 Views)
I've used events a number of times, but I don't see how that will help.  If, for example, I put event cases all over the screen, the code will become unreadable.  I will have to scroll and scroll..... and scroll and scroll.... and scroll some more to see all the possible events that could happen.  If not, I feed the events into a case, but doesn't that bring me right back to polling?
0 Kudos
Message 7 of 17
(3,673 Views)

Sorry, I wasn't clear.  The state is 'switch when pressed' which stays in the active state until the button is pressed again, or until the local variable is set to false, as in my case.

 

0 Kudos
Message 8 of 17
(3,672 Views)

Ideally your code should be structured so that you handle all (most) the events in one event structure. A producer/consumer arcitecture will help you achieve this. The producer loop handles the user interface and the consumer can implement a state machine. LabVIEW ships a template of the producer/consumer (events) architecture. Select "File>>New..." and then expand the "From Template" node in the "New" dialog.

 

0 Kudos
Message 9 of 17
(3,668 Views)

I think I'm getting the picture.  I'll look into this a bit deeper to see if this will solve my problem.

Thanks.

 

0 Kudos
Message 10 of 17
(3,665 Views)