LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

button for while loop won't work

Solved!
Go to solution

cap.PNG

Hi all,
I am a beginner in the Labview. I did a serial communication program ,firstly write a command than start data acquision,During running VI, the data is continuously obtained.But When I want to stop the startDAQ button ,this button doesn't work ,it cann't be pressed in front panel.
One more thing,Why I use event structure ?because I have some commands,so these buttons(event structure) respond immediately. If I don't use this structure, is there any other way?
Can anybody help me, please?

0 Kudos
Message 1 of 5
(2,814 Views)

Hi Steveson,

 

read the help for the Event structure. And read the caveats section of the help!

 

1. Don't hide the event structure inside a case: the event structure should be able to react on events at all the time.

2. By default the UI is blocked until an event is handled. You start your event using the "startDAQ" button so you cannot use this (or any other button) to stop this event case…

 

Suggestions: Think about restructuring your application. Think about proper statemachine. Think about queued message handlers.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,805 Views)
Solution
Accepted by topic author USTCSteveson

You definitely should be looking at using a Queued Message Handler for your serial port communications.  This way, the reading can happen in parallel to your main loop.  You just use a queue to send a message to the QMH to send a message, close, setup, etc.

 

Also, DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

The Bytes At Port causes all kinds of weird race conditions with your instrument.  Use your instrument's protocol.  Do you know what the protocol of your instrument is (ie, how the data message is formatted)?  Binary communications typically either use fixed sized messages (all messages are the same length) or the length of the message is embedded into the header of the message.  Use this information instead of relying on the Bytes At Port.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 5
(2,785 Views)

 Thank you for your reply .I want to use the queued message handlers.method, but there are too few serial communication data projects in this way.

Is there any relevant information to learn?  Thanks!

0 Kudos
Message 4 of 5
(2,765 Views)

Here is a quick example I just put together.  Far from complete, but a good place to start.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 5
(2,727 Views)