AnsweredAssumed Answered

problem in programming 34980a with VISA

Question asked by amolgupta87 on Jun 19, 2009
Latest reply on Jun 19, 2009 by amolgupta87
I am facing strange problem while trying to operate 34980a using visa in VC++. . The device is connected over lan . I had extracted it's address using connection expert. I am able to connect using visa. I am even able to extract its idn string. Now here comes the strange part. If i send any other SCPI command using formatted IO the device doesn't responds. Like for example "ROUTe:CLOSe (@2101)" .The device gives error beep but VISA doesn't report any error . I have tried the same commands on interactive IO utility it works. Now comes the strangest of all the IO monitor is registering commands of interactive IO but not that of my program. One thing that i feels is that my code is not linked to agilent VISA but to ni VISA

here is the code if you may like to have a look but I feel there is some config flaw. Any how what i feel is if I am able to read identification string then all SCPI commands should work.

#include "stdafx.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "visa.h"

*  If the call failed, this procedure prints an error message,
*  takes the board offline and exits.
#define CHECK(func) \
do {\
     ViStatus _s = (func);\
     if (_s < 0)\
          fprintf(stderr, "Error: %s returned %d\n", #func, _s);\
} while (0)

/* Specify the default address */
#define DEFAULT_LOGICAL_ADDRESS "TCPIP0::"     // Instrument LA

#define ARRAYSIZE       100          // Max size for some char arrays
#define MAX_READINGS    20          // Max size for number of channels

void main()
      * This example program is adapted for Microsoft Visual C++ 6.0
      * and uses the VISA API, the file visa.h must be included
      * Include file directory; C:\VXIPNP\win95\include or C:\VXIPNP\WinNT\Include
      * Library files; C:\VXIPNP\win95\Lib\msc or C:\VXIPNP\WinNT\Lib\msc
      * Link Object/Library Modules; visa32.Lib
      * See the Agilent VISA Users Guide for Compiling and
      * Linking an Agilent VISA Program
     ViSession   viDefaultRM, Instrument;
     ViRsrc      TxtAddress = DEFAULT_LOGICAL_ADDRESS;
     unsigned long actual;
     char idn&#91;ARRAYSIZE&#93;;

     CHECK(viOpen(viDefaultRM, TxtAddress, VI_NULL, VI_NULL, &Instrument));
     /* Send a power reset to the instrument         */
     CHECK(viPrintf(Instrument, "*RST\n"));
     CHECK(viPrintf(Instrument, "ROUTe:CLOSe (@2101)\n"));
     /* Query the instrument for the IDN string      */
     CHECK(viPrintf(Instrument, "*IDN?\n"));
     CHECK(viRead(Instrument, (ViPBuf)idn, ARRAYSIZE, &actual));
     idn&#91;actual&#93; = '\0';
     printf("IDN result:\n%s\n",idn);


please help me.