LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generic questions about the Basic Serial read and write VI

Hello,
 
  I have several questions and/or comments about the Labview example "Basic Serial Write and Read".  My past programming experience has been done via text files, so the "block diagram"/gui concept of "programming" in LabView is causing me some problems. My questions are  as follows...
 
  1. How many times does the comm port get initialized with the usual parms (baud rate, etc). Past programming experience via "text files" allowed me to specify the com port ONCE. So how do I allow the user to specify the com port parms once before the rest of the program executes?
  2. The serial device I am communicating with outputs unsolicated serial data/messages when hardware errors exist in the customer hardware, this is causing numerous framing errors when I try to initialize the com port. So after searching thru this forum for "framing errors", I have realized that I need to do the following to my program, they are
    1. Find a way to initialize the com port ONCE, BEFORE the rest of the program executes (How would I do this?)
    2. Put a delay after the com port is initialized, to allow the parms to take effect
    3. clear/flush the com port buffer to eliminate garbage from the input buffer
Regards,


Kaspar
0 Kudos
Message 1 of 7
(3,119 Views)
Normally you initialise the comport once alsoin labview.
You can ignore all errors by throwing the error away connect it e.g. to an indicator that is invisible or try to behave your subvi not to give the error dialog when an error pops up.
 
Opening the port already activates it to the baudrate and other parameters set in MAX. If you did not set these in MAX you get 9600 baud no handshaking and 8 bits no parity.
 
If you have questions or need an example just ask.
 
greetings from the Netherlands
0 Kudos
Message 2 of 7
(3,115 Views)

The com port gets configured by VISA Configure Serial Port so if you only call this once in your program, it will only get configured once. Usually, a program has a while loop in which the main code resides. The configure would be done outside the while loop. You put a delay in the program with a Wait (ms) or Delay function. These are on your Time & Dialog palette. You flush the buffer with the VISA Flush I/O Buffer function. This is on the VISA>Visa Advanced>Interface Specific palette.

The example is just a starting point. The entire thing is not intended to be used as a subVI or run continuously. The configure serial port and the VISA close functions are things that would normally be done once you write your own program.

Message 3 of 7
(3,113 Views)

Hello,

 

  What is MAX and how do your configure it to automagically configure the com port parms?

Regards,


Kaspar
0 Kudos
Message 4 of 7
(3,103 Views)

Hello,

   I agree and understand the concept of having "the main program" inside a while loop and the com port fig is before the while loop starts and the com por close is after the main while loop ends. The problem I am having is the GUI/visual programming enviornment in Labview. So in order to present a screen/dialog to the user to specify the comport parms, do I have to create another while loop that when it is exited goes into the main while loop? So do I have a boolean button defined in the first while loop that is pressed when the com port config is complete that will allow the program to go into the "main while loop".  I think that you are right is that I naively assumed that the Basic serial read and write example can be used as a standalone vi.  

 

Regards,


Kaspar
0 Kudos
Message 5 of 7
(3,093 Views)
Okay, I think I understand where the confusion is now. If you're going to have a program that automatically starts when loaded, then yes, you can have a separate while loop that does nothing but wait for a user to press a "Start" button is one way to do it. You do not have to put anything else inside this loop. While the first loop is running, the user can set the com port and it's settings on the front panel and those would be programmed between the wait for start loop and the main loop.
Message 6 of 7
(3,075 Views)
Hello,

  Thanks for getting back to me about the confusion that I am having. WHen I started using Labview and was very impressed (still am, always will be) about how easy it is to create a awesome looking front panel very quickly. The confusion I am having it adapting to the GUI interface for the block diagram that is often referred to as "code". Before I started using Labview, "code" was defined as text files that you made with your favorite editor and ran it thru a compiler and linker. So I am starting to get used to the concept of the GUI programming.
  Thanks again for the help, I will most likely have more questions, the deeper I get into my project.
Regards,


Kaspar
0 Kudos
Message 7 of 7
(3,046 Views)