[Digital][MC9]

- Digital port 수정
  ㄴ DO, DI 핀번호 수정 (for IFB v1.1)
- MC9 Auto Tune 기능 추가
  ㄴ 테스트 완료
main
Changwoo Park 1 year ago
parent 6c60af89fa
commit 917c8a121e

@ -7,7 +7,7 @@ String Prcss_AO_Write(unsigned int data[], int dataSize);
String Prcss_PV_Read(); String Prcss_PV_Read();
String Prcss_SV_Read(); String Prcss_SV_Read();
String Prcss_SV_Write(unsigned int data[], int dataSize); 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_RngAO(unsigned int data[], int dataSize);
String Prcss_ChMC9(unsigned int data[], int dataSize); String Prcss_ChMC9(unsigned int data[], int dataSize);

@ -70,9 +70,9 @@ int RngAO[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// ========== ========== Processing // ========== ========== Processing
// Read Datas // Read Datas
const int DoPin[] = { 26, 27, 28, 29, 30, 31, 32, 33, const int DoPin[] = { 34, 35, 36, 37, 38, 39, 40, 41,
34, 35, 36, 37, 38, 39, 40, 41}; 42, 43, 44, 45, 46, 47, 48, 49};
const int DiPin[] = { 2, 3, 4, 5, 6, 7, 8, 9}; const int DiPin[] = { 26, 27, 28, 29, 30, 31, 32, 33};
const int AiPin[] = { A0, A1, A2, A3, A4, A5, A6, A7, const int AiPin[] = { A0, A1, A2, A3, A4, A5, A6, A7,
A8, A9, A10, A11, A12, A13, A14, A15}; A8, A9, A10, A11, A12, A13, A14, A15};
@ -189,6 +189,11 @@ void loop() {
else if(cmd=="SV!"){ else if(cmd=="SV!"){
dataSize = demuxNum(cmdData, data); dataSize = demuxNum(cmdData, data);
client.print(Prcss_SV_Write(data, dataSize)); 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!"){ else if(cmd=="ATon!"){

@ -101,6 +101,79 @@ int msg_MC9_SV_set(unsigned int data[], int dataSize){
return 0; 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 saveMC9(String message){
int addr; int addr;
int idx = -1; int idx = -1;

@ -17,7 +17,7 @@ String Prcss_ALL_Read(){
str += ','; str += ',';
str += RcvOK; str += RcvOK;
str += "PV10?:"; str += "PV_0?:";
if(rcv_10_PV){ if(rcv_10_PV){
for (int i = 0; i < RS485_1_Rcv_size*2; i++) { for (int i = 0; i < RS485_1_Rcv_size*2; i++) {
char formattedNumber[5]; char formattedNumber[5];
@ -30,7 +30,7 @@ String Prcss_ALL_Read(){
str += RcvErr; str += RcvErr;
} }
str += "SV10?:"; str += "SV_0?:";
if(rcv_10_SV){ if(rcv_10_SV){
for (int i = 0; i < RS485_1_Rcv_size*2; i++) { for (int i = 0; i < RS485_1_Rcv_size*2; i++) {
char formattedNumber[5]; char formattedNumber[5];
@ -84,6 +84,15 @@ String Prcss_SV_Write(unsigned int data[], int dataSize){
return str + FIN; 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 Prcss_AT_Write(bool onOff){
String str = "AT!:"; String str = "AT!:";
String message, cmd; String message, cmd;
@ -103,7 +112,7 @@ String Prcss_AT_Write(bool onOff){
str += RcvOK; str += RcvOK;
return str + FIN; return str + FIN;
} }
*/
String Prcss_RngAO(unsigned int data[], int dataSize){ String Prcss_RngAO(unsigned int data[], int dataSize){
String str = "RngAO!:"; String str = "RngAO!:";
int rng = 0; int rng = 0;

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save