Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA settable attraibutes integer values

#1.


For all settable attributes of VISA plug in,
I am looking tor all possible settable values for each attribute.

Example:
VI_ATTR_TERMCHAR=0x0A
What are all possible values for VI_ATTR_TERMCHAR (other than 0x0A)

This, I am looking for such, for all attributes.
Any document that can supply these? 

#2
ILooking to aquire 10000 datapoints from a single VISA query on a spectrum analyser
How can it be ensured that VISA driver is able to receive all these datapoints in its buffer?

 

#3
Looking to flush the buffer I finish reading.
How do I do it without loosing any valid data that instrument may have put in its send buffer?


regards

0 Kudos
Message 1 of 11
(2,808 Views)

1. Read the NI-VISA help. It lists all available attributes and possible values. For example, the term character can be anything between 00 and FF.

 

2. Are you talking about serial communication?

 

3. Again, are you taling serial? The flush buffer function has no affect on the instrument, of course.

0 Kudos
Message 2 of 11
(2,794 Views)

Hi Dennis.

Thanks for reply.

 

It is for following communications: USB, GPIB, serial, TCPIP.

 

Let's take following case:

 

Q1

Suppose spectrum analyser takes 10000 data points.Also suppose my receive buffer data size is only for 500 datapoints.

This means after one read, there will still be 9500 points unread. Where will they be? In the insrtrument?  on on the computer side somewhere?

 

Q2

Also in this case if I make a next query (say get version), then I suspect that I will be getting one of the previous 9500 points, correct?

 

Q3

Most importantly, to avoid this problem, I can increase my receive buffer size to 10000+.

But out of 5000 queries I make evey day, I hardly make 1 query which requires 10000 points, others need only one value.

I am afraid that increasing receive buffer size to 10000 will negetively affect my communication speed adversly.

Is it correct that increasing the buffer size reduces the speed of communication (over above 4 communication chanel types)?

 

Thanks

regards

 

 

 

 

 

0 Kudos
Message 3 of 11
(2,787 Views)

You have some misunderstandings about serial communications.

 

First, read this for an excellent explanation of serial buffers.

 

If the instrument sends 10000 bytes and you specify some high number of bytes to read, you will have read everything. The VISA Read will keep reading until the termination character is detected. If you only request 500 bytes, the instrument will obviously send everything it has. Old data in the system buffer will be overwritten. The instrument sends bytes, the uart's buffer fills, the pc transfers this to the system buffer, the VISA read transfers to your memory. The process repeats. As long as the VISA Read is able to get the contents faster out of the system buffer than the instrument is sending, no problems and no need to set the buffer size to be equal to the amount of data the instrument is going to send. How fast the the system buffer is filled is going to depend on a couple of factors (i.e. baud rate) and how fast you can read is going to depend on your pc and os and your code. If you start to get buffer overflow errors, you can simply increase the size of the buffer for the specific results you are requesting.

 

The only time you have to get a little fancy is if the instrument does not send a termination character. Then you would use the VISA Bytes at Serial Port in a loop to check to see how many bytes are in the system buffer. When this is greater than 0, then do another loop and keep reading until the number of bytes is 0.

 

What programming language are you using? Have you looked at any of the existing drivers that NI has to see how serial communication is handled?

Message 4 of 11
(2,779 Views)

Hi Dennis.

Thanks for the reference link. It is good content.

Thank you for your response and, having your answer complementory to the link as well.

 

You said: "If the instrument sends 10000 bytes and you specify some high number of bytes to read, you will have read everything"

Yes, but will it reduce the speed of data acquisition. As long as I get CR/LF, it should not right? That means if I know my data size is around 50 bytes, but if I specify read buffer size = 50000, it should not reduce the speed neither it should eat up memory. Can this pls. be confirmed?

 

 You said: "The only time you have to get a little fancy is if the instrument does not send a termination character. Then you would use the VISA Bytes at Serial Port in a loop to check to see how many bytes are in the system buffer. When this is greater than 0, then do another loop and keep reading until the number of bytes is 0."

