add timer for stepper
This commit is contained in:
parent
7b975bd9a9
commit
9c11f62019
@ -23,6 +23,7 @@ build_flags =
|
|||||||
;-D STEPER_PAS=755.906 ; = 65mm
|
;-D STEPER_PAS=755.906 ; = 65mm
|
||||||
-D STEPER_PAS=58 ; = 5mm
|
-D STEPER_PAS=58 ; = 5mm
|
||||||
-D STEPER_SPEED=2700 ;1000 ; 2500
|
-D STEPER_SPEED=2700 ;1000 ; 2500
|
||||||
|
-D GRBL_UPDATE=165 ;update time in ms
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;; App config ;;;
|
;;; App config ;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -28,6 +28,7 @@ private:
|
|||||||
NfcReader *nfcReader;
|
NfcReader *nfcReader;
|
||||||
GRBL *grbl;
|
GRBL *grbl;
|
||||||
BigNfcReader* outputReader;
|
BigNfcReader* outputReader;
|
||||||
|
int grblUpdateTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,6 +82,7 @@ Program::Program() {
|
|||||||
this->grbl = new GRBL(STEPMOTOR_I2C_ADDR);
|
this->grbl = new GRBL(STEPMOTOR_I2C_ADDR);
|
||||||
this->outputReader = new BigNfcReader();
|
this->outputReader = new BigNfcReader();
|
||||||
this->outputReader->init();
|
this->outputReader->init();
|
||||||
|
this->grblUpdateTime = 0;
|
||||||
Wire.begin(21, 22);
|
Wire.begin(21, 22);
|
||||||
grbl->init(STEPER_SPEED, STEPER_PAS, STEPER_ACC);
|
grbl->init(STEPER_SPEED, STEPER_PAS, STEPER_ACC);
|
||||||
struct WifiConfig wifi_c = {WIFI_SSID, WIFI_PASSWORD};
|
struct WifiConfig wifi_c = {WIFI_SSID, WIFI_PASSWORD};
|
||||||
@ -100,7 +101,7 @@ void Program::loop() {
|
|||||||
}
|
}
|
||||||
this->servo->refresh();
|
this->servo->refresh();
|
||||||
this->outputReader->refresh();
|
this->outputReader->refresh();
|
||||||
Serial.println(this->outputReader->getNbTags());
|
// Serial.println(this->outputReader->getNbTags());
|
||||||
|
|
||||||
if(this->outputReader->getNbTags() >= 2){
|
if(this->outputReader->getNbTags() >= 2){
|
||||||
lcdScreen->set_nfc_message("To mutch colis number detected");
|
lcdScreen->set_nfc_message("To mutch colis number detected");
|
||||||
@ -162,8 +163,10 @@ void Program::loop() {
|
|||||||
}
|
}
|
||||||
this->grbl->mouveForward(CONVOYER_LEN);
|
this->grbl->mouveForward(CONVOYER_LEN);
|
||||||
} else {
|
} else {
|
||||||
if(this->grbl->isIddle()){
|
if(this->grbl->isIddle() || (maintenant - this->grblUpdateTime >= GRBL_UPDATE)){
|
||||||
|
this->grblUpdateTime = maintenant;
|
||||||
this->grbl->mouveForward(5);
|
this->grbl->mouveForward(5);
|
||||||
|
Serial.print("pouet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user