Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

what is enable termination char

1) Is it when the VISA receive the specific char then it will stop receive?
2)If the char is X.Then will VISA stop receiving when it receive "aadfsX" or it only stop when receive only one char "X"?
3)what is the advantage of this char?
0 Kudos
Message 1 of 6
(3,763 Views)
Hi,

The termination character is particulary useful for serial communication, since there isn't any other way to detect that the transmitter has finish sending a message. GPIB has a dedicated line to indicate the receiver that the message has ended.

Let's consider the case of not having a termination character for serial communication. Every time you call VISA read with serial you have two options to terminate the operation: giving the exact count of bytes you are going to read or waiting for the timeout.

If your device always send X number of bytes after a query, you can make your VISA reads count 5. You don't need the termination since you know that after 5 bytes the message is over.

This is not the behavior of most instruments. Most instrumen
ts will respond with different message lengths based on the query. In this case, the count should allow you to receive the longest message. If a shorter message is receive, the read will not return until the timeout expires. If your timeout is 10 seconds, you are making EVERY read from the instrument 10 seconds long. Not very efficient. you can set the timeout to a shorter time, but if it is too short you might timeout before getting the whole message.

The termination character allows VISA to know when the end of the message is. After the end is received there is no need to wait any more and VISA returns. This is the optimal case, since every read executes as long as it needs.

Hope this clears things up.

DiegoF
National Instruments.
Message 2 of 6
(3,764 Views)
Hi,
I do not know when the device will response ,how many time the device will response and how long is the message.Thus,i put the visa in the while loop.is it ok?
0 Kudos
Message 3 of 6
(3,763 Views)
Hi,

Yes, you can put the VISA Read in a while loop. Depending on the result of the error cluster you can determine what to do.

If the read returns and the error code is zero, it means that the termination character was detected and you can continue.

If there is a warning in the error code (positive value), most likely you have read the exact amount of bytes you requested so there might be more data in the buffer.

If there is a timeout error you can try again and ignore the error.

DiegoF
National Instruments.

National
0 Kudos
Message 4 of 6
(3,763 Views)
DiegoF,
What char is used as Terminator char?  example, #, /n, or something else.
0 Kudos
Message 5 of 6
(3,619 Views)
The termination character is whatever the instrument vendor says it is. It could be a carriage return (\r), line feed (\n), a combination, anything else, or nothing at all. There is no standard.
0 Kudos
Message 6 of 6
(3,604 Views)