01-15-2013 03:40 AM
Hello!
I would like to read the voltage values of a Keithley 2182 nanovoltmeter via RS232, using a serial to usb converter.
The RS232 settings of the nanovoltmeter are:
baudrate 9600
flowcontrol none
TX term CR
Stopbits 1
Data bits 8
When starting the VI the nanovoltmeter gets configured (Nanovoltmeter konfigurieren) so it countinously sends values. The read command (read befehl) tells the nanovoltmeter to provide the next fresh data at the serial port.
When I just started my computer and labview and the nanovoltmeter I get the desired values in my text output. This works for some time, from half a minute to several minutes. But then a value is not fully read and afterwards no values are transmitted anymore. Then the property node "bytes at port" shows zero 0 and nothing is read anymore. Even if i stop and restart the VI the bytes at port are still 0. Only when I totally close labview and restart it i get data but again only for a short period of time.
I tried to use a constant (1024) at the VISA read module but always got the -1073807339 error, even at the start of the program where normally I get at least a few measurement values. I also tried to increase the waiting time after the read command is written - without success.
I also monitored the com port parallel to running the VI and thats what i got:
COM is open <20130115103308.612 SYS> Baud-Rate 9600 <20130115103308.612 SYS> RTS on <20130115103308.612 SYS> DTR on <20130115103308.612 SYS> Data Bits=8, Stop Bits=1, Parity=None <20130115103308.612 SYS> Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13 <20130115103308.612 SYS> Handflow: ControlHandShake=(DTR_CONTROL), FlowReplace=(TRANSMIT_TOGGLE, RTS_CONTROL), XonLimit=64, XoffLimit=64 <20130115103308.612 SYS> Buffersize In/Out 640/640 <20130115103308.612 SYS> Timeout: ReadInterval=-1, ReadTotalTimeoutMultiplier=0, ReadTotalTimeoutConstant=0, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=500 <20130115103308.615 SYS> RTS on <20130115103308.615 SYS> DTR on <20130115103308.615 SYS> Baud-Rate 9600 <20130115103308.615 SYS> RTS on <20130115103308.615 SYS> DTR on <20130115103308.615 SYS> Data Bits=8, Stop Bits=1, Parity=None <20130115103308.615 SYS> Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13 <20130115103308.615 SYS> Handflow: ControlHandShake=(DTR_CONTROL), FlowReplace=(TRANSMIT_TOGGLE, RTS_CONTROL), XonLimit=64, XoffLimit=64 <20130115103308.615 SYS> Buffer Size In/Out 640/640 <20130115103308.615 SYS> Timeout: ReadInterval=-1, ReadTotalTimeoutMultiplier=0, ReadTotalTimeoutConstant=0, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=500 -------------- configure nanovoltmeter ------------------ <20130115103308.615 TX> *RST [len=4] <20130115103308.615 TX> <LF>*CLS [len=5] <20130115103308.615 TX> <LF>:CONF:VOLT [len=11] <20130115103308.615 TX> <LF>:sens:volt:nplc 0.01 [len=21] <20130115103308.615 TX> <LF>:INIT:CONT ON [len=14] ------------ get data ---------------- <20130115103308.615 TX> <LF>:DATA:FRESh? [len=13] <20130115103313.714 RX> -7.5ø <20130115103314.114 TX> :DATA:FRESh? [len=12] <20130115103314.614 TX> :DATA:FRESh? [len=12] -------------- closing labview -------------- <20130115103327.997 SYS> RTS aus <20130115103327.997 SYS> DTR aus <20130115103327.997 SYS> Empty ports: RXABORT, RXCLEAR, TXABORT, TXCLEAR <20130115103328.037 SYS> COM ist geschlossen
Has anybody more ideas what i could try?
Thanks, Tom
(Labview 11, Windows 7, VISA 5.2)
01-15-2013 06:30 AM
Since you are using a termination character, you should not be using the Bytes at Port. Just set the number of bytes to read to something really big. The termination character will limit the read to a single command/response.
Are you sure the instrument is sending a termination character?
Is the instrument supposed to constantly send the data on its own? Or are you commanding it for the data? If it is sending it on its own, you might not be reading fast enough and you are overflowing the serial buffer.
01-15-2013 08:40 AM
Thank you for your quick reply!
I tried setting the bytes to read to 1024 (normally only 16 bytes or so are read). But then i always get the -1073807339 error, even at the start of the program where normally I get at least a few measurement values. This error means "Timeout expired before operation completed". But using the byte at port works at least for some values.
I'm sure the instrument normally sends a CR (\r) as termination character, i can even see it in the text field when I receive values at first.
The instrument is commanded to make measurements all the time. With the :DATA:Fresh? command the next value that is measured is sent to the serial port and than read, so it should come to an buffer overflow. Do you know if the serial buffer is emptied when Labview is fully closed? because closing labview is the only possibility to get some data again. i don't think it's the buffer of the instrument, as it doesn't help to turn off and on the instrument.
Maybe somebody has other guesses?!
I will try to change the mode of reading to really use the termination char, maybe i can overcome the -1073807339 error somehow!
01-15-2013 10:53 AM
Tom,
1. How have you set the instrument communications? According to the manual there are four possible termination character combinations. The fact that you sometimes see <CR> is an indication that you have something set incorrectly. The termination character is stripped out and never appears as part of the message. VISA only uses single-character termination characters. So make sure that the instrument is set for one of those. The instrument also may use X_ON/X_OFF handshaking. Are you sure it is off?
2. Your VI shows two different termination character combinations being sent (\r\n and \r). One of those will likely confuse the instrument, or you.
3. Are you sure you have correctly interpretted the commands? My reading of the command list shows :DATA:FRESh? as a subset of CALCulate as well as :SENSe. I also interpret :INIT:CONT ON as causing the instrument to measure continuously but not to transmit data continuously.
The VI you posted earlier may not implement the delays exactly as you want because there is no data dependency. As other responses have indicated, you need to get rid of Bytes at Port and make sure your termination characters match at the instrument and in your VI.
Lynn
01-17-2013 03:53 AM
Hello Lynn,
Thanks for your response.
Ad 1: I use CR as termination character for the nanovoltmeter and also in the VI. On the 2182 the Flow control is shown as off. So i think this should be alright. I don't know why the /r can be seen when getting data.
Ad 2: You are right, the \n is not necessary, it came from putting each command in an individual line.
Ad 3: I worked on that and changed the whole VI, so the nanovoltmeter is'nt in the continuous measurment mode and I use the :read? command for reading. With that now I can use a fixed number of bytes to read, so i don't use "Bytes at Port" anymore. The new VI is attached.
But now I always get a 1073807339 timeout error after some time (a few to 20 min). It seems that once data isn't completely read (so no terminator is at the end) no more data is getting to the VI. I still don't know why it's that way, but maybe it is a driver problem. I use a Prolific Serial to USB Converter - maybe this is the problem.
Thanks, Tom
01-17-2013 06:23 AM
Hi again!
I now changed the terminator on the nanovoltmeter to LF and also changed the termination character in die VI to that (ascii decimal 10). Now I see in the output the LF (\n) at the end of the data. Why does the VISE read not accept the \n as terminator? If it was so, why would it still show it in the output?
Thanks, Tom
01-17-2013 06:36 AM
Since you are using the termination character, you really should set the number of bytes to read to something rediculously high, not just how many you actually expect. The VISA driver will return the bytes up to either the termination character or the number of bytes you specified (whichever is first).
01-18-2013 02:56 AM
Ok, I changed the byte to read to 1024, but nothing changed.
I noticed that the flow control is set to ControlHandshake 0x1 (Serial DTR Control) and FlowReplace 0x40 (Serial RTS Control), altough I chose "none"
Handflow: ControlHandShake=(DTR_CONTROL), FlowReplace=(TRANSMIT_TOGGLE, RTS_CONTROL), XonLimit=64, XoffLimit=64
Is there a possility to change that to none? When I read the Flow Cntrl value of the VISA property node, is says none, but my serial port monitor tells me it gets set to the values above ...
Can I also change the timeout values to 0, so there is no timeout? No matter what i set for the timeout constat at the VISA configure serial module, i get this in the port monitor:
Timeout: ReadInterval=-1, ReadTotalTimeoutMultiplier=0, ReadTotalTimeoutConstant=0, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=500
Attached is the VI I use right now.
Thanks, Tom