Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Hi

Hi
 
I am very new to labview. so i would be happy if somebody helps me.
 
hw cn i design in labview for the C program given below.
 

      #include<ieee-c.h>
      #include<stdlib.h>
       #include<stdio.h>
      #include<conio.h>
      #include<dos.h>
      #define DVM 12
      int status;
      float v1;
      extern Base=0x200;
      error_handler(error,routine)
     
      int error;
      char *routine;
      {
 char ch;
 if(error!=0)
    {
     printf("\nError in call to %s \n",routine);
     printf("Press any key to continue:");
     scanf("%c",&ch);
   }
      }
      initialize_hpib()
      {
 settimeout(3000);
 error_handler(status,"SETTIMEOUT Error");
 return;
      }
      sourcesetup()
       {
  char *str;
            transmit("DCL",&status);
     error_handler(status,"Device Clear");
  str="F0R2G1P10X"; /*SET UP THE DVM */
  send(DVM,str,&status);
  error_handler(status,"DVM setting error");
       }
       main()
       {
  int sensor_no,l;
  char buf[6000],cv[20];
  FILE *fp;
  fp=fopen("cec.c","w+");
  clrscr();
  printf("\n THIS PROGRAM IS TO INDIVIDUALLY CHECK THE VOLTAGE\n ACROSS EACH SENSOR. ");
  printf("\n PRESS CTRL-BREAK KEY TO SUSPEND/QUIT THE JOB");
  outportb(Base+0x09,7);/*UNIPOLAR & INPUT RANGE 0-10V*/
  outportb(Base+0x0c,3);/*SOFTWARE TRIGGER ENABLING*/
  outportb(Base+0x0a,0);/* UNIPOLAR WITH CH0 SELECTION*/
   printf("\n THIS PROGRAM WRITES THE CURRENT OUTPUT IN THE FILE \"cec.c\"\n [WHICH CAN BE SAVED]");
   initialize_hpib();
   sourcesetup();
   printf("\n\n SENSOR NO.\t VOLTAGE IN voltS.");
  for(sensor_no=137;sensor_no>=0;sensor_no--)
   {
    outportb(Base+0x0,sensor_no);
             delay(1000);
            enter(cv,20,&l,DVM,&status);
    error_handler(status,"ENTER statement");
    v1=atof(cv);
   printf("\n\n %d\t %f", sensor_no,v1);
    sprintf(buf,"\n Sensor no=%d Voltage at   1mA is %f V",sensor_no,v1);
    fputs(buf,fp);
  }
  printf("\nOVER ");

   transmit("DCL",&status);
   error_handler(status,"Device Clear");
 getch();
       }
 
thanks
0 Kudos
Message 1 of 2
(3,103 Views)

Hey Sujeep,

I'm a little unclear what you're trying to accomplish in your program. If you're trying to do Serial communicaiton, or GPIB, I would recommend going to labVIEW->Help->Find Examples....->Search for either "GPIB" or "Serial" and you'll find either "LabVIEW<->GPIB.vi" or "Serial Basic Read and Write.vi". Both of these are great starting points.

Regarding your code. I saw you make a call to HPIB, I was curious if you're using a National Instruments GPIB card, or a 3rd party card?

Regards,

Nick D.

0 Kudos
Message 2 of 2
(3,066 Views)