Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i create a VI that talks to the Serial Port?

Hi,
I'm a Student at Swinburne University in Melbourne studying Robotics and Mechatronics. For my final year project i am creating a new interface for a series of robots that the university has. Labview is the program that has been selected to do some of the controlling of the robot.

my task at the moment is to set up a VI which can talk to the Serial port which will be connected to a microcontroller. What i need the VI to do is to be able to send and receive characters to and from the serial port. I have looked at the Basic Serial Read and Write example and this is close to what i need, but how do i set up the block diagram of this communication? i am fairly new to Labview but i have looked through all i can and i'm not sure what i need to do to set up this basic communication.

if someone would be able to give me some advice that would be great.

thankyou

Michael Robertson
0 Kudos
Message 1 of 10
(4,285 Views)
You say it's close so what else do you want it to do? The example sends and receives characters through the serial port after setting it up. If you want to integrate the example inot your main program, you probably don't want to configure the serial port and close VISA each time. If you need to parse the responses from the micro, there are several ways to do that such as the Scan From String.
0 Kudos
Message 2 of 10
(4,278 Views)
thanks for your response Dennis.
i guess it is what i want to do, but i agree with you that i won't want to close the connection everytime i have communicated.
 
its the part of integrating this into my program which i'm not familiar with, as i've only just started using Labview.
0 Kudos
Message 3 of 10
(4,269 Views)

Hi Michael,

You can reference your instrument by entering the correct VISA alias (ie, COM1, COM2, etc.) into the VISA Resource control in the LabVIEW example program for direct communication to the instrument.  If you add a while loop to that example program (so the configure and close steps are outside the loop) and reference and configure the port properly, then you should be able to communicate with the instrument.  Are you able to do this?

Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 10
(4,241 Views)
Hi Chris.
Ah i understand what you mean by this. And this would be appropriate, but where can i find the diagram to put this while loop? i can't find the block diagram of the VI.
 
Michael
0 Kudos
Message 5 of 10
(4,236 Views)
If you can't find the block diagram of Basic Serial Write and Read, you need to start at the very beginning of learning LabVIEW. The block diagram is where all of the actual coding is done and is an extremely basic concept. Go to http://zone.ni.com/devzone/cda/tut/p/id/5199 and look at the various resources. Start with the 'Getting Started with LabVIEW' link.
0 Kudos
Message 6 of 10
(4,220 Views)
yeah i have gone through some of the tutorials and i understand how the idea of the Block Diagram and the Front Panel works. But it was just for this particular example, i couldn't find how to bring the Block Diagram up onto the screen, as it did not open when the Front Panel of "Basic Serial Read and Write" opened. I ended up placing a new feature onto the front panel, and then suddenly the Block Diagram appeared for me. So my problem is solved. Thanks for all the help guys.
I've just re-arranged that example with a While loop around everything, and then customizing the String going into the VISA write, as a concatenation of a number of different bytes depending on the command being sent.
 
thanks again
Michael
0 Kudos
Message 7 of 10
(4,204 Views)

Hi Michael,

That's great that things are working for you.  Thanks for letting us know.  For future reference, you can open the block diagram of a VI by pressing [Ctrl]+E or by going to the "Window" menu in LabVIEW and selecting "Show Block Diagram".  Best of luck to you and have a great day!

Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 8 of 10
(4,201 Views)

thanks for your help Chris.

I guess in all my rush to get all this work done i blatantly looked passed what was right in front of me... oops.

My Final Year Thesis is due on monday so its been a bit hectic.

thanks again

Michael

0 Kudos
Message 9 of 10
(4,199 Views)
Not a problem.  I hope everything with your thesis turns out great!  Good luck!!
Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 10 of 10
(4,196 Views)