05-19-2011 02:31 PM
Dear All,
I want to readout the Stanford Research counter SR400 via its serial port RS232. Please note, readout via the GBIP interface, for which I found some examples, is not an option.
The serial readout was tested with Hyperterminal and a self-written Matlab script. Both work flawless. Hence I assume the settings and teh port are ok.
I use Labview v.8.6. Start point is the 'Basic Serial Write and Read.vi' from the Labview examples with the RS232 settings from the matlab script.
The encountered problem is that when a command string is sent to the SR400, the Labview VI puts by itself a 'space' string in front of the command string. This can be seen on the display of the SR400. The modified command string can not be interpreted by the SR400. I checked that the sent command string is correctly 8bit long.
This additional 'space' can also be seen in the echo of the SR400 shown read pane of the Labview VI (see attached screenshot). The '??>' string indicates that the sent command contains an error. Instead of 8 bit the echo has 9 bit. This is probably the dot in front of the '??>' string, which should be there either.
What is going wrong? Is that a problem with the frame of the command? What kind of adjustments have to be done to the VI? Any hints or example VI are very welcome!
Many thanks in advance!
Rolf
05-19-2011 07:57 PM
05-20-2011 01:23 AM
Hi,
As mentioned I used the NI provided example for serial communication. Please find this vi attached.
Rolf
05-20-2011 02:41 AM
Don't send a shipping example. As shown in your image, you have a VI called Counter_SR400.
Your comment about the command being 8 bits does not make any sense. In your image, you are sending 3 bytes (if the \r is sent correctly).
05-20-2011 03:42 AM
Ok, here you go.
This VI runs with the same result. It shows additionally the number of bytes written to the RS232.
You are right, I was wrong with the 8bit (used a property node to read out the wrong property). The string received by the SR400 is always "<space>SS[cr]", i.e.. " SS[cr]" (as displayed by the SR400), where it should be "SS[cr]".
The string in the read pane of the VI is the echo of the SR400. The string "??>" is the SR400's prompt that the sent command was not correct. The dot in the string comes also from the VI. In case of a working communication and an incorrect command, the echo should read "SS??>" correctly. In case of a working communication and a correct command the prompt reads "SSOK>"
Rolf
05-20-2011 07:43 AM
Have you tried terminating with LF or CR/LF?
05-20-2011 07:45 AM
Yes, tried all combinations. However teh SR400 request a \r.
Rolf
05-23-2011 06:14 AM
you can use the NI Spy Tool for further debugging:
http://digital.ni.com/public.nsf/allkb/282C5D41E2BA04F2862574BA007803B9?OpenDocument
Cheers,
Cheggers
05-23-2011 09:52 AM
50 'SET THE COM MENU OF THE SR400 FOR RS-232 BAUD=9600
60 ' RS-232 BITS=8
70 ' RS-232 PARITY=NONE
80 ' RS-232 WAIT=6
90 ' RS-232 ECHO=OFF
100 '
110 '
120 OPEN "COM1:9600,N,8,2,CS,DS,CD" AS #1
from the manual example pg 50
You example uses 19.2K, Even,8, 1, None you need 9600, None, 8, 2 none
05-23-2011 10:03 AM
The SR400 is configurable. Its maximum baudrate is 19200 (according to the manual). I tried different settings with no success.
Anyway the settings I used for teh VI are settings working perfectly with other software. The SR400 reads the command sent by the VI . It could be a timing issue.
Rolf