LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Questions about several Serial Communication connections

I have doubts about my LabVIEW code. I have to acquire data from several equipments using Serial Communication (RS232). This is a simple example of my code:

 

 

 

1st Question: Is there a way to generate Error dialog boxes from all equipments without have to connect the General Error Handler.vi to every single connection? (red box in the picture)

 

2nd Question: How could I simplify the code inside the blue box? I'd like to use Or logical comparators from several inputs.

 

3rd Question: If I receive a error from Serial connections (True from any Or port), I have like to break the execution of the remain code (at the orange box). There's a way to break the execution of a LabVIEW program in the middle of the code?

 

Thanks in advance!

 

Klein



Message Edited by Klein on 11-28-2007 11:57 AM
Download All
0 Kudos
Message 1 of 6
(3,257 Views)
Klein,

1. Use the Merge Errors function.

2. Use the compound arithmetic/logic function. It is found in both the numeric and boolean function palettes and can be expanded to as many inputs as you need.

3. You cannot break out of a sequence structure. Each frame will execute after the previous one completes. You could put a case structure inside each frame, but that gets rather awkward quickly. A better approach is to use dataflow and not use the sequence structure at all. A state machine architecture for your entire program would make it more versatile, more robust, and easier to modify.

4. You did not have question 4, but another comment is appropriate. Rather than duplicating the serial code 4 times, create an array of the Sources and feed that to a for loop containing the code once. Put the error cluster in a shift register and the error handler outside and you do not need the merge errors or more than one error handler. The serial code and the error handler can easily be incorporated into a state machine as well.

Lynn
0 Kudos
Message 2 of 6
(3,248 Views)

Klein,

1.  Use Merge Errors.vi to combine to one error and feed to one Simple Error Handler.vi

2.  On Boolean palette, use Compound Arithmetic.vi and select "OR" as mode (left click to change).

3.  Not sure I completely understand your question here.  You could feed the output of blue box into a case statement and execute code for error or no error condition.

-cb

0 Kudos
Message 3 of 6
(3,247 Views)

Thanks johnsold and 10Degree for your replies.

Question 1: I had already tried this: Use Merge Errors.vi to combine to one error and feed to one Simple Error Handler.vi. I'm not sure if I'm using correctly the Merge Errors. This is because if I receive 4 errors from the Serial connections, when I use Merge Errors, the Simple Error Handler only displays one dialog box for only one error... I'd like to visualize all the four source errors. See the picture, I used the build array.vi to merge errors and input this into the Merge errors.vi and I used 2 Merge Errors.vi to compile the four inputs. The solutions displays me one only error dialog box.

Question2: Ok guys. I didn't know this function. It works great! Thanks.

Question3: "A state machine architecture for your entire program would make it more versatile" Johnsold. I'm not sure what it means. The LabVIEW is a typically dataflow programming language. This is ok. How could I program my code in a state machine architecture?

Advice4: "Rather than duplicating the serial code 4 times, create an array of the Sources and feed that to a for loop containing the code once" Ok, I got it. This simply the organization of the code.

"Put the error cluster in a shift register and the error handler outside and you do not need the merge errors or more than one error handler. The serial code and the error handler can easily be incorporated into a state machine as well."  I'm really lost with this advice: "...error handler can easily be incorporated into a state machine as well" How can I do this, Johnsold?

"You could feed the output of blue box into a case statement and execute code for error or no error condition" This is a good solution, 10Degree.

I rebuild the code:



Message Edited by Klein on 11-28-2007 01:26 PM

Message Edited by Klein on 11-28-2007 01:28 PM

Message Edited by Klein on 11-28-2007 01:31 PM
Download All
0 Kudos
Message 4 of 6
(3,232 Views)
A state machine is often implemented as a while loop with a case structure inside. There are examples which come with LV (File >> New.. >> VI >> From Template >> Frameworks >> Design Patterns...).

Here is a very simple state machine based on your serial example. It also shows the error cluster in a shift register.

Lynn
Message 5 of 6
(3,224 Views)

Johnsold,

It was really a great advice! I finally understood how to build a code using the State Machine concept with LabVIEW.

Thanks a lot!!!

 

Best regards,

Klein

0 Kudos
Message 6 of 6
(3,199 Views)