LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

????Help with serial communication.

I am trying to send command and read from the serial port. I am not sure if I am sending the commands the right way. I am attaching my example and I have documents for my instrument available under question "Thermal Couple using RS-232" If some one can help thanks alot.
Download All
0 Kudos
Message 1 of 12
(3,152 Views)
Hi Noman
I can not open second file you have enclosed, there are some vis missing in my distribution. But I can open the first one.
What I would reccomend is to wire in "Visa Read" wire the "byte count" with a eg. 5 bytes. The default number is 0, so the Visa is dead, I guess. I enclose the corrected first file.


If it stil will not work try to communicate with your device using eq. "Hiper terminal" or other text communication program to see if your device is working properly.
When you ensure it does, then the problem lies in your software. Maybe you need to play with CTS and DTR lines also available via Visa palette.

Hope it helps.
good luck
Pawel
0 Kudos
Message 2 of 12
(3,152 Views)
In LabVIEW, go to Help>>Examples>>Hardware I/0>>Serial>>Serial Communication for an example program. Check your device's user manual for information about required baud rates, stop bits, handshaking protocols, and termination characters. These are required for all instruments and can be set for the port with the Visa Serial VI.
Ray K
0 Kudos
Message 3 of 12
(3,152 Views)
I have used this program before. It loops if there isn't any response from device( bytes at port =0), and will loop until all the bytes are at the port. If your message is too big for the port, loop reading the port each time, concantenate the response onto a shift register and search for your terminating character.
0 Kudos
Message 4 of 12
(3,152 Views)
Thanks, I am able to read the recovery message which the device send at the initial power on of the device, restart or after a power failure, and internal reset. Also able to read Prompt message which is basically a "!" which let the user know that device is ready to accept the next input. I read all is as \F0\C0\r\n\01!\S\POWER\s\ON\r\n\r\n!\r\n. where the \F0\C0 are not the same when i do this few times. And plus once the device spit this out if you ask again there is no bytes. After receiving this I send my command but no response from the device. I think I am just missing something here. Do i need to clear the buffer or actually search for ! and send my command to receive my data??? Need help! thanks
0 Kudos
Message 5 of 12
(3,152 Views)
The FO\CO may be BCC(bit check). Your message isn't that long so the initial way should take care of you.The device might be looking for a termination character in the command string, or looking for you to include the BCC data i the string format. When you read the serial port it does a buffer dump.Do you have the book for this device?
0 Kudos
Message 6 of 12
(3,152 Views)
Yes, I do have the book. It says that there are basically two kind of commands the device recognizes, list commands and program commands. Since I am not programing anything just want to receive data ,I am using list commands. Let me just type the pragraph from the book about List commands:
------------------------------------------------------
A list command consists of a two character mnemonic field (i.e. SS) and optional range field (i.e. 1, 36). A space may be used to separate the mnemonic and range field but it is not required. Either upper or lower case letters can be used in the mnemonic field. The optional range field may consist of a single integer (i.e. 5), a double integer (i.e. 5-15) or omitted entirely. When a souble intege
r is entered, the two integers must be separated by a hyphen or comma, and the first integer must be less than the second integer. If the optional range field is omitted, default is to the entire range of points, alarms, deviation, or ralay numbers as applicable. The model 205 output response to a valid list command is a message containing the data requested, followed by the prompt.
The following commands comprise the entire List Commmand set. Each field is enclosed in brackets [] with individual keystrokes indicated therein (i.e. [SS] means type an "S" twice). The optional range field is shown as [x-x]. Note that a comma can also be used to separate integers. A carriage return [CR] terminates all commands.

List command : SINGLE SCAN Key Entry:[SS] [x-x][CR]
-------------------------------------------------------
single scan command basically request a single log of point data with alarm information for the point(s) specified. The model 205 responds with a log mes
sage consisting of the time field, point data fields (in ascending order), and one or two alarm fields if the point is in alarm. If the range field is omitted, this command logs all unskipped points installed in the system.
0 Kudos
Message 7 of 12
(3,152 Views)
I am using this way to read my response from the device, one thing that i notice that the recovery message is always followed by a prompt message which is ok , I am able to read those messages. but I am thinking that my data message is either getting lost somewhere or maybe I am suppose to read that after I have read the recovery message. Right now i am reading the bytes and as soon as all the bytes are read my program terminates, but what if the device takes a while after sending the recovery message to send the data message, so how can I fix my VI to do that. And also another this is that when i was reading the manual ,I read that the Recovery message has following things it contain:
blockheader, line control, program information field ind
entifer (optional), program information text or recovery message, line control (CR, LF, etc), block railer.
and this what I get from my device back:
\F0\C0\r\n\01!\s\POWER\s\ON\r\n\r\n!\r\n

01! looks like the program information field identifier I think what it means is that my channel currently programmed is channel 1 which is correct because I have only one channel which has the termal couple connected currently reading temperature on my device. What i think is that 01 is the program channel and ! should mean that device is ready to except my command. So this could be another reason I am not reading my data.
0 Kudos
Message 8 of 12
(3,152 Views)
Hello again Noman,

Nowhere in your program do I see you sending the CR. Its not enough to type the characters CR at the end of your command string. I thought this was discussed in one of my answers to an earlier post of yours.
0 Kudos
Message 9 of 12
(3,152 Views)
Maybe I do not know how do I send command the proper way, can you give me suggestions, Thanks
0 Kudos
Message 10 of 12
(3,152 Views)