AnsweredAssumed Answered

Programming 34972A in C++

Question asked by nigelstevens on Feb 13, 2014
Latest reply on Feb 27, 2014 by nigelstevens

I'm writing a program in C++ Builder XE to control a 33522A function / arbitrary waveform generator and a 34972A switch unit. I'm setting up the function generator ok, and I can read the results of a scan in the 34972A (after waiting for the scan to finish). The only thing I'm not able to do is to read the number of results available from the 34972A using the :DATA:POIN? command from my C++ code.

When I run a test sequence in the Agilent Command Expert, it seems to work ok, but when I call it from C it waits a few seconds for the viQuery command, but never reads anything back.

I've tried pausing the code in the C++ debugger before the DATA:POIN? command, then running this command in the command expert, and that seems to read the correct number (3 readings)

The error I get from the viQuery command is returned as VI_ERROR_TMO, so I think this means it's a timeout.

The command in the command expert is :

The code that the command expert exports for this is :
     long points_num = 0;
     viQueryf(my_34972a, ":DATA:POIN?\n", "%d", &points_num);

The code in my C++ program is :
     long Points = 0;
     result = viQueryf(Agilent_34972A, ":DATA:POIN?\n", "%d", &Points);

I know that my program is talking to the 34972A because before this DATA:POIN? command is this code :
     viPrintf(Agilent_34972A, "*RST\n");
     viPrintf(Agilent_34972A, ":CONF:FREQ AUTO,DEF,(@101)\n");
     viPrintf(Agilent_34972A, ":SENS:FREQ:RANG:LOW 3,(@101)\n");
     viPrintf(Agilent_34972A, ":CONF:VOLT:AC AUTO,DEF,(@102)\n");
     viPrintf(Agilent_34972A, ":ROUT:CHAN:DEL 2,(@102)\n");
     viPrintf(Agilent_34972A, ":CONF:VOLT:DC AUTO,DEF,(@103)\n");
     viPrintf(Agilent_34972A, ":SENS:VOLT:DC:NPLC 10,(@103)\n");
     viPrintf(Agilent_34972A, ":FORM:READ:UNIT 1\n");
     viPrintf(Agilent_34972A, ":FORM:READ:CHAN 1\n");
     viPrintf(Agilent_34972A, ":FORM:READ:TIME 0\n");
     viPrintf(Agilent_34972A, ":ROUT:SCAN (@101:103)\n");
     viPrintf(Agilent_34972A, ":INIT\n");

and if I access the switch unit manually (from its front panel), channels 101,102 and 103 are setup as I expect ( Freq, Vac. and Vdc) and I can read them OK.

Any ideas ?