In this case, something does not seem complete. Let's imagine that computer's (processor's) reading speed is faster than the instrument's data delivery (into UART and subsequently into system buffer), then there can be mements when computer is not finding a single byte, yet the instrument is not yet complete in delivering the data.

Then in this specific case, how does the computer know at what time the instrument is finished delivering th data?

 

You asked: "What programming language are you using? Have you looked at any of the existing drivers that NI has to see how serial communication is handled?"

I am using NI VISA, along with C#. I am unsure about the question asked (slow down and memory eating if buffer is high) in this particular section of the thread which is response to your first referred comment.

 

Thank you

best regards

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 5 of 11
(2,728 Views)

If you think about it, the speed of the acquisition cannot be affected, right? In your example, you read 50 bytes either way.

 

You may have to put a small delay in your loop.

 

There are numerous of IVI drivers. These are written in ANSI C. You can look at the source code of some of them if you want.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 6 of 11
(2,725 Views)

Hi Dennis.

 

Thaniks for the prompt response.

 

To your comment: "If you think about it, the speed of the acquisition cannot be affected, right? In your example, you read 50 bytes either way."

Yes, but if I block a  huge read buffer (although mostly not needed), is it going to eat a lot of memory and eventually slow down the computer?

 

Skimmed thru the link: http://www.ni.com/devzone/idnet/

IVI drivers seem to be manufacturer/instrument/comm channel specific. I am looking to utilize one in a generic way, like VISA works in LabVIEW.

 

Thank you

best regards

0 Kudos
Message 7 of 11
(2,664 Views)

Define huge. You would only need a larger buffer when doing something like a waveform transfer and thats goibg to be fairly small compared to sysrem memory. If you can't allocate 10-20 kbytes and the deallocate it when you are done, then you might want to reconsider your architecture.

 

I don't know what you are asking. An IVI driver is class specific and each class is for a type of instrument (i.e. DMM, power supply, etc.). Your code makes a call yo (for example) IviDMM class driver which in turn will call the specific instrument driver you assign to that class. VISA is typically used by the instrument specific driver.

 

IVI-C is what is supported by NI with LabWindows/CVI. There is also an IVI-COM and IVI-NET specification. If you want to write or use IVI drivers, go to the IVI Foundation for the specs.

Message 8 of 11
(2,636 Views)

 

Hi Dennis.

 

I appreciate your prompt response. Thanks.


You mentioned: "Define huge. You would only need a larger buffer when doing something like a waveform transfer and thats goibg to be fairly small compared to sysrem memory. If you can't allocate 10-20 kbytes and the deallocate it when you are done, then you might want to reconsider your architecture."

I take it as follows....As long as there is memory space, and as long as I am following the programming rules, I can define the buffer of a huge size (ex. 60000 bytes) and the system will not get slow or memory leaks will not happen (just because I am allocating huge buffers and calling the data acquire functions frequently)

 

 

You mentioned: "I don't know what you are asking. An IVI driver is class specific and each class is for a type of instrument (i.e. DMM, power supply, etc.). Your code makes a call yo (for example) IviDMM class driver which in turn will call the specific instrument driver you assign to that class. VISA is typically used by the instrument specific driver.

 IVI-C is what is supported by NI with LabWindows/CVI. There is also an IVI-COM and IVI-NET specification. If you want to write or use IVI drivers, go to the IVI Foundation for the specs."

 

I must say I haven't studied IVI drivers beyond some primary reading in the past. (Certainly don't recall writing any IVI drivers)

 

Notabely,

A. which instruments my program is going to connect to ...is unknown. (I only know the communication channel types)

B. my program is in Microsoft .NET programming (although the client is LabVIEW)

 

Do the above "A and B" disqualify IVI driver being used?

If no, then I know I better learn IVI.

 

Thank you

best regards

0 Kudos
Message 9 of 11
(2,621 Views)

Memory leaks are up to you to prevent. 60000 bytes is not 'huge'. It's rather small in my experience and remember you only need that occasionally.

 

When you do find out the specific instruments, determine whether it fits into one of the IVI classes and then search to whether a driver already exists. That is of course, if you decide IVI is what you want to use.

 

Did you read anything at the IVI foundation link? IVI can be used with any programming language. The IVI-.NET specification would be especially suitable to Microsoft.NET, don't you think?

Message 10 of 11
(2,616 Views)