You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.8 KiB
C++

void Periodic_run(){
if(T_10ms){
T_10ms = false;
}
if(T_20ms){
send_485(); // RS485 send
recieve_485(); // RS485 recieve
T_20ms = false;
}
if(T_50ms){
read_analog();
read_digital();
T_50ms = false;
}
if(T_100ms){
T_100ms = false;
}
if(T_200ms){
T_200ms = false;
}
if(T_500ms){
recieve_485_0(); // RS485 recieve (for developing)
T_500ms = false;
}
if(T_1000ms){
//write_buff(Buff_485_Wr, MC9_10_PV); // 10 DRS num 8 from ch1 PV
for(int i=0 ; i < 2 ; i++){ // RS485_1 has two rooms for two MC9s
if(RS485_1_Addr[i] > 0){ // If there is address
write_buff(Buff_485_Wr, msg_MC9_PV(RS485_1_Addr[i])); // write buff to send PV Req.
}
}
//write_buff(Buff_485_Wr, msg_MC9_PV(10));
T_1000ms = false;
}
if(T_2000ms){
if(numOf485 > 5){
Serial.print("----- remain 485 buff : "); // For
Serial.println(numOf485); // Debugging
}
T_2000ms = false;
}
if(T_5000ms){
//write_buff(Buff_485_Wr, MC9_10_SV); // 10 DRS num 8 from ch1 SV
for(int i=0 ; i < 2 ; i++){ // RS485_1 has two rooms for two MC9s
if(RS485_1_Addr[i] > 0){ // If there is address
write_buff(Buff_485_Wr, msg_MC9_SV(RS485_1_Addr[i])); // write buff to send SV Req.
}
}
//write_buff(Buff_485_Wr, msg_MC9_SV(10));
T_5000ms = false;
}
}
void timer_10ms(){
msCnt += 10;
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;
}
}