Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

communicating with serial port

Hello,

 

I am trying to send commands to a motor control through COM port. Since I am working on a laptop, I use a Keyspan USB to RS-232 adapter. I mapped the adapter to COM4. If I use a serial capture program (vista unfortunately does not have hyperterminal), I can send the commands perfectly and the motor responds correctly. When I try to implement some automation in LabVIEW it gives me some errors. First of all I need to configure the COM port baud rate to 19200. When I do this, LabVIEW returns an error in arg 8 of the configure VI. I looked this up and it means that arg8 of the property node is giving a problem (This is the argument to change the flow control). However, I set the flow control to the (in the motor manual) described value: None.

If I try to just open the COM port (without making changes to the configuration) and try to write a string like "jof" to the serial port, it gives another error, that the communication is lost.

 

Anyone encounter this before?

 

Thx

Giovanni Vleminckx
---------------------------------------------------------------------------------------
Using LabVIEW 8.5 on Windows7
0 Kudos
Message 1 of 10
(2,572 Views)

Best guess is that you are running versions of Labview and NI-Visa that are not compatible with Windows7.  What version of NI-Visa are you running?

0 Kudos
Message 2 of 10
(2,567 Views)

Hi,

 

I am running LabVIEW 8.5 on a Windows Vista 32bit. How do I check which version of NI-VISA I am running?

 

Thx

Giovanni Vleminckx
---------------------------------------------------------------------------------------
Using LabVIEW 8.5 on Windows7
0 Kudos
Message 3 of 10
(2,560 Views)

Open "Measurement&AutomationExplorer" and have a look at the left column. Open MySystem-Software, there is NI-VISA. Klick it, on the right side you see infos about it.

Message 4 of 10
(2,556 Views)

 


@anita Zahr wrote:

Open "Measurement&AutomationExplorer" and have a look at the left column. Open MySystem-Software, there is NI-VISA. Klick it, on the right side you see infos about it.


The NI-VISA version is 4.5.1. Additionally, I should say that when I user the Measurement&AutomationExplorer, I can perfectly send commands like jof\r to the device, and it will act the way it should. The problem however, still remains that I cannot do it from a LabVIEW VI.

 

Giovanni Vleminckx
---------------------------------------------------------------------------------------
Using LabVIEW 8.5 on Windows7
0 Kudos
Message 5 of 10
(2,545 Views)

The fact that you can communicate from MAX proves that my theory is not correct.  Can you post your vi?

0 Kudos
Message 6 of 10
(2,538 Views)

Hi,

 

I seemed to have solved the problem myself. I guess before there was some other instance trying to use the COM port resulting in an error when I tried to open the port. I now can set the baud rate etc. and can read. It took me some time to figure out that the string (which is read to the serial instr) has to be set to '\' Codes display instead of the default setting. This solved my problem I think. I will try the complete program tomorrow to see if everything runs as it should and I will post here the result.

 

Thx

Giovanni Vleminckx
---------------------------------------------------------------------------------------
Using LabVIEW 8.5 on Windows7
0 Kudos
Message 7 of 10
(2,532 Views)

It really seems to work now, but I have an additional question regarding this topic. Can anyone help me or direct me to information about the timing w.r.t. COM ports? Because I built in a delay between a write and read command of 500ms, but the shorter it is, for me, the better 🙂

 

Thx

Giovanni Vleminckx
---------------------------------------------------------------------------------------
Using LabVIEW 8.5 on Windows7
0 Kudos
Message 8 of 10
(2,498 Views)

1) Write command

2) Read PropertyNode "Bytes at serial port" in a loop,

until you get at least one byte, wait a very short time within the loop

3) Read Bytes (one by one until termination character or all at once if you know the count, as the device offers them)

Message 9 of 10
(2,486 Views)

If you have specified an end character for read and enabled this endcharacter you can ask more bytes and it will stop at the end character.

greetings from the Netherlands
0 Kudos
Message 10 of 10
(2,481 Views)