LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

strange problems about my projects(efficiency,event structure,queue)

hey,guys,i am a labview user from china,so forgive me about the chinese words of my projest. i found something wrong with my work. .


there are two functions in my "While loop", the first one depends on "queue" and  is to get information from UART, the second one is "event structure" to send information through UART. my problems:

 

1. i can not stop while loop by pressing "停止“, and i find two ways to stop it. first, i press"停止”,then, i press any buttons that can trigger "event structure"twice, at last, while loop can stop.the second way, i press buttons for "event structure" one time, then "停止”, and then the same button for"event". it also works

 

2.my work does not run efficiently. you guys can try. once you press buttons for "event structure", it responses very slowly,and if you press many times,the whole program seems like suspending.i have added a LED named test at the front panel, it should light once you press "运行“. and it also shows how slow the whole program is.

 

i have attached my work, and my main vi is "串口通信 主VI".

 

can any body give me some suggestions? thanks a lot

 

 

0 Kudos
Message 1 of 21
(2,725 Views)

from looking at the code firswt thoughts are put a small delay in the while loops say 5ms.(under timing menu, wait(ms).vi) I have not run your code. This delay allows the system to perform tasks in a timely manor and the while loops dont take over, Another problem i have had is that i was taking data from the queue quicker than i was placing data into the queue. This lead to loops etc waiting  for data to appear on the queue. May be worth checking

Please remember to accept any solutions and give kudos, Thanks


LV 8.6.1, LV2010,LV2011SP1, FPGA, Win7
0 Kudos
Message 2 of 21
(2,718 Views)
i cant check the code right now, but going from description:
1 sound like your reading buttons outside the event structure, causing the need for 2 events to get the right value.
2 sounds like a greedy loop, some loop consuming all cpu.
/y
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 21
(2,713 Views)

i think once i press"停止“,the whole while loop should end, why should i also press buttons for "event"?

0 Kudos
Message 4 of 21
(2,711 Views)

hey,Akiel

 i have let my while loop to wait 5ms. but the problem still exists.....from your suggestions,  should i check how much data has arrived at queue?

0 Kudos
Message 5 of 21
(2,709 Views)

to get a queue status look into synchronisation>queue operations>get queue status.vi. 

 

hoipe it helps

Please remember to accept any solutions and give kudos, Thanks


LV 8.6.1, LV2010,LV2011SP1, FPGA, Win7
0 Kudos
Message 6 of 21
(2,706 Views)
Do you handle the stop button as an event also? Do you have a timeout on the event case? If not the program will halt until an event happens, explaining the behaviour.
/Y
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 21
(2,705 Views)

hey,Yamaeda

i make the control button to control the whole loop, and the event has not time out paremeter.this sould be the problem, but if i wire a time value to the "event structure".it can not realise my purpose. in this loop, i want get value countinuely through queue and press button to send something  through uart.

0 Kudos
Message 8 of 21
(2,700 Views)

hey,Yamaeda

      after adding time out, i can finish the while loop with control button. but the problem is that after timeout event happens, i can not trigger event, so this approcah can not solve my problem

0 Kudos
Message 9 of 21
(2,693 Views)
Your event structure will execute exactly once per loop of the main loop, thus the other three loops must stop before handlig the next event. You will also get a race condition between the top loop and the events when writing.
I'd put the top loop as the timeout case in the event and place the loop around the event for starters.
/Y
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 21
(2,677 Views)