diff --git a/FC_InferfaceBoard/FC_InferfaceBoard.h b/FC_InferfaceBoard/FC_InferfaceBoard.h index 4c825a5..3cf080c 100644 --- a/FC_InferfaceBoard/FC_InferfaceBoard.h +++ b/FC_InferfaceBoard/FC_InferfaceBoard.h @@ -7,7 +7,7 @@ String Prcss_AO_Write(unsigned int data[], int dataSize); String Prcss_PV_Read(); String Prcss_SV_Read(); String Prcss_SV_Write(unsigned int data[], int dataSize); -String Prcss_AT_Write(bool onOff); +String Prcss_AT_Write(unsigned int data[], int dataSize); String Prcss_RngAO(unsigned int data[], int dataSize); String Prcss_ChMC9(unsigned int data[], int dataSize); diff --git a/FC_InferfaceBoard/FC_InferfaceBoard.ino b/FC_InferfaceBoard/FC_InferfaceBoard.ino index 3a02224..c7b0dc2 100644 --- a/FC_InferfaceBoard/FC_InferfaceBoard.ino +++ b/FC_InferfaceBoard/FC_InferfaceBoard.ino @@ -70,9 +70,9 @@ int RngAO[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // ========== ========== Processing // Read Datas -const int DoPin[] = { 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41}; -const int DiPin[] = { 2, 3, 4, 5, 6, 7, 8, 9}; +const int DoPin[] = { 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49}; +const int DiPin[] = { 26, 27, 28, 29, 30, 31, 32, 33}; const int AiPin[] = { A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15}; @@ -189,6 +189,11 @@ void loop() { else if(cmd=="SV!"){ dataSize = demuxNum(cmdData, data); client.print(Prcss_SV_Write(data, dataSize)); + + }else if(cmd=="AT!"){ + dataSize = demuxNum(cmdData, data); + client.print(Prcss_AT_Write(data, dataSize)); + } /* else if(cmd=="ATon!"){ diff --git a/FC_InferfaceBoard/MC9.ino b/FC_InferfaceBoard/MC9.ino index 19bbb45..ab59035 100644 --- a/FC_InferfaceBoard/MC9.ino +++ b/FC_InferfaceBoard/MC9.ino @@ -101,6 +101,79 @@ int msg_MC9_SV_set(unsigned int data[], int dataSize){ return 0; } +int msg_MC9_AT_set(unsigned int data[], int dataSize){ + String message = ""; + bool at[16]; + + int lp0, lp1; + + unsigned int data0 = data[0]; + for (int i = 0; i < 16; i++) { + at[i] = (bitRead(data0, i) ? HIGH : LOW); + } + + lp0 = 8; + lp1 = 8; + + message = ""; + if(RS485_1_Addr[0] != 0){ + if(RS485_1_Addr[0] < 10){ + message += "0"; + } + message += String(RS485_1_Addr[0]); + message += "DWR,16,"; + for(int i=0 ; i<8 ; i++){ + String atFlag; + if(at[i]){ + atFlag = "0001"; + }else{ + atFlag = "0000"; + } + + message += "0302,"; // Ch No cmd. + message += "000" + String(i+1) + ","; // Ch No. + message += "0501,"; // AT cmd. + message += atFlag; // AT flag + if(i != 7){ + message += ","; + } + } + message += sumMC9(message); + message = "" + message + CRLF; + write_buff_first(Buff_485_Wr, message); + } + + message = ""; + if((RS485_1_Addr[1] != 0) && (lp1>0)){ + if(RS485_1_Addr[1] < 10){ + message += "0"; + } + message += String(RS485_1_Addr[1]); + message += "DWR,16,"; + for(int i=0 ; i<8 ; i++){ + String atFlag; + if(at[i+8]){ + atFlag = "0001"; + }else{ + atFlag = "0000"; + } + + message += "0302,"; // Ch No cmd. + message += "000" + String(i+1) + ","; // Ch No. + message += "0501,"; // AT cmd. + message += atFlag; // AT flag + if(i != 7){ + message += ","; + } + } + message += sumMC9(message); + message = "" + message + CRLF; + write_buff_first(Buff_485_Wr, message); + } + + return 0; +} + int saveMC9(String message){ int addr; int idx = -1; diff --git a/FC_InferfaceBoard/Processes.ino b/FC_InferfaceBoard/Processes.ino index 2e6999a..ca74416 100644 --- a/FC_InferfaceBoard/Processes.ino +++ b/FC_InferfaceBoard/Processes.ino @@ -17,7 +17,7 @@ String Prcss_ALL_Read(){ str += ','; str += RcvOK; - str += "PV10?:"; + str += "PV_0?:"; if(rcv_10_PV){ for (int i = 0; i < RS485_1_Rcv_size*2; i++) { char formattedNumber[5]; @@ -30,7 +30,7 @@ String Prcss_ALL_Read(){ str += RcvErr; } - str += "SV10?:"; + str += "SV_0?:"; if(rcv_10_SV){ for (int i = 0; i < RS485_1_Rcv_size*2; i++) { char formattedNumber[5]; @@ -84,6 +84,15 @@ String Prcss_SV_Write(unsigned int data[], int dataSize){ return str + FIN; } +String Prcss_AT_Write(unsigned int data[], int dataSize){ + String str = "AT!:"; + + msg_MC9_AT_set(data, dataSize); + + str += RcvOK; + return str + FIN; +} +/* String Prcss_AT_Write(bool onOff){ String str = "AT!:"; String message, cmd; @@ -103,7 +112,7 @@ String Prcss_AT_Write(bool onOff){ str += RcvOK; return str + FIN; } - +*/ String Prcss_RngAO(unsigned int data[], int dataSize){ String str = "RngAO!:"; int rng = 0; diff --git a/Labview/Data_process.vi b/Labview/Data_process.vi index af32dfe..13662bc 100644 Binary files a/Labview/Data_process.vi and b/Labview/Data_process.vi differ diff --git a/Labview/IF_CMD.vi b/Labview/IF_CMD.vi index e9c90e5..d56a121 100644 Binary files a/Labview/IF_CMD.vi and b/Labview/IF_CMD.vi differ diff --git a/Labview/IF_Loop.vi b/Labview/IF_Loop.vi index 59d584a..d5a6a4b 100644 Binary files a/Labview/IF_Loop.vi and b/Labview/IF_Loop.vi differ