Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from HP/Agilent 53131 frequency counter via GPIB using C#

Solved!
Go to solution

 

I am new to GPIB communication programming, so please bear with me. What I am trying to do is write a program that read samples from a HP universal counter and display on a real-time graph (without Measurement Studio).
Before I get to that point, I am creating a test program to capture data from the instrument. What I am finding out is program takes too long to fetch the sample, another words round trip time takes too long. What am I doing wrong? Ultimately program should be able to read data up to 10 samples per second, but right now its only reading 1 samples per second. Please help. I prefer to use NI488.2 over VISA if that is possible. I have attached my sample program if anyone want to run it on their own.
Below is a part of the program:
double []arrData=new double[5];
Device dev=new Device(1, 3);
int count=0;
string readString =ReplaceCommonEscapeSequences("READ?\\n");
while (count < arrData.Length)
{
dev.Write(readString);
ret=dev.ReadString();
arrData[count++]= Convert.ToDouble(ReplaceEscapeSequences(ret));
}
This is the output:
Frequency  Tick #
532.251665 634244801127043347
532.214921 634244801135043358
532.331588 634244801143043370
532.418313 634244801150843380
532.120377 634244801158843392
End time 3:08:35, Start time 3:08:31, Time taken is 990 ticks

 

 

I am using Visual Studio 2008 on a Windows 7 machine, instrument is connected to GPIB using a USB (NI GPIB-USB-HS) and using NI-488.2 ver 2.7. Any help is much appreciated.

0 Kudos
Message 1 of 4
(6,412 Views)
Solution
Accepted by topic author newGPIBuser

The only thing in your code is a Read?. How are you configuring the counter manually before you take the measurements? Whats the arming mechanism? What's the gate time? What's sensitivity/resolution?

 

I think the problem is with your setup and could be answered by studying the manual or asking Agilent.

0 Kudos
Message 2 of 4
(6,405 Views)

 

Dennis thank you for your help. From your advice I was able to get my program working. In the manual there is an example written in qbasic and I was able to take parts from that program and was able to get a sample from the counter pretty fast.
again thanks for directing me to the right path. Smiley Wink
PS: I have attached a copy of my program if anyone likes to take a look at it.

 

0 Kudos
Message 3 of 4
(6,364 Views)

You can download the C driver from our IDNet here.

0 Kudos
Message 4 of 4
(6,339 Views)