From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

QMH / Actor based Serial Port Module - bidirectional communication

Solved!
Go to solution

Hi,

 

I'm using QMH to manage an equipment (eg power supply) via serial port. The states are initialize, set voltage, set current, read voltage, read current, close. From other loops, I can enqueue to get this MHL to process the action. How do I read back the data from read voltage / read current? I want the caller to wait until the data is returned. There may also be situations where there is timeout. Is there a way to wrap this nicely?  

0 Kudos
Message 1 of 5
(1,201 Views)

Why do you want to have a separate loop to handle instrument operation? It seems you need a synchronous control of the instrument, maybe you can use a simple API that you can call whenever you need to communicate with the instrument. The caller will always wait until the method in the API is executed and if data is returned, the caller can easily get it. Unless the instrument is sending data continuously (and caller has to always listen for data) I don't think a separate loop (thread) is appropriate.

Lucian
CLA
0 Kudos
Message 2 of 5
(1,174 Views)

Hi Lucian,

 

In some cases, I can use idle state or one of the states to perform update query (eg update voltage / current to indicators). I can also perform self error recovery based on this. There could also be cases where the instrument needs to be 'ping' within an interval to keep it alive. 

So far I have no issue getting it to work, by adding another queue to act as reply, just that I wonder if there's a better way to do this (especially when there are multiple cavities sharing the same power supply). 

0 Kudos
Message 3 of 5
(1,154 Views)
Solution
Accepted by topic author kokthiam.chiam

Include a queue reference in your messages to the QMH.  Then QMH can then use that reference to pass data back.  I tend to make API VIs that will create the return queue, send the message, wait for the response, and then destroy the return queue.


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
Message 4 of 5
(1,125 Views)

Hi Crossrulz,

 

Thanks for your suggestion. 

 

 

0 Kudos
Message 5 of 5
(1,120 Views)