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: 

Paralel loops and serial communication

Solved!
Go to solution

TimBotsM

                 If you use 1st method then you are going to read 16 bytes. If you read 0 then wait for timeout time (Automatically) and display no device connected.

 

Here if you are using 1 VISA read then you are using less resources. Any other reason why 2 VISA read ?

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 21 of 29
(655 Views)

No, no other reason to use a 2nd readout.

However you got me thinking and combined with your statement that one 16 byte read uses less resources than two times 8 (makes sense) I think I'll change my code soon.

 

About my last example, what do you think about the theory from that code? Is it something you would create or are there better solutions?

0 Kudos
Message 22 of 29
(653 Views)

See if in your VI you only want to write and read from multiple device connected to serial port then I will never go for queue  becasue according to me this can be done without me (I think). Like I mentioned in my first attachment this can be acheived without queue.

 

Are you sure you have to use QUEUE, as I am not knowing completely your application. Try to make it as simple as it can be and try to remove QUEUE.

 

I think it will work !!!

 

Thanks

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 23 of 29
(648 Views)

@TimBotsM wrote:
 

@@Todd_Lesher I'm using the "Queued Message Handler" design patern. So in order to stop all the loops I put in the "exit" string and all the loops should release their queue and stop. If one of the loops enters the "exit" state they'll queue an "exit" (whitout error check) command to the main handler, is the main is already gone, fine, if not, this will stop all the other loops.

I guess with Scuttling you mean something to dump the queue. The "Queued Message Handler" design patern should do the same.


If the "Release Queue" primitive is called when the dequeue is waiting, dequeue will error instead of timeout. Someone on the forums called it that, with respect to sinking the boat, yes.

It looks like you have a good handle on things. It would be simpler to just send the queue reference in without bundling it each time, but bundling it allows you to create different queues - either for the different instruments, or for different commands/responses.

0 Kudos
Message 24 of 29
(640 Views)

The thing is that my program is already stuffed with all kind of queues and notifiers. This is due to the design pattern used.

 

Aside communicating to this rack I also need to communicate to 4 other devices, maintain a UI and (later on) run a testing sequence.

 

So I have 7 loops running in parallel just to get a testing sequence up-and running (the goal). So in order to prevent any data dependency's between all the different loops (and thus preventing Labview from running the code in parallel) I need some mechanism to keep all the data in the correct order.

 

I think queues are the best solution to this. (otherwise my code will end in Labview spaghetti)

0 Kudos
Message 25 of 29
(640 Views)

See this is serial communication and communication will occure serially hence it should be possible to write the code without using QUEUE. You can maintain UI for that also.

 

Try and let me know

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 26 of 29
(634 Views)

As told in the start post I'm using the "Queued message handler" design patern so i'm kinda stuck with queues. (see the "Continuous Measurement Data Logger" excample)

Below in a screenshot of it's main VIContinuous Measurement Data Logger.png

 

So altough it is not required (even UI) to use queues I'm stuck with them since all my design patern is based on queues.

0 Kudos
Message 27 of 29
(631 Views)

There is no hard and fast rule my friend. Solutions always comes from problems, if problem is new the solution should be new. No one never told you have to use this solution only.

 

But if you already decide then what can be done.

 

Let me know if you need any help

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 28 of 29
(628 Views)

@Ranjeet_Singh Thanks for your support and if I have other problems I'll post it in this forum

0 Kudos
Message 29 of 29
(624 Views)