Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

I can write commands to my RS-232 device and change settings but cannot read data

Hi,
I am developing a driver for a TTi 1906 Digital multimeter. The driver that is available on the NI website is for LabWindows/CVI and not for Labview. Moreover the existing driver is meant for a GPIB interface whereas i am looking for a RS-232 driver.
 
I have been developing my own driver but there seems to be a problem.
 
I can write commands to my device and change settings like voltage measurement, resistance measurement etc
but CANNOT READ THE VOLTAGE , resistance etc.
 
To make sure that the appropriate numer of bytes were read, i used the VISA function to read the number of bytes available at the port. However the number of bytes available for reading are indicated as 0!
The commands were entered with the correct syntax (based on reference to the TTi 1906 Manual)
 
I passed the cable through a loopback test and it seems perfectly functional.
 
I want to know how i can make the read possible and why no bytes are read by the RS-232 interface. If someone knows where to locate this driver, that wud be even better
 
Thanks to all replies
0 Kudos
Message 1 of 21
(7,009 Views)
Hi,

why dont you ckeck with the VISA GUI tool the interface functionality? This is working if the device is configured properly.

Open the NI-VISA interactive control Window. It is the same on Win and Linux.You should see your RS-232 device there. Click on the device address. An other Window opens. Go to viwrite and press execute. An *IDN? command is send to your device. (Old devices use sometimes different commands for this, e.g. the HP8563 Spec. uses ID?. See the instrument control manual of your instrument for details about this.) Read the response back on the viread window by pressing execute again. This should return you your instrument name and ID.

If this is not working, check the VISA attributes. My guess is that you need to change the VI_ATTR_TERMCHAR attribute from <nl> (0xA) to <CR> (0xc) for proper string IO operation.

Otherwise your VISA client works wrong.

Best regards peter




0 Kudos
Message 2 of 21
(6,985 Views)
You should also try to verify that you can talk to it via HyperTerminal.

In LabVIEW there's a Basic Serial Read/Write example that you can use. Open the Example Finder and search for "serial".

If the LabWindows driver uses VISA, and there's a DLL, you can convert it to a LabVIEW driver as explained here. Note that if the driver already has a DLL you don't need to do the first part of the steps in that document.
0 Kudos
Message 3 of 21
(6,970 Views)
Hi,
the LabWindows driver was not made with VISA!
0 Kudos
Message 4 of 21
(6,965 Views)
Howdy floaters,

It may be worth your time to contact Thurlby Thandar Instruments to see if they have an updated version of their TTi 1906 driver since they provided it as-is to NI.

muellerp and smercurio above both offer solid suggestions involving the VISA Interactive Control and Serial examples in the Example Finder accessible through Help»Find Examples in LabVIEW. On an additional note, if the Bytes at Port property incorrectly returns 0, then you can try just using a constant number there to indicate the number of bytes you want to read at the port.

For additional troubleshooting help using NI-VISA with RS-232, NI Spy is a great tool that allows you to see the communication going through the port(s). You can access it by navigating to Start»Programs»National Instruments»NI Spy.


Warm regards,

pBerg
0 Kudos
Message 5 of 21
(6,954 Views)
@muellerp
Thanks for your suggestions, when i use the interactive visa control and do as you instructed, i get a time out error.
 
I am not so confident about my hyperterminal test with the device. In the labview online help, it says i should see two characters for every one i enter , but that's not happening.
 
I have already tried using a constant, if i do so, i get a time out error.
 
 
0 Kudos
Message 6 of 21
(6,937 Views)

Why aren't you confident in using Hyperterminal? I always try serial communication with that first before trying to write any code. If I can't get communication to work with Hyperterminal, I know there is something wrong with the com settings, the cable, or command. I don't have to worry about bugs in a program I just wrote. Also, if you contact the vendor, they will in most cases, be very familiar with Hyperterminal. Many will have never heard of LabVIEW and suggest Hyperterminal anyway. If you can't get Hyperterminal to work, then you should not even bother with LabVIEW.

I don't understand your comment about seeing two characters for every one you enter. The number of characters received is not a function of the number of characters sent when you are connected to an instrument. Exactly what help are you referring to?

0 Kudos
Message 7 of 21
(6,933 Views)

@Knight of NI

I am sorry, i guess i did not convey my message clearly.

When i meant i was not confident with the Hyperterminal test, i was referring to the fact that i am unfamiliar with the hyperterminal test for the device. I am familiar with the loopback test and it works. However, i am not sure about how to talk to a device using the Hyperterminal test.

My knowledge of the hyperterminal test is based on this page

 

http://www.ni.com/support/serial/verhyper.htm

 

If this isnt what has to be done, please direct me to a correct version of the test.

When i connect my device to the serial port and run hyperterminal, a connected symbol appears at the bottom left of the hyperterminal window. If i type in characters into the window, nothing happens

0 Kudos
Message 8 of 21
(6,927 Views)

That's a loopback test where you connect the tx and rx lines of the cable together. All that is verifies is that the serial port on the pc works and that you have continuity of the lines. It does not verify that you have the correct cable for the instrument, or that you have the com port settings for the instrument, or that you are sending the correct commands to the instrument. To test communiucation to the instrument, connect the cable to the instrument and then open a Hyperterminal session. Select the com port and com settings. Then, send a command to the instrument. You have a DMM so if the instrument is in Voltage mode, send a command to set it Ohms. If that works, send the command that requests the instrument to take a reading and return a measurement. If the instrument does not switch to ohms or if you do not get a response, then something is wrong. Double check the com settings, double check the type of serial cable you are supposed to use (there are different types), and double check the commands. All of this information should be in the manual for the instrument.

If you have an electronic copy of the manual, attach it so someone can look at it. If you don't have a copy, provide a link to it. Also, if you could attach a copy of the VI you are using, that would help as well. Be sure the VI includes the actual commands you are sending. That means that if you are using a front panel control, you need to enter the command in the control and then go to the edit menu and select 'Make Current Values Default', save the VI, and then attach it.

0 Kudos
Message 9 of 21
(6,921 Views)
Hi,
I have been testing the different commands using the Basic serial read and write VI given in the examples folder of labview.
The manual has been attached for your reference.
The COM port settings have been double checked, the syntax of the commands are in order (this i have checked several times).
The cable is something i am not sure about (I know i am not using the cable recommended by the manufacturer though).
 
I checked the device using the hyperterminal test, there is no response whatsoever! However as mentioned in my initial question, the basic read and write VI seems to be able to write commands to the device. I find this a conflicting situation when the hyperterminal evokes no response but the basic serial read and write does. For example i am able to change the mode from DC voltage measurement to resistance measurement using a OHMS command in the basic serial read and write VI but the same command produces no response in the Hyperterminal program
 
thanks for the help Knight of VI
0 Kudos
Message 10 of 21
(6,917 Views)