/* Name: B_FVI_AGV.ino Created: 2022-11-16 오전 13:32:00 Author: KIMCHK */ #include "motor.h" #include "IO.h" #include "HmiClass.h" #include "UtilClass.h" #include "VarClass.h" #include "VarClass.h" #include int debugportvalue = 0; String version = "22.11.16.1716"; String debugmessage = ""; void(*resetFunc)(void) = 0; unsigned long timesyncvalue = 0; unsigned long startTime = 0; void setup() { Serial.begin(57600); //디버그 및 업로드 포트 Serial1.begin(57600); //통신 포트 /*while (!Serial) true; while (!Serial1) true;*/ pinMode(13,OUTPUT); var.eeprom_load(); //플래그 우선 복원 io.Setup(); hmi.Setup(); //HMI 초기화 var.Setup(); mot.Setup(); hmi.SendMessage(F("##:SETUP:OK"),false); hmi.SendMessage(String("##:VERSION:") + String(version), false); //TCCR1B = TCCR1B & B11111000 | B00000001; // set timer 1 divisor to 1 for PWM frequency of 31372.55 Hz TCCR1B = TCCR1B & B11111000 | B00000010; // set timer 1 divisor to 8 for PWM frequency of 3921.16 Hz TCNT1 = 0x0000; //TCCR1B = TCCR1B & B11111000 | B00000011; // set timer 1 divisor to 64 for PWM frequency of 490.20 Hz PrintDebugCommand(); } void loop() { io.Update(); //DIO 상태 학인; var.Update(); //가변변수 업데이트 mot.Update(); // 모터제어 hmi.Update(); //HMI Events //초기화 if (var.runReset) { Serial.println("** RESET **"); var.eeprom_incResetCount(); var.runReset = false; resetFunc(); delay(2000); } //경과시간 unsigned long runtime = millis() - startTime; if (runtime > 60000) var.runtime = 60000; else var.runtime = (uint16_t)runtime; startTime = millis(); if(startTime % 500 == 0) { if(digitalRead(13)==HIGH) digitalWrite(13,LOW); else digitalWrite(13,HIGH); } } void UpdateTime() { //시간정보를 조회한다. 190319 timesyncvalue = millis(); } void PrintDebugCommand() { String data = ""; data += String("====================================\n"); data += String("## AGV Z-Motor Controller\n"); data += String("## Version "+ version + "\n" ); data += String("## Created by ATK4-EET-1P\n"); data += String("====================================\n"); data += String(">> ZUP (z-axis move up)\n"); data += String(">> ZUP (z-axis move up)\n"); data += String(">> ZUP (z-axis move up)\n"); data += String(">> ZUP (z-axis move up)\n"); data += String(">> ZUP (z-axis move up)\n"); data += String(">> ZUP (z-axis move up)\n"); data += String("====================================\n"); Serial.println(data); }