diff --git a/FC_InterfaceBoard/Analog_Out.ino b/FC_InterfaceBoard/Analog_Out.ino index 15d5c14..a572886 100644 --- a/FC_InterfaceBoard/Analog_Out.ino +++ b/FC_InterfaceBoard/Analog_Out.ino @@ -73,5 +73,8 @@ void AO_Write(int i, int volt) { AO = &AO_14; } + Serial.println(" [AO] " + String(i) + " > " + String(volt)); + //Serial.print(" > "); + //Serial.println(volt); AO->setDACOutVoltage(volt, ch); } \ No newline at end of file diff --git a/FC_InterfaceBoard/FC_InterfaceBoard.h b/FC_InterfaceBoard/FC_InterfaceBoard.h index 6191edd..0a201c4 100644 --- a/FC_InterfaceBoard/FC_InterfaceBoard.h +++ b/FC_InterfaceBoard/FC_InterfaceBoard.h @@ -34,6 +34,7 @@ int Size_AI = 16; int Values_DI; // digit values to a number int Values_AI[16]; +int Recent_AI[16][10]; /* ---------- I2C (Analog Output, DAC) ---------- */ // Addresses @@ -62,6 +63,40 @@ unsigned long timeoutPeriod = 5000; // 이더넷 타임아웃 시간 (5초) bool State_eth = false; +HardwareSerial* Serials[] = {&Serial1, &Serial2}; + +const int BUFF_SIZE = 1024; +char Buff_Eth_Rd[BUFF_SIZE] = {0}; +char Buff_485_1_Wr[BUFF_SIZE] = {0}; +char Buff_485_1_Rd[BUFF_SIZE] = {0}; +char Buff_485_2_Wr[BUFF_SIZE] = {0}; +char Buff_485_2_Rd[BUFF_SIZE] = {0}; + +String latest_sent_msg; +int numOf485 = 0; +int returnTime = 0; + +/* ---------- RS485 ---------- */ +// 485 CH 1 +bool Wait_485_1; +int Wait_485_1_cnt; +int RS485_1_Addr[2] = {0,0}; +bool RS485_1_Rcv_PV[2] = {false, false}; +bool RS485_1_Rcv_SV[2] = {false, false}; +int RS485_1_Rcv_size = 8; +int RS485_1_Values_PV[8*2]; +int RS485_1_Values_SV[8*2]; + +// 485 CH 2 +bool Wait_485_2; +int Wait_485_2_cnt; +int RS485_2_Addr[2]; +bool RS485_2_Rcv_PV[2]; +bool RS485_2_Rcv_SV[2]; +int RS485_2_Rcv_size = 8; +int RS485_2_Values_PV[8*2]; +int RS485_2_Values_SV[8*2]; + //Processes String Prcss_ALL_Read(); diff --git a/FC_InterfaceBoard/FC_InterfaceBoard.ino b/FC_InterfaceBoard/FC_InterfaceBoard.ino index dfe2a93..7d87e1f 100644 --- a/FC_InterfaceBoard/FC_InterfaceBoard.ino +++ b/FC_InterfaceBoard/FC_InterfaceBoard.ino @@ -10,49 +10,6 @@ String IdeSerial; // for 485_0 -HardwareSerial* Serials[] = {&Serial1, &Serial2}; - -const int BUFF_SIZE = 512; -char Buff_Eth_Rd[BUFF_SIZE] = {0}; -char Buff_485_1_Wr[BUFF_SIZE] = {0}; -char Buff_485_1_Rd[BUFF_SIZE] = {0}; -char Buff_485_2_Wr[BUFF_SIZE] = {0}; -char Buff_485_2_Rd[BUFF_SIZE] = {0}; - -String latest_sent_msg; -int numOf485 = 0; -int returnTime = 0; - -// ---------- 485 -bool Wait_485_1; -int Wait_485_1_cnt; - -int RS485_1_Addr[2] = {0,0}; -bool RS485_1_Rcv_PV[2] = {false, false}; -bool RS485_1_Rcv_SV[2] = {false, false}; -int RS485_1_Rcv_size = 8; -int RS485_1_Values_PV[8*2]; -int RS485_1_Values_SV[8*2]; - -bool Wait_485_2; -int Wait_485_2_cnt; - -int RS485_2_Addr[2]; -bool RS485_2_Rcv_PV[2]; -bool RS485_2_Rcv_SV[2]; -int RS485_2_Rcv_size = 8; -int RS485_2_Values_PV[8*2]; -int RS485_2_Values_SV[8*2]; - - -//bool rcv_10_PV = true; -//int Size_PV = 8; -//int Values_10_PV[8]; - -//bool rcv_10_SV = true; -//int Size_SV = 8; -//int Values_10_SV[8]; - void setup() { // put your setup code here, to run once: Serial.begin(9600); @@ -111,6 +68,7 @@ void loop() { // If data read if(message != ""){ cmd = demuxCMD(message, &cmdData); + //Serial.println(">> " + message); message = ""; //Serial.println(cmd); diff --git a/FC_InterfaceBoard/GPIO.ino b/FC_InterfaceBoard/GPIO.ino index f6f7422..43370f1 100644 --- a/FC_InterfaceBoard/GPIO.ino +++ b/FC_InterfaceBoard/GPIO.ino @@ -14,6 +14,11 @@ void read_analog(){ for(i = 0 ; i < Size_AI ; i++){ Values_AI[i] = analogRead(AiPin[i]); + + for(int j = 0; j < 9; j++) { + Recent_AI[i][j] = Recent_AI[i][j + 1]; + } + Recent_AI[i][9] = Values_AI[i]; } } diff --git a/FC_InterfaceBoard/MC9.ino b/FC_InterfaceBoard/MC9.ino index 5ebe7d0..d4364c6 100644 --- a/FC_InterfaceBoard/MC9.ino +++ b/FC_InterfaceBoard/MC9.ino @@ -6,6 +6,8 @@ const int MC9_CH[] = {1000, 1008, 1016, 1024, 1100, 1108, 1116, 1124}; void setupMC9_1(int i, int data){ RS485_1_Addr[i] = data; + + Serial.println("MC9 No."+ String(i) + " 's address set as " + String(data)); } String msg_MC9_PV(int addr){ diff --git a/FC_InterfaceBoard/Periodics.ino b/FC_InterfaceBoard/Periodics.ino index 57c4549..e6af6ac 100644 --- a/FC_InterfaceBoard/Periodics.ino +++ b/FC_InterfaceBoard/Periodics.ino @@ -1,6 +1,6 @@ void Periodic_run(){ if(T_10ms){ - + read_analog(); T_10ms = false; } if(T_20ms){ @@ -11,7 +11,7 @@ void Periodic_run(){ } if(T_50ms){ // Read Arduino Inputs - read_analog(); + read_digital(); T_50ms = false; } diff --git a/FC_InterfaceBoard/Processes.ino b/FC_InterfaceBoard/Processes.ino index 020ecbe..5b97607 100644 --- a/FC_InterfaceBoard/Processes.ino +++ b/FC_InterfaceBoard/Processes.ino @@ -3,8 +3,14 @@ String Prcss_ALL_Read(){ str += "AI?:"; for (int i = 0; i < Size_AI; i++) { + int sum_AI = 0; + for(int j = 0; j < 10; j++) { + sum_AI += Recent_AI[i][j]; + } + char formattedNumber[5]; // 4자리 숫자 + 널 종료 문자 - sprintf(formattedNumber, "%04X", Values_AI[i]); // 4자리로 고정된 형식의 문자열 생성 + //sprintf(formattedNumber, "%04X", Values_AI[i]); // 4자리로 고정된 형식의 문자열 생성 + sprintf(formattedNumber, "%04X", sum_AI); // 4자리로 고정된 형식의 문자열 생성 str += formattedNumber; // 형식화된 문자열 추가 str += ','; } @@ -114,7 +120,7 @@ String Prcss_AT_Write(bool onOff){ String Prcss_RngAO(unsigned int data[], int dataSize){ String str = "RngAO!:"; int rng = 0; - int d = 20; + int d = 10; for(int i=0 ; i data[i+1]) ? data[i] : data[i+1]; diff --git a/Labview/IFB_CMD.vi b/Labview/IFB_CMD.vi index 423cd3f..72d466c 100644 Binary files a/Labview/IFB_CMD.vi and b/Labview/IFB_CMD.vi differ diff --git a/Labview/IFB_ReadData.vi b/Labview/IFB_ReadData.vi index 6292ecd..a183e5b 100644 Binary files a/Labview/IFB_ReadData.vi and b/Labview/IFB_ReadData.vi differ