LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer/consumer acquisition - consumer timing & stopping

Hi user123,

 

The for loop and break were exactly what I needed.

Well, you don't use the stop condition of the FOR loop right now. Right-click the loop border and enable it!

Btw. can these function in the loop run parallel or should the be sequenced using an error wire?

 

I had an issue with the dequeue waiting indefinitely when i pressed stop, due to no timeout. I have added some logic to that, which I found from another thread on here: if stop = true > timeout = 50ms > else timeout = -1

Wrong! What happens when your Dequeue already waits for a new element when you press the stop button?

Set a timeout of 100ms (double the wait time of your producer loop) and handle the timeout output of the Dequeue function!

 

Is this what you meant by reading start/stop time before/after loop?

Have you seen jwscs' image above?

Your implementation is similar, but might give slightly different results… (THINK DATAFLOW!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 11 of 12
(302 Views)

Exactly what I needed… Not that I have done it right ha…

 

Ah ok I see. Even this way, it seemed to improve stopping time, because it stopped as soon as its current cycle finished, instead of current cycle + next cycle. But yes, I have now added the conditional terminal, which is breaking out immediately. Thanks for that one.

 

Ok maybe I am doing something wrong. Although my wait time is set to 50ms, it takes 3-4s to acquire & queue the data.  Therefore setting the wait time of consumer to 100ms timeouts in between every queue. I would have to set the consumer wait to 4500+? Then this feels very sluggish when you click the stop button.

 

What I have tried instead, is to integrate the enqueue function within the forloop, so that it doesn’t have to wait for the whole array to send to the queue? Then put dequeue in a forloop also. Then putting a 100ms wait. This seems to keep it responsive, however I now have some undesired behaviour.

Currently, if the user clicks stop half way through the poll, the other half of the array is empty, and all the numeric indicators will get wiped. Ideally what I would like is for the array to just show its previous values, and only update with new values from the queue if they exist. Then all the indicators will just display their last values and not be blank.

 

PS. I haven't got round to trying the sequence structs for start/end time yet.

Thanks

0 Kudos
Message 12 of 12
(271 Views)