03-27-2011 06:00 AM
Hello Forum,
I'm trying to read temperatures from a Center 300 Type K thermometer via a serial port and RS232 cable. However, I must first send it a command asking for the data and am using the Basic Serial Write and Read.vi provided in labview 8.5. According to the manual the digital output is a 9600bps N 81 serial interface and an example of the list of commands is as follows:
RS232 command Function Remarks
K(ASC 4BH) Ask for model No. Send 4 bytes
D(ASC 44 H) Ask for main display Range, Data, Unit Send 22 bytes
Command K:
Return 4 bytes. For example, when sends command "K" to meter, it will return "3", "0", "0", ASCII(13)
Command 😧
Return data of main window
Data: 9999.0, -OL, OL (7 bytes include polarity and decimal point), Unit: C, F(5 bytes)
When the meter recieves the D command, it will send:
Rage _ Data _ Unit.
So, I assume that this means that if I type "K\r\n" in the serial write field it will return the model number. Instead, what it returns is just the letter "K". Similarly, if I type "D\r\n" in the serial write field, I get the letter "D" returned to me. I must be making a very fundamental error, but I really do not know what it is.
Any help woud be greatly appreciated. Regards,
L
03-27-2011 06:29 AM
Normally if you send a command to a device you don't need to add "\r\n" (which is CODE presentation for a carriage return.
If you enter the carriage return in your string field, is it in codes display? or in normal display?
03-27-2011 07:28 AM
Usually you setup a termination character, like \n which you setup in Visa Configure Serial Port. Once setup it's always applied when you send something.
I think the Basic Serial example has this setup, so you only need to send 'K'.
/Y
03-27-2011 07:39 AM
Normally you do have to send a termination character and it is sent in the basic example by typing either \r, \n, or both. You cannot set a termination character for a write with the VISA Configure Serial Port.
Try different combinations and if you can attach the manual, do that.
03-27-2011 09:49 AM
Thanks for the quick reply. I followed your suggestions, though there was no improvement. But I did notice a few curious things about Basic Write and Read.vi. Why will it only allow me to send between 5 and 8 bits, when the 'K' command is only 1 bit? Or is 'K' shorthand for something more elaborate I should input? My other observation is that the program always tells me that it has read 0 bits, even when I have unplugged the RS232 cable. Should it not time out while waiting to read and then give me an error signal? Is this a sign that I'm doing something else wrong.
There is not much more in the manual other than what I have already given.
RS232 command Function Remarks
K(ASC 4BH) Ask for model No. Send 4 bytes
D(ASC 44 H) Ask for main display Range, Data, Unit Send 22 bytes
Command K:
Return 4 bytes. For example, when sends command "K" to meter, it will return "3", "0", "0", ASCII(13)
Command 😧
Return data of main window
Data: 9999.0, -OL, OL (7 bytes include polarity and decimal point), Unit: C, F(5 bytes)
When the meter recieves the D command, it will send:
Rage _ Data _ Unit.
For example:
T1 _ _ _ _ _ _-199.9 _ _ C_ _ _ _
(0x13) represent T1, -199.9 C, The total byte number shoudl be 7+1+7_1_5+chr(13)=22 Bytes
I have attached a PDF of a manual, though the digital version does not contain the commands mentioned in the hardcopy. Nonetheless, the PDF does mention the digital output at the bottom of page 4.
Any help would be appreciated,
L
03-27-2011 09:54 AM
Can you post the vi?
/Y
03-27-2011 10:16 AM
The example allows to send an unlimited number of bytes and the character 'K' is one byte - 8 bits.
Yes, you will get a timeout and the error indicator will show that. The manual mentions a custom cable and software from the vendor. Does that work?
03-27-2011 12:09 PM
did you try with HyperTerminal tool that comes with windows.......try to communicate with the device using this tool......just to make sure nothing is broken from device and COM port side........
03-27-2011 08:59 PM
Once again, my thanks to you guys, but still no luck. I did a loop-back test using the hyperterminal, and the port seems to be working fine. I did not get any response from the device, but part of the problem is that I do not know what commands to send it: is it literally just the letter 'K' and nothing else? I inherited this device so I do not have the software mentioned in the manual, Testlink.
I have attached the Basic Write and Read.vi and have been trying to use it unmodified. One curious thing about this program, which others might confirm for me, is that it seems to make no difference whether the cable to device is attached or not. If I write a command I get always 0 bytes read. But shouldn't just it not be able to read anything and give me a time out error instead?
Regards,
L
03-27-2011 09:19 PM
Now you are saying you get 0 bytes instead of the echo back of the 'K'. Which is it?
Have you contacted the vendor to get the software?
Since you have not attached anything that explains the commands, impossible to know if you have to send anything else besides the K.
The VI won't give a timeout error because if there are 0 bytes to be read, the Read will not happen and there will be no timeout.