Home › Forums › Programming Books and Reviews › C program that sends 1mA to all Si sensors
- This topic has 0 replies, 1 voice, and was last updated 17 years, 4 months ago by Shayaan_Mustafa.
Viewing 0 reply threads
- AuthorPosts
- July 7, 2007 at 9:18 pm #1986Shayaan_MustafaParticipant
Hi,
Can someone help me in understanding this program. I need to try this with Labview Software.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116/* THIS PROGRAM SENDS ONLY 1mA TO all si SENSORS [137 to 0 ]<br />TO DIFFERENTIATE<br />BETWEEN SENSORS DIPPED IN LIQUID & VAPOUR. VOLTAGES ACROSS THESE<br />SENSORS ARE STORED IN A FILE OPENED*/<br /><br />#include<ieee-c.h><br />#include<stdlib.h><br />#include<stdio.h><br />#include<conio.h><br />#include<dos.h><br />// #define CSRC 14<br />#define DVM 12<br />int status;<br />//unsigned int v2;<br />float v1;<br />extern Base=0x200;<br />error_handler(error,routine)<br /><br />int error;<br />char *routine;<br />{<br />char ch;<br />if(error!=0)<br />{<br />printf("nError in call to %s n",routine);<br />printf("Press any key to continue:");<br />scanf("%c",&ch);<br />}<br />}<br />initialize_hpib()<br />{<br />settimeout(3000);<br />error_handler(status,"SETTIMEOUT Error");<br />return;<br />}<br />sourcesetup()<br />{<br />char *str;<br />transmit("DCL",&status);<br />error_handler(status,"Device Clear");<br />/*<br />str="D0R0T0G0K0F0X";<br />send(CSRC,str,&status);<br />error_handler(status,"CSRC INITIALISING EEROR");<br />*/<br />str="F0R2G1P10X"; /*SET UP THE DVM */<br />send(DVM,str,&status);<br />error_handler(status,"DVM setting error");<br />}<br />/*<br />csrcsetup()<br />{<br />char *str,cv[20];<br />int l;<br />str="L2B2I+1E-3V+3E+0P1X";<br />send(CSRC,str,&status);<br />error_handler(status,"CSRC SETTING ERROR");<br />str="L2B2X";<br />send(CSRC,str,&status);<br />error_handler(status,"CSRC ERROR");<br />str="F1X";<br />send(CSRC,str,&status);<br />error_handler(status,"CSRC EXECUTION ERROR");<br />delay(1000);<br />enter(cv,20,&l,DVM,&status);<br />error_handler(status,"ENTER statement");<br />v1=atof(cv);<br />return;<br />}<br />*/<br />/*<br />trigger()<br />{<br />error=IOTRIGGER(CSRC);<br />error_handler(error,"IOTRIGGER");<br /><br />error=IOTRIGGER(DVM);<br />error_handler(error,"IOTRIGGER");<br />delay(100);<br />}<br />*/<br />main()<br />{<br />int l,sensor_no;<br />char cv[20],buf[6000];<br />FILE *fp;<br />fp=fopen("smtochk1.c","w+");<br />clrscr();<br />printf("n THIS PROGRAM IS TO INDIVIDUALLY CHECK THE VOLTAGEn ACROSS EACH SENSOR. PRESS ANY KEY TO SWITCH TOn NEXT SENSOR");<br />printf("n PRESS CTRL-BREAK KEY TO SUSPEND/QUIT THE JOB");<br />outportb(Base+0x09,7);/*UNIPOLAR & INPUT RANGE 0-10V*/<br />outportb(Base+0x0c,3);/*SOFTWARE TRIGGER ENABLING*/<br />outportb(Base+0x0a,0);/* UNIPOLAR WITH CH0 SELECTION*/<br />printf("n THIS PROGRAM WRITES THE CURRENT OUTPUT IN THE FILE "smtochek1.c"n [WHICH CAN BE SAVED]");<br />initialize_hpib();<br />sourcesetup();<br />printf("nn SENSOR NO.t VOLTAGE IN voltS.");<br />for(sensor_no=137;sensor_no>=0;sensor_no--)<br />{<br />outportb(Base+0x0,sensor_no);<br />// csrcsetup();<br />// trigger();<br />enter(cv,20,&l,DVM,&status);<br />error_handler(status,"ENTER statement");<br />v1=atof(cv);<br />printf("nn %dt %f", sensor_no,v1);<br />sprintf(buf,"n Sensor no=%d Voltage at 1mA is %f V",sensor_no,v1);<br />fputs(buf,fp);<br />getch();<br />}<br />printf("nOVER ");<br /><br />transmit("DCL",&status);<br />error_handler(status,"Device Clear");<br />getch();<br />}</ieee-c.h>Thanks in advance.
- AuthorPosts
Viewing 0 reply threads
- The forum ‘Programming Books and Reviews’ is closed to new topics and replies.