diff --git a/FC_InferfaceBoard/Ethernet.ino b/FC_InferfaceBoard/Ethernet.ino index 5551340..d821470 100644 --- a/FC_InferfaceBoard/Ethernet.ino +++ b/FC_InferfaceBoard/Ethernet.ino @@ -1,4 +1,3 @@ -// void Ethernet_setup(){ byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x00 }; IPAddress ip(192, 168, 20, 177); diff --git a/FC_InferfaceBoard/FC_InferfaceBoard.ino b/FC_InferfaceBoard/FC_InferfaceBoard.ino index eda1643..3a02224 100644 --- a/FC_InferfaceBoard/FC_InferfaceBoard.ino +++ b/FC_InferfaceBoard/FC_InferfaceBoard.ino @@ -175,35 +175,20 @@ void loop() { //Serial.println(cmd); if(cmd=="ALL?"){ client.print(Prcss_ALL_Read()); - } // GPIO else if(cmd=="DO!"){ dataSize = demuxNum(cmdData, data); client.print(Prcss_DO_Write(data, dataSize)); - }else if(cmd=="DI?"){ - client.print(Prcss_DI_Read()); - }else if(cmd=="AO!"){ dataSize = demuxNum(cmdData, data); client.print(Prcss_AO_Write(data, dataSize)); - - }else if(cmd=="AI?"){ - client.print(Prcss_AI_Read()); - } // MC9 else if(cmd=="SV!"){ dataSize = demuxNum(cmdData, data); client.print(Prcss_SV_Write(data, dataSize)); - - }else if(cmd=="SV?"){ - client.print(Prcss_SV_Read()); - - }else if(cmd=="PV?"){ - client.print(Prcss_PV_Read()); - } /* else if(cmd=="ATon!"){ @@ -220,13 +205,16 @@ void loop() { }else if(cmd=="RngAO!"){ dataSize = demuxNum(cmdData, data); client.print(Prcss_RngAO(data, dataSize)); - }else if(cmd=="ChMC9!"){ dataSize = demuxNum(cmdData, data); client.print(Prcss_ChMC9(data, dataSize)); - } + // Extra + else if(cmd=="AT!"){ + dataSize = demuxNum(cmdData, data); + client.print(""); + } //else if(cmd==""){ //} diff --git a/FC_InferfaceBoard/MC9.ino b/FC_InferfaceBoard/MC9.ino index 5a1093d..19bbb45 100644 --- a/FC_InferfaceBoard/MC9.ino +++ b/FC_InferfaceBoard/MC9.ino @@ -10,6 +10,9 @@ void setupMC9_1(int i, int data){ String msg_MC9_PV(int addr){ String message = ""; + if(addr < 10){ + message += "0"; + } message += String(addr); message += "DRS,08,0001"; message += sumMC9(message); @@ -21,6 +24,9 @@ String msg_MC9_PV(int addr){ String msg_MC9_SV(int addr){ String message = ""; + if(addr < 10){ + message += "0"; + } message += String(addr); message += "DRS,08,0011"; message += sumMC9(message); @@ -29,36 +35,107 @@ String msg_MC9_SV(int addr){ return message; } +int msg_MC9_SV_set(unsigned int data[], int dataSize){ + String message = ""; + int lp0, lp1; + + if(dataSize > 8){ + lp0 = 8; + lp1 = dataSize; + /* + if(dataSize==16){ + lp1 = 8; + }else{ + lp1 = dataSize%8; + } + */ + }else{ + lp0 = dataSize; + lp1 = 0; + } + + if(RS485_1_Addr[0] != 0){ + if(RS485_1_Addr[0] < 10){ + message += "0"; + } + message = String(RS485_1_Addr[0]); + message += "DWR,0" + String(lp0) + ","; + for(int i=0 ; i0)){ + if(RS485_1_Addr[1] < 10){ + message += "0"; + } + message = String(RS485_1_Addr[1]); + message += "DWR,0" + String(lp1-8) + ","; + for(int i=8 ; i pin 22 for CH#1 #define Snd_485 HIGH #define Rcv_485 LOW - void RS485_setup(){ Serial1.setTimeout(300); Serial1.begin(9600); @@ -69,7 +67,6 @@ int recieve_485(){ String message = read_buff(Buff_485_Rd); if(message != ""){ numOf485--; - //if((latest_sent_msg == msg_MC9_PV(10)) || (latest_sent_msg == msg_MC9_SV(10))){ if(latest_sent_msg.indexOf("DRS") != -1){ saveMC9(message); } @@ -84,7 +81,6 @@ int recieve_485(){ return 0; } - /* For Test from PC */ void recieve_485_0(){ @@ -103,5 +99,3 @@ void recieve_485_0(){ IdeSerial = ""; } } - - diff --git a/Labview/Data_process.vi b/Labview/Data_process.vi index 8d6c50f..af32dfe 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 11b1a76..e9c90e5 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 8c18b9a..59d584a 100644 Binary files a/Labview/IF_Loop.vi and b/Labview/IF_Loop.vi differ