Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication through an USB-to-serial converter

Solved!
Go to solution

Hello all,

 

I have a pretty basic application that communicates through an RS-232 port with a motor driver (made in-house). I have developed it on a desktop computer (Windows7. LabVIEW 2009), with a true serial port. I worked fine, as expected.

 

I had to move it to a laptop, for a sort of traveling test stand. Windows7 again, no serial port though, I had to use an USB-to-serial adapter. I installed LabVIEW Runtime Engine, VISA runtime, moved my executable - it did not work. No errors, just the motor did not move.

 

I installed LabVIEW on the laptop, copied the source over, and rebuilt the executable there. It still did not work. But if I run the software from the source, it works!

 

I have also noticed something else: my program does not exit LabVIEW when I exit my main vi (I forgot to do that). If I launch my executable and I exit it (beacause it does not work), I still have the front panel open. If I restart it from the Run (arrow) button, it works, it communicates with my driver.

 

I don't know if it's the serial converter (this is the only hardware change between my working and my non-working setups), or something else I am overlooking. I would appreciate any hint on how to solve this problem.

 

It may not be relevant: I have another instrument in the setup, connected through a USB-to-GPIB adapter. I have no problem reading from it, even when using my non-working executable.

 

Thank you!

 

0 Kudos
Message 1 of 7
(7,531 Views)

Can you double check, and make sure your cable is functioning properly on another computer. Also use the VISA Interactive control located at NI-MAX>>Tools>>NI-VISA to test the comunication, and see if it errors out or not. 

National Instruments
Applications Engineer
0 Kudos
Message 2 of 7
(7,506 Views)

Thank you for replying, Edna-S.

The cable I use is the same for both configurations, it never failed to work while I was using the desktop.

I am afraid it would not be very straight forward to use the VISA tools to test comunication with this particular driver. I have used these tools very often for friendlier instruments, where the message to be sent is easy to build, and, even better, I can read something back from them. I can't read anything back from this driver, the motor movement is my only indication that it works.

It is still very intriguing to me that everything works fine from the programming environment, but not from the executable (cables don't change). It is very consistent so. It looks like something not being loaded/initialized properly when I run the executable.

I will try to see if I can make the VISA tools do something for me. The setup is currently being used in the awkward way I described in the first post: launching the executable, exiting it without exiting LabVIEW, and then re-starting the vi from the toolbar. It better did not work at all :).

0 Kudos
Message 3 of 7
(7,501 Views)
Solution
Accepted by topic author adina25

Problem solved, by explicitly setting the baudrate (14400) of the communication port in the program.

 

My program allowed the user to select which COM to communicate with, but the initialization settings were done before the user had the chance to select it. The default value of my VISA resource control was COM1, which was ok for the desktop computer, but not for the laptop (COM3). When re-launching the stopped vi, I already had COM3 selected, and the setting was applied to the right port.

 

As an "excuse", I must say I had set the baudrate to the right value (14400) in Control Panel, and I thought that was enough.

 

I would appreciate if somebody can explain to me if the Windows port settings are ignored (or reset to default) when LabVIEW is launched. I realize that is good practice to do all the settings in the software, and I normally do it (except this time when I set the wrong port). I very much want to know this for the future.

 

Thank you.

0 Kudos
Message 4 of 7
(7,491 Views)

This might give you an idea, where you can set that in LV: http://digital.ni.com/public.nsf/allkb/266901441F6BD12786256C30004D2361

I would recommend to keep one question per forum post to get better answers for your question.

National Instruments
Applications Engineer
0 Kudos
Message 5 of 7
(7,451 Views)

Thank you very much! Helpful link, sorry for the extra question.

 

0 Kudos
Message 6 of 7
(7,427 Views)

No problem. Good luck.

National Instruments
Applications Engineer
0 Kudos
Message 7 of 7
(7,405 Views)