Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual serial port: No bytes at serial port before visa read

Solved!
Go to solution

Hi I'm want to use LabView for real-time data acquisition of my servo dc motors. I'm new to LabView, so I'm trying to do the same thing with virtual port. I'm writing some data (a sinusoidal wave) to the virtual port and then read and show it on graph. the writing part works just fine as it can be seen in hyper terminal. but it doesn't read anything. the number of bytes at port is zero. i tried to set the bytes count in visa read manually but it doesn't work. I have attached my code below. any comment is much appreciated. Thanks in advance

0 Kudos
Message 1 of 9
(5,878 Views)

Are you doing a simple loopback of the serial port? That is the only way you would be reading the sine wave and that has nothing to do with servo motors. What pins do you have connected at the serial port?

 

Why bother doing a loopback? Assuming you have a USB-RS232 converter, do you think It's broken?

0 Kudos
Message 2 of 9
(5,857 Views)

my English sucks. what do you mean by loopback?

 

I have a USB-RS232 converter that works. the problem is the servo motors I'm supposed to work with aren't ready. so I wanted to prepare a code beforehand. in my work I have to read some data like speed, current from servos. I just wanted to do some practice by writing a sine wave and reading it.

 

what modifications I need to make to my code in order to work properly (with virtual port of course)?

0 Kudos
Message 3 of 9
(5,851 Views)

@Neo_Ev wrote:

what do you mean by loopback?


You need to connect the TX to the RX on the output of your USB-RS232 adapter.  Then you will be able to read what you sent out, creating a loop back into your port (hence the name "loopback").


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 9
(5,848 Views)
Solution
Accepted by topic author Neo_Ev

This is just basic knowledge of how serial communication works. In order to do a read without any instrument there, you must loopback (short) the transmit line to the recieve line. For a 9 pin connector, you short pins 2 and 3. If you have not done this, I don't understand where you thought you could do a read from.

 

In any case, if you have servos that are controllable from RS-232, it is not likely that the serial protocol is even close to what you are doing and a loopback will not tell you much more than the converter is functional. When you have an actual instrument connected, you still have to debug the com parameters (baud, parity, handshaking), cable type (null modem or straight through), and the actual commands you send to the instrument and it's responses.

Message 5 of 9
(5,844 Views)
Thank you for the answers.
In the actual instrument everything is pretty much known.
In my code how should I connect pins 2 and 3?
Sorry if my questions are too basic!
0 Kudos
Message 6 of 9
(5,837 Views)

@Neo_Ev wrote:
In my code how should I connect pins 2 and 3?

You can't do it in code.  You have to do it with the serial bus hardware (the end of the USB-Serial adapter).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 9
(5,834 Views)
Is it possible to write and read using a virtual bridge connection?
0 Kudos
Message 8 of 9
(5,829 Views)

Didn't you read the explanation of a loopback in the link I posted? There is no such thing as a virtual bridge. It is an actual physical connection. If you have a special converter that supports this debug mode, then you would need to refer to the api for the converter.

Message 9 of 9
(5,828 Views)