void Periodic_run(){
  
  if(T_1ms){
    // read_analog();
    T_1ms = false;
  }
  if(T_2ms){
    read_analog();  // runtime of 1.xxx ms @8ch
    T_2ms = false;
  }
  if(T_4ms){
    //read_analog();
    T_4ms = false;
  }
  if(T_5ms){
    //read_analog();  // runtime of 2.048012 ms @16ch
    T_5ms = false;
  }
  if(T_10ms){
    //read_analog();
    T_10ms = false;
  }
  if(T_20ms){
    send_485_1();
    send_485_2();
    recieve_485_1();
    recieve_485_2();
    T_20ms = false;
  }
  if(T_50ms){
    read_digital();
    T_50ms = false;
  }
  if(T_100ms){
    
    T_100ms = false;
  }
  if(T_200ms){
    
    T_200ms = false;
  }
  if(T_500ms){

    T_500ms = false;
  }
  if(T_1000ms){

    T_1000ms = false;
  }
  if(T_2000ms){
    // Read MC9 PV
    
    for(int i=0 ; i < 2 ; i++){
      if(RS485_1_Addr[i] > 0){
        if(write_buff(Buff_485_1_Wr, msg_MC9_PV_read(RS485_1_Addr[i]))){
			  numOf485_1++;
		    }
      }
    }
    
    for(int i=0 ; i < 2 ; i++){
      if(RS485_2_Addr[i] > 0){
        if(write_buff(Buff_485_2_Wr, msg_MC9_PV_read(RS485_2_Addr[i]))){
			  numOf485_2++;
		}
      }
    }


    if(numOf485_1 > 10){
      Serial.print("----- remain 485 buff : "); //  For
      Serial.println(numOf485_1);                 //  Debugging
    }
    T_2000ms = false;
  }
  if(T_5000ms){
    // Read MC9 SV
    for(int i=0 ; i < 2 ; i++){
      if(RS485_1_Addr[i] > 0){
        //write_buff(Buff_485_1_Wr, msg_MC9_SV_read(RS485_1_Addr[i]));
      }
    }
    T_5000ms = false;
  }
}

void timer_1ms(){
  msCnt += 1;

  T_1ms = true;
  if (msCnt % 2 == 0){
    T_2ms = true;
  }
  if (msCnt % 4 == 0){
    T_4ms = true;
  }
  if (msCnt % 5 == 0){
    T_5ms = true;
  }
  if (msCnt % 10 == 0){
    T_10ms = true;
  }
  if (msCnt % 20 == 0){
    T_20ms = true;
  }
  if (msCnt % 50 == 0){
    T_50ms = true;
  }
  if (msCnt % 100 == 0){
    T_100ms = true;
  }
  if (msCnt % 200 == 0){
    T_200ms = true;
  }
  if (msCnt % 500 == 0){
    T_500ms = true;
  }
  if (msCnt % 1000 == 0){    
    T_1000ms = true;
  }
  if (msCnt % 2000 == 0){
    T_2000ms = true;
  }
  if (msCnt > 5000){
    T_5000ms = true;
    msCnt = 0;
  }
}
