Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystem
Diff: ILF3_rev1.cpp
- Revision:
- 9:1d75106ccfa2
- Parent:
- 8:34e4ca3c366e
- Child:
- 10:b34306f7add6
--- a/ILF3_rev1.cpp Mon Apr 25 08:31:18 2022 +0000 +++ b/ILF3_rev1.cpp Tue Apr 26 08:34:58 2022 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "SDFileSystem.h" + //difine_mbed_LPC1768 /******************************************************************************* @@ -232,7 +233,7 @@ /*** UART ver3 ***/ //Serial uart(P0_15,P0_16,19200); //Serial pc(USBTX,USBRX,9600); //mbed⇔PCデバック用 -Serial pc(P0_15,P0_16,19200); //ILF3⇔PCデバック用 +Serial pc(P0_15,P0_16,19200); //ILF3⇔PCデバック用 /*** interruput ***/ //InterruptIn seq_yobi(P0_19); @@ -545,8 +546,10 @@ void display_resistor(short sdata);//測定値を表示する。 void led_off();//判定用LED全消灯 void read_syoudo(char* c);//EEPROMから照度データ(PwmDuty)を読み込んでセットする -void seq_serialcomunication(int noc);//シーケンサへのシリアル出力 -// +void seq_serialsend(/*int noc*/);//シーケンサへのシリアル出力 +void seq_serialrecive(/*int noc*/);//シーケンサへのシリアル入力 + + /******************************************************************************* 測定関係 変数 @@ -563,12 +566,9 @@ float ocp[4];//2byte 補数あり 測定値 char ch_num ;//選択中の測定チャネル(0~3) int cat;//検査カテゴリNo. - -/**************************** -シーケンサ関係変数 -****************************/ -int CH[] = {1,2,3,4}; -double seq_fdata[4][4]; +float fdata[4][4];//ファイル出力用 +char seq_name[3];// + //structure struct cal_info { @@ -645,19 +645,23 @@ //seq_start.fall(&trigger);//スタート信号立下りで割込み + //シーケンサからシリアル受信割り込みイネーブル + pc.attach(seq_serialrecive,Serial::RxIrq); + //シーケンサのトリガ以外は受け付けない while(1) { /*** ver3 ***/ //if( seq_start == 0 ) { if ( seq_in[0] == 0 ){ - trigger(); - } wait(0.3); }//while(1) + + //シーケンサからシリアル受信割り込みディスイネーブル + pc.attach(NULL,Serial::RxIrq); } @@ -670,6 +674,7 @@ { char meas_num;//測定個数 char cal_num; //CAL選択ナンバー + int sdata;//シリアル通信STX格納 //char cmd_gu[2]; gu_cls();//clear screen @@ -681,6 +686,15 @@ gu_cursor(128,0); gu_print1("CAL."); + //シーケンサからSTX受信するまでループ + while(1){ + sdata = pc.getc(); + if(sdata == 0x02){ + break; + } + } + + //シーケンサからCAL選択bit読込と表示 /* cal_num = ( seq_cal_c << 2 ) + ( seq_cal_b << 1 ) + seq_cal_a; @@ -700,7 +714,6 @@ gu_fontsize(1); gu_print1("Cal number error"); wait(1); - } /*** v3 debag ***/ @@ -723,7 +736,7 @@ wait(0.1); - seq_serialcomunication( meas_num ); + //seq_serialsend( meas_num ); //自動モード中のシーケンサ通信 //測定終了ver3 //seq_busy = 0;//DegitalOut busy @@ -2704,8 +2717,10 @@ Jyushin = i2c.read ((addr_gu + 0x01), crdata, 3, true); + //シーケンサからシリアル受信割り込みイネーブル(デバック用) + pc.attach(seq_serialrecive,Serial::RxIrq); + while(1) { - //スタートスイッチで測定開始 if ( sw_start == 0 ) { meas_sub(); @@ -2765,6 +2780,10 @@ }//if wait(0.1); }//While + + //シーケンサからシリアル受信割り込みディスイネーブル(デバック用) + //pc.attach(NULL,Serial::RxIrq); + } /* @@ -2977,11 +2996,26 @@ *********************************/ void meas_sub() { + int sdata;//シリアル通信STX格納(デバック用) auto_int_hyouji(); gu_cursor(0,2); gu_print1("Please Wait.."); gu_fontsize(2); + + + //シーケンサからSTX受信するまでループ + while(1){ + if ( seq_name[0] == 'A' ){ + break; + } + /* + sdata = pc.getc(); + if(sdata == 0x02){ + break; + } + */ + } read_regnum();//CAL登録No.読込 @@ -2990,7 +3024,10 @@ auto_meas( number_of_channels );//2個測定 hantei( number_of_channels );//判定LED - + + seq_serialsend(); //デバック用シーケンサ通信関数呼出 + + wait(0.5); gu_fontsize(1); @@ -3012,7 +3049,6 @@ int y[4] = {5,11,5,11}; //GU_D y座標 4個測定時の表示スタート位置 int iy ; //GU_D y座標 2個測定時の表示スタート位置 int i; - float fdata[4][4];//ファイル出力用 short sdata[4]; iy = 4;//GU_D 2個測定時の測定値の表示開始位置 y座標 @@ -3220,9 +3256,6 @@ fdata[i][0] = iop[i] * 0.01; //1bitあたり0.01uA fdata[i][1] = ocp[i] * 0.01; //1bitあたり0.01uA fdata[i][2] = voc[i] * 0.001; //1bitあたり0.001V - seq_fdata[i][0] = iop[i] * 0.01;//シーケンサ用グローバル変数 - seq_fdata[i][1] = ocp[i] * 0.01; - seq_fdata[i][2] = voc[i] * 0.001; } for( i = 0; i <= ( noc - 1 ); i++) { @@ -3683,7 +3716,10 @@ if( err_f[i] == 1) { led_red[i] = 1; - } else { + } /*else { + led_green[i] = 1; + }*/ + else if(seq_name[0] == 'A') { led_green[i] = 1; } @@ -5064,43 +5100,34 @@ ****************************************/ -void seq_serialcomunication(int noc) +void seq_serialrecive(){ + + seq_name[0] = pc.getc(); + led_green[0] = 1; + wait(0.5); + led_green[0] = 0; + + /* + while(seq_name[2] == 0x03){ + seq_name[0] = pc.getc(); + seq_name[1] = pc.getc(); + seq_name[2] = pc.getc(); + } + */ + +} + + +void seq_serialsend(/*int noc*/) //デバック時int nocコメントアウト { - char STX = 2; - char EXT = 3; - int i; + char STX = 2; + char EXT = 3; + int i; + int CH[] = {1,2,3,4}; + int noc = 4; for(i = 0; i <= ( noc - 1); i++){ -/* - uart.printf("%c" , STX); - uart.printf("%s" , calinfo.name[i]); - uart.printf("%c" , ","); - - //アンテナ抵抗値 - if(R[i] < res_vref && R[0] >= 0){ - uart.printf("%d" , R[i]); - } - else{ - uart.printf("%c" , "OL"); - } - - uart.printf("%c" , ","); - uart.printf("%f" , seq_fdata[i],[0]); //Iop - uart.printf("%c" , ","); - uart.printf("%f" , seq_fdata[i],[1]); //Idd - uart.printf("%c" , ","); - uart.printf("%f" , seq_fdata[i],[2]); //Voc - uart.printf("%c" , ","); - uart.printf("%d" , vocp[i]); - uart.printf("&c" , ","); - uart.printf("%c" , err_f); //void hanteiのエラーフラグを流用 - uart.printf("&c" , ","); - uart.printf("&d" , cat); - uart.printf("&c" , ","); - - uart.printf("%c" , EXT); - */ -//PCデバック用 +//PCデバック用 pc.→uart.に変更で装置用へ変更出来る pc.printf("%c" , STX); pc.printf("%d" , CH[i]); pc.printf("%c" , ','); @@ -5116,11 +5143,11 @@ } pc.printf("%c" , ','); - pc.printf("%f" , seq_fdata[i][0]); //Iop + pc.printf("%f" , fdata[i][0]); //Iop pc.printf("%c" , ','); - pc.printf("%f" , seq_fdata[i][1]); //Idd + pc.printf("%f" , fdata[i][1]); //Idd pc.printf("%c" , ','); - pc.printf("%f" , seq_fdata[i][2]); //Voc + pc.printf("%f" , fdata[i][2]); //Voc pc.printf("%c" , ','); pc.printf("%f" , vocp[i]); pc.printf("%c" , ',');