LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

usb virtual serial port

Hi all,
I've spent a lot of time tring to figure ot the problem by myself and looking for an answer in this board without success so this is my problem :
I need to communicate with an instrument connected through an USB port seen as a COM port. The software given with the instruments works fine. Hyperterminal works fine. LabWindows doesn't work. A typical command is "SYSTEM:REMOTE\r" when sent via the original software or Hyperterminal the instrument goes in the remote mode while when I send the same command with LabWindows the communication freezes and I must restart the instrument. I monitor the serial port and the command and the termination character are the same in all cases. I tried with some general labwindows code for serial comunication given here without success.
An interesting thing is that even attempts to send same command using the serial port monitor were unsuccesfull. The only idea that came to my mind is the time that elapses between characters sent : hyperterminal send a series of characters with a certain amount of delay between them (letter typing) while labwindows and the monitor program maybe send the characters too close each other. Is there any way how to put a delay between characters sent while sending a string?

cheers,
Geiland
Labwindows 7.1- LabView 8
0 Kudos
Message 1 of 14
(5,566 Views)
If all your instrument cares about for termination is the "/r" byte, then you can just send each byte separately with a delay of your choice (useless loop, Delay(0.1) or whatever suits you) in between:
 
ComWrt(port, "S", 1);
Delay(0.1);
ComWrt(port, "Y", 1);
Delay(0.1);
ComWrt(port, "S", 1);
Delay(0.1);
ComWrt(port, "T", 1);
Delay(0.1);
ComWrt(port, "E", 1);
Delay(0.1);
ComWrt(port, "M", 1);
Delay(0.1);
ComWrt(port, ":", 1);
Delay(0.1);
...
char CarrRet = 0xD;
ComWrt(port, CarrRet , 1);
 
That being said, I control a power supply via CVI through a USB port simulating a com port and have no problem doing such.
When I tested my other code versus someone using hyperterminal, I did have to add some pauses to "compensate" for their code that was used to slow inputs.
0 Kudos
Message 2 of 14
(5,553 Views)

In asynchronous serial communication, stop bits are delays that the sender inserts between bytes to allow some time for the receiver to process a byte before receiving the next byte.  Try increasing the number of stop bits to 2 (from the default of 1).

How do you open the comm port?

Have you checked to see if you get errors opening the port?

Are you sure you're setting all parameters the same in hyperterm as in CVI?

0 Kudos
Message 3 of 14
(5,450 Views)
Frist of all I must thank you for the answers.
I found out that the problem is in fact in the delay between the characters sent : I used dockLight scripting that allows to put a delay between characters. When there is the delay the instrument answers when there is not delay the instrument doesn't.
Labwindows 7.1- LabView 8
0 Kudos
Message 4 of 14
(5,327 Views)

If the problem is being caused by sending characters to the instrument before it is ready to receive them, then perhaps using the hardware handshaking of the Com port might help? Or does the instrument not support this (eg RTS/CTS) feature?

JR

0 Kudos
Message 5 of 14
(5,318 Views)
Hi jr_2005,
In the manual the flow control is set to none. The instrument is connected using a usb port that is seen as a virtual serial port. Is it possible to use flow control in this case ?

cheers,
Jland
Labwindows 7.1- LabView 8
0 Kudos
Message 6 of 14
(5,315 Views)
Unless the instrument supports some form of flow control option then this approach won't work. I have used CTS/RTS flow control on virtual serial ports (USB) quite successfully in the past. As the instrument apparantly does not have an input buffer on its serial data, I would be surprised if it could not be set to use hardware flow control somehow. Is it a general purpose commercial instrument or is it a custom design?
 
JR
0 Kudos
Message 7 of 14
(5,311 Views)
It's a commercial instrument. I've tried to send character by character and a delay inside a loop but it still doesn't want to work. I am rather clueless at the moment...

cheers,
Jland
Labwindows 7.1- LabView 8
0 Kudos
Message 8 of 14
(5,309 Views)

It might help to disable the transmit buffers at the PC end. In your OpenComConfig() call, put a -1 as the last parameter, to disable the output queue. It could be that this queue was masking your efforts at introducing delays between characters.

JR

0 Kudos
Message 9 of 14
(5,304 Views)
thank you very much for your help, I will give it a try.

cheers,
Geiland
Labwindows 7.1- LabView 8
0 Kudos
Message 10 of 14
(5,301 Views)