07-18-2010 12:26 PM
Hi... I have two instruments, both manufactured by the same company (Inficon), both that provide the same basic function which is rate control of vapor deposition... Both instruments use RS-232 serial communication (baud rate of 19,200, 8 data bits, 1 stop bit, no parity, no flow control). The only fundamental difference between the two instruments is that the instrument I will call #1 communicates serially using simple ASCII text while the second instrument (#2) communicates using HEX numbers... Using VISA serial write and read, I have for a long time been successfully communicating with instrument #1... I send it (serial write) a certain ASCII text command and the instrument responds with a message I successfully read back (serial read)... That works fine... Now I have a need to do the same "write a command and read a response" with instrument #2... I'm working with an engineer at the instrument company who has supplied me with the precise HEX messages I need to send, messages he has tested on an identical instrument #2 at his factory but so far, what works for him does not work for me... I write the HEX string. I get no errors but also I get NO BYTES available to read at the serial port... Note, he is NOT using LabVIEW at the factory but is instead using a proprietary serial communication executable the factory uses internally... He and I have resorted to having me try the simplest HELLO command in HEX that is, in fact, exactly the following
0200480149 <--- in HEX (first two bytes are Length of command with LSB first, MSB second, the next two bytes are the command itself, in this case H1 (HEX for ASCII "H" is 0x48 and this company then uses 0x01 for 1 rather than the actual HEX for ASCII "1" which would be 0x31. Then the last byte is a checksum which is simply the HEX add of the two command bytes, 0x48 + 0x01 = 0x49...
The bottom line I am confident the above 0200480149 (HEX) would work if I was sending it correctly but somehow I am not...
It's the weekend right now and I've been reading NI support posts here and I already have a couple of ideas that I intend to try on Monday... One is I will try HyperTerminal to see I can communicate that way... Second, the code I am using is ALMOST identical to the very basic Serial Write/Read code that can be found at (this is being done in LabViEW 7.1)
C:\Program Files\National Instruments\LabVIEW 7.1\examples\instr\smplserl.llb\Basic Serial Write and Read.vi
But the ALMOST might be important... I just noticed that I "Enable Termination Character" set to TRUE (default). That may be causing my problem so the first thing next week I will set that to FALSE and see if my problem goes away... But I'm trying to get a jump start on this problem (I am under time pressure to get this working) so I thought I would ask for your help...
I also am not sure how to set up the string control that is inputting this HEX input message... I have set it as "Normal" and also as "HEX display"... But either way I set it, I still get "0 bytes at port" when I get to the READ portion of the code so neither "Normal" nor "HEX display" is working for me...
So other than trying HyperTerminal and also trying to set the "Enable Termination Character" to FALSE, can anyone suggest what I might be doing wrong??? I am pretty sure it is a formatting issue (such as sending that termination character) and I need to get it figured out soon... Any other ideas??? Any help would be much appreciated... thanks.... bob...
07-18-2010 03:13 PM - edited 07-18-2010 03:15 PM
If you want to enter the values in hex on the front panel control then you should set the string to hex display mode. Thus, your string control would look like this:
The VISA Write will simply send out the string as entered.
As for the "Enable Termination Character", that's for configuring VISA Read to stop reading once it sees a specific character. Instruments will often end their messages with a character like a carriage return or a linefeed. In these cases you can simply enable the termination character, set the value to the specific character the instrument is using, and wire in a large value for the "bytes to read" input of VISA Read. VISA Read will automatically end the read once it sees the termination character, even if the number of bytes is less than what you specified. It would not affect the write unless you also configured VISA to use a termination character on a write. The example VIs don't do this, so unless you explicitly did it (and it doesn't sound like you did), it VISA would not be appending another character.
One thing you may want to consider is to use PortMon (just Google it) to see exactly what is being sent over the serial port (at least from the computer's side).
If you post your code it would help.
07-19-2010 10:03 AM
Hi... Thanks for the response... Find the very simple code I am using attached... Do note that the string indicator out of the VISA read does open up with default values of 0D0A (CR LF)... I didn't put those in and I've left them there to show what the defaults were when this code was first saved, just in case you think those values being there matter... ?? Anyway, again, the code is attached... Note also I have left the code with its "Enable Termination Char" set to ON (default) in the Configure VISA serial subvi. I am not at work yet and will set that to FALSE later but you've more or less convinced me that is not going to solve my problem as that is tied to terminating the READ and does not impact the Serial WRITE... And I appreciated the input on Portmon... I downloaded it and will give it a try when I get to work which will be soon... But I wanted to attach the code as you requested... Holler back if you see anything that might help me with my issue...
Oh, one last thing... The manual for the instrument explicitly says that it uses "one start bit, 8 data bits, one stop bit, no parity, no flow control"... What got my attention there is the explicit mention of "one start bit"... Nothing in Windows or LabVIEW allows me to alter how many start bits there might be so I am assuming ALL serial comm uses one start bit and they just chose to mention it here??? Or might the start bit settings be an issue???? I am just searching...
Last, this code is in LabVIEW 7.1 and I really do use COM4 as I use a Keyspan serial port expander on the PC because we needed more serial ports... That part has been tested and In fact, the other day, while in the middle of this problem we took the serial cable and hooked to what I above called the #1 instrument and talked to it just fine over COM4, same cable and everything so I think that part is good...
thanks... bob...
07-19-2010 11:15 AM
Since you are reading raw byte values you'd want the "enable termination character" set to false. Otherwise you could get a premature end to your read.
You can't change the number of start bits. Besides, the spec calls out for only 1 start bit.
The value on the indicator will not change your program. It's an indicator, and it will be populated with whatever comes out of the Read.
Have you tried increasing the amount of time after the write? You may not be waiting enough time for the response.
07-19-2010 11:41 AM
You might check the serial port properties. Start>Settings>Control Panel>System, Hardware tab, Device Manager. Double click on Communications Port (COMX) Properties. Check under 'Port Settings'. You can change the baud rate, parity, flow control, etc.
Thanks,
Jim
07-19-2010 12:03 PM
@TSJim wrote:
You might check the serial port properties. Start>Settings>Control Panel>System, Hardware tab, Device Manager. Double click on Communications Port (COMX) Properties. Check under 'Port Settings'. You can change the baud rate, parity, flow control, etc.
Thanks,
Jim
That should not be necessary, since the serial port configuration is being done in code.
Or are you saying that to change the number of start bits that way? Can't change the spec... ![]()
07-19-2010 12:13 PM
There are FIFO settings there that might make a difference.
I seemed to remember that old versions of LabVIEW didn't have flow control settings available and just used the default from the OS, I'm loading up LV7.1 now to check.
Thanks,
Jim
07-19-2010 12:46 PM
Your right, LabVIEW 7.1 'VISA Configure Serial Port' should be able to control all the settings that are available in the Device Manager, except for FIFO settings.
Jim
07-19-2010 01:01 PM
@TSJim wrote:
Your right, LabVIEW 7.1 'VISA Configure Serial Port' should be able to control all the settings that are available in the Device Manager, except for FIFO settings.
The transmit and receive buffers can be configured using the VISA Set I/O Buffer Size. However, I don't believe that would have any impact on the issue here.
07-19-2010 01:13 PM
OK - Let me try again after actually reading the problem -
-----------------------
the second instrument (#2) communicates using HEX numbers...
--------------------
0200480149 <--- in HEX (first two bytes are Length of command with LSB first, MSB second, the next two bytes are the command itself, in this case H1 (HEX for ASCII "H" is 0x48 and this company then uses 0x01 for 1 rather than the actual HEX for ASCII "1" which would be 0x31. Then the....
--------------------
The above is confusing. Can you post the model number of the instrument you are trying to communicate with and I can look at the protocol and probably figure out the bytes needed to communicate.
Thanks,
Jim