LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My serial communication commands work in MAX but not in LabVIEW.

I have been trying to communicate over serial (RS232) with my instrument. I succeed when I use MAX, but not in LabVIEW. I checked and made sure all the details of the communication were the same in both programs. I also tried not using the VISA close function in LabVIEW, since MAX keeps the session open. This was unsuccessful. I'm wondering if there is a difference in the way the two programs are communicating. Clearly MAX is doing something that LabVIEW isn't. What could that be?
0 Kudos
Message 1 of 12
(5,024 Views)

Do a search of LabVIEW examples and look for Basic Serial Write and Read.vi.  This should be very helpful.

 

C:\Program Files\National Instruments\LabVIEW 8.0\examples\instr\smplserl.llb\Basic Serial Write and Read.vi

Matt

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
Message 2 of 12
(5,004 Views)
Unfortuantely, that is exactly the LabVIEW example VI that I have been using, and it is not working. I've also tried writing my own version, but nothing seems to work.

Message Edited by eriegler on 06-21-2006 03:30 PM

0 Kudos
Message 3 of 12
(5,002 Views)
Check to make sure you have the right termination charachters at the end of your strings.  I believe Max adds some termination charachters that LabVIEW does not automaticly do.
 
What I did was use the Instrument I/O Assistant to communicate with the com port.  Then I opened up the front panel to see the code it created for me. 
 
Brian
Message 4 of 12
(4,999 Views)

As stated, add \r and or \n to the end of your data to terminate the data.  Try \r or \n or \r\n

 

Matt

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
Message 5 of 12
(4,995 Views)
These are great suggestions so far, but also ensure that you installed NI-VISA after you installed LabVIEW.  For example, if you upgraded LabVIEW, but didn't reinstall NI-VISA, the VIs will be on the LabVIEW palettes, but they will not function.  You will need to reinstall VISA to have those functions installed in the LabVIEW directory.
Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 12
(4,978 Views)
I have double checked and made sure NI-VISA is working properly. I used the find instrument Visa, and it was successful. I do not have the instrument I/O assistant since I am currently working with the 6.1 version. Your suggestions were good ones, unfortunately nothing seems to be working. Any other ideas? Or would it be worth it to upgrae my version?
0 Kudos
Message 7 of 12
(4,969 Views)
What do you mean you used the find instrument? This only works for GPIB instruments. In MAX, if you have a com port listed, it doesn't know if there is an actual instrument hooked up to it. Did you actually create a VISA session in MAX and send and receive commands to it? If you are using one of the example VIs for serial communication, set up your write string and go to the Operate menu and select Make Current Values Default. Save it with a new name and post it please. Just want to check how you are setting up the termination characters.
0 Kudos
Message 8 of 12
(4,965 Views)
I have succesfully controlled my instrument through MAX. I used the find instrument VISA merely to make sure that the VISA functions were working in LABView. I believe I correctly attached the file. If you haven't already guessed I am fairly new to LABView. Your help is greatly appreciated.

Also, this version does not have the \n in the message, because my instrument gives me an Invalid Character error when I try to use it.

Message Edited by eriegler on 06-22-2006 01:34 PM

0 Kudos
Message 9 of 12
(4,953 Views)
If you used this version to send a \n or \r, you would not be sending the control characters. You would be sending the text "\" and then "n". In order to correctly send a LF or CR with \n and \r, you have to right click on the String to Write control and select '\' Codes Display. That is how the shipping example is set.
0 Kudos
Message 10 of 12
(4,944 Views)