Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from serial port

I'm having a very hard time setting up a serial port connection. I'm new to both LabVIEW and serial ports, and I apologize that I don't even know what are the right questions to ask.

 

I want to control and read a Spex CD2. I found a VI for it here: IDN -- CD2a I'm not able to get this to work, however I suspect that I have a different version of the hardware (it says CD2 on the front and CD2a on the back). I've tried opening MAX, opening VISA session and sending and receiving commands, but nothing seems to be responding.  

 

For now, I've given up on controlling the device through LabVIEW. I'd be happy if I can just read position data from the device (i.e. SPEX CD2). The device sends a data block (and might need an <ACK>) and ends with an <EOT>. (the data flow is described on page 12 of this PDF document).

 

I'd like to see what data the device is sending. I tried a serial port sniffer but that seems restricted to proper serial port devices (this device doesn't even respond to IDN). Using LabVIEW, is there a way to read/sniff data from the serial port? Also, how would I go about sending messages like <ACK><EOT><STX> etc.? I'd appreciate any help/suggestions for this.  

0 Kudos
Message 1 of 8
(4,735 Views)

My best guess is that you have the wrong serial cable. They come roughly in two versions.

One version wires straight pin 1 to pin 1 and all other pins are also directly connected.

The other version is twisted. It means that for sending and receiving the correct signals swap between the two connectors.

The famous pin 2,pin 3 swap is because both instruments otherwise would speak on the same line and listen on the same line with a net result of nobody hearing anything.

RS232 sometimes is refeered to as Regularly Soldering pin 2 to 3 and 3 to 2.

The best you can do is measure if you have a twisted or a straight cable and replace it with the other one.

 

Alternatively, als baudrate handshake and more can be wrong.

The only thing left is to wish you good luck.

greetings from the Netherlands
Message 2 of 8
(4,721 Views)
Thank you very much for your reply!
Yes, I'm not 100% sure about the cabling either -- the device has a 25 pin serial port so I had to use a convertor. Luckily, the manual mentions that it requires a null-modem configuration. I'm using a null-modem adapter; that should take care of the pins 2-3 swap, right?

If it's a handshake problem, I'm thinking that I can loop through all the different settings from within LabVIEW to find the correct setting. If that doesn't work, and if I get frustrated enough, I'll just hookup the TX pin to a oscilloscope.
0 Kudos
Message 3 of 8
(4,720 Views)

I'd like to try my looping through all possible configurations idea. Could someone please point me to an assured method of listening to the serial port and dumping the data on the screen?

0 Kudos
Message 4 of 8
(4,705 Views)

portmon logs all communication to a port.

Search for it , it presently is part of microsoft utilities

greetings from the Netherlands
Message 5 of 8
(4,701 Views)

Portmon from Microsoft is a sniffer that will work.

 

Frankly, I don't see what good a sniffer will do. The instrument will not respond unless it gets the correct command and the driver appears to format the commands correctly. The driver will show the response when the com settings are correct and the right cable is used. Until then, the sniffer will not have anything to sniff.Smiley Very Happy

 

p.s. the commands you asked about are explained in any ASCII Table. for example, <AC> is hex06 and one way to set that is to set the string control/constant to hex display. There have been countless discussions on sending hex over the serial port. Do a search.

Message 6 of 8
(4,699 Views)

Thank you Albert for recommending Portmon. I tried some shareware apps, but this one seems much better.

  

Re: Knight of NI  ( Smiley Very Happy I showed that to everyone), when the 'Remote' button is activated on the device, it constantly sends a stream of data. Would I not be able to sniff this stream of data if I had the right serial port settings?

 

I am more confident about the cabling now. The manual mentions using a null-modem, which I am doing. Also, some of the other devices from that era in our lab are connected the same way.

 

0 Kudos
Message 7 of 8
(4,695 Views)
My comment about the instrument only responding to a command was based on what I saw in the driver. If this button does what you say it does, then yes, you should be able to monitor the data stream.
Message 8 of 8
(4,680 Views)