给大家发一个研华pcl-818l的c语言数据采集程序! 点击:1470 | 回复:1



王勇hao

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:2帖 | 5回
  • 年度积分:0
  • 历史总积分:31
  • 注册:2004年8月22日
发表于:2004-11-15 19:55:00
楼主
希望大家能互相讨论,我的qq 9376724 /* ********************************************************************** * Program : ADTRIG.C * * Description : Program for PCL-818L pacer trigger A/D * * conversion with software data transfer. * * Revision : 1.00 By WangYong * * Date : 3/11/2004 Harbin commercial university * ********************************************************************** */ #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <process.h> #include <dos.h> #include <math.h> /*********************/ extern pcl818L(int, unsigned int *); #define BASE 0x300 /* base address */ #define NUM 10000 #define door 1.5/1340 /* ???????????? */ FILE *fp; unsigned int param[60]; /* If two boards installed, need to declare the second parameter array */ unsigned int data[10000]; /* Conversion data buffer */ unsigned int far * dat; main() { unsigned int i; float *p,*str,num1; float DataBuf,acc1,div,divisor1,divisor2; float rate; float s_time; /* sample time inteval*/ char filename[10]; /* data file name */ float wait; int k; clrscr() ; dat = data; /* data=start address of 12bit sample data array */ param[0] = 0; /* Board number */ param[1] = BASE; /* Base I/O address */ /*********************program Explanation***********************/ printf("\n****This is a sample program by Advantech PCL-818l card***\n\n"); /****************************set sample rate**************************/ re_enter: printf("please input sample rate(<40KHz):"); scanf("%f",&rate); div=1000000L/rate; if(div<25) /****25=1M/40K******/ { printf("invalid sample rate!!"); goto re_enter; } divisor1=div/0xffff; if(divisor1>2) /* adjust c1 and c2 */ { divisor1=divisor1+1; divisor2=div/divisor1; } else { divisor1=2; divisor2=div/divisor1; } printf("\n actural sample rate=%f Hz\n",1000000L/(divisor1*divisor2)); /****************************number of all sample***********************/ printf("\nC1=%f C2=%f",divisor1,divisor2); printf("\nplease input the number of all sample (=10000):"); edt3: scanf("%f",&num1); if (num1<5000||num1>10001) { printf("\nyou should input number between 5000 and 20000,please again\n"); goto edt3; } printf("elapsed sample time will be =%f second",NUM*(divisor1*divisor2)/1000000L); param[5] = divisor1; /* Pacer rate = 1M / (div1*div2) */ param[6] = divisor2; /* sample rate */ param[7] = 0; /* Trigger mode, 0 : pacer trigger */ param[10] = FP_OFF(dat); /* Offset of A/D data buffer A */ param[11] = FP_SEG(dat); /* Segment of A/D data buffer A */ param[12] = 0; /* Data buffer B address, if not used, */ param[13] = 0; /* must set to 0. */ param[14] = NUM; /* A/D conversion number */ param[15] = 1; /* A/D conversion start channel */ param[16] = 1; /* A/D conversion stop channel */ param[17] = 0; /* Overall gain code, 0 : +/- 5V */ /* param[18] = FP_OFF(gain_array); param[19] = FP_SEG(gain_array); */ /* param[45] : Error code param[46] : Re



xuelaizhang

  • 精华:0帖
  • 求助:0帖
  • 帖子:1帖 | 5回
  • 年度积分:0
  • 历史总积分:8
  • 注册:2004年3月02日
发表于:2005-01-23 21:28:00
1楼
没有中断的吗?

热门招聘
相关主题

官方公众号

智造工程师