// ============================================================================ // thermal lens sampling program ver 1998.3.8 // programmed by S.Nishimura // this program must be compiled under MSDOS version 6.2 & MSVC // to compile : // msvcvars        (初回のみ) // cl /AH /Od /c tlsamp3.c // link /NOE /map /li tlsamp3,tlsamp3,tlsamp3,c:\msvc\lib\nanolibh // to run: // c:\wavedrv\adadrv    (初回のみ) // tlsamp3 // 1から30000の間で入力されたstep(nano)を1stepにして //  X,Y方向にそれぞれ入力されたstep数サンプリングする //  結果は入力されたファイル名+1.csv , ファイル名+2.csvにそれぞれ格納される // ============================================================================ // ---------------インクルードファイル----------------------- #include #include #include #include #include #include #include #include #include #include #include // nano-liabraryインクルードファイル #include "c:\msvc\lib\nanolib.h" // ---------------- 定数(nanomover)の定義 -------------------- #define TRUE 1 #define FALSE 0 // ----------------グローバル関数の定義------------------------ // 全体 double smstep; //1stepの大きさ 単位:ミクロン int xma,yma; //xma…x方向,yma…y方向のサンプリングstep数 FILE *fp1; //結果出力用ファイルポインタ (fname+"1.csv") signal FILE *fp2; //結果出力用ファイルポインタ (fname+"2.csv") phase char fname1[200]; //結果出力ファイル名1 ***1.csv char fname2[200]; //結果出力ファイル名2 ***2.csv // ADboard使用 int fh; // Wave Driver ファイルハンドル unsigned int wseg; // 波形メモリセグメントアドレス char cmd[128]; // コマンド文字列バッファ char sta[128]; // ステータス文字列バッファ char mh[6]; // 波形メモリ メモリハンドル float dat[128]; // データ読み込みバッファ char schc[128]; // サンプリングチャンネルパラメータ作成用バッファ int sch[] = {1,2}; // サンプリングチャンネル ***チャンネル1,2を使用*** int schn = 2; // サンプリングチャンネルの数 unsigned int sn = 128; // サンプリング件数 float sc = 1000.0f; // サンプリング周波数 int rng = 12; // レンジ設定 int gin = 1; // ゲイン設定 // ------------------------関数の定義------------------------------ void main(void); //メインルーチン void sampleget(void); //サンプリングルーチン void koma(char *f,...); //AD boardへコマンド出力 int wmget(void); //AD samplingの為のメモリ確保 void initadboard(void); //AD boardの初期化 void initnanomover(void); //nanomoverの初期化 void closenanomover(void); //nanomoverの後処理 void wait_EOS(void); //サンプリング終了待ち // ---------------------------------------------------------------- // main関数 // void main(void); // ---------------------------------------------------------------- void main(void) { int nano,x,y,flag; int co,cp; printf("\nTLSMP3 thermal lens sampling program\n\n"); /* open AD board */ if ((fh = open("PCA3124",O_RDWR | O_BINARY)) == -1) { printf("Wave Driver が OPEN できません。"); exit(1); }else{ printf(" .. wave driver opened ..\n"); } /* initialize AD board */ initadboard(); /* initialize nanomover */ initnanomover(); /* input parameters */ printf(" initilize completed..\n"); printf("\n one step size? (nano) (1-30000)>>"); scanf("%d",&nano); smstep=(double)nano/1000.0; printf(" how many X steps ? (1-30000)>>"); scanf("%d",&xma); printf(" how many Y steps ? (1-30000)>>"); scanf("%d",&yma); do{ printf("File names (拡張子は付けない)>>"); scanf("%s",fname1); strcpy(fname2,fname1); strcat(fname1,"1.csv"); strcat(fname2,"2.csv"); }while((fp1=fopen(fname1,"w"))==NULL && (fp2=fopen(fname2,"w"))==NULL); /* parameters output for display */ printf(" file name signal .. %s",fname1); printf(" file name phase .. %s",fname2); printf(" one step .. %f(micron)\n",smstep); printf(" x .. %d(steps) y .. %d(steps) \n\n",xma,yma); /* parameters output for FILE1 & FILE2 */ fprintf(fp1,"SIGNAL %s",fname1); fprintf(fp1," one step is %f micron , ",smstep); fprintf(fp1," x %d (steps) y %d (steps) \n",xma,yma); fprintf(fp2,"PHASE %s",fname2); fprintf(fp2," one step is %f micron , ",smstep); fprintf(fp2," x %d (steps) y %d (steps) \n",xma,yma); printf("Press any key to START SAMPLING\n"); getche(); // ========= main routine ========= nl_write_units(1,"MI"); /* motor1の単位をmicronに設定 */ nl_write_units(2,"MI"); /* motor2の単位をmicronに設定 */ for(;kbhit()!=0;){} printf("Start sampling.. \n"); flag=0; /* キー入力割り込みフラグを0に */ for(y=0;y