Update
Dependencies: mbed mbed-rtos X_NUCLEO_IHM02A1
Diff: ST_DUO.cpp
- Revision:
- 40:117b324843ee
- Parent:
- 38:3776ee18e56f
diff -r 6cc9a40bc8a6 -r 117b324843ee ST_DUO.cpp --- a/ST_DUO.cpp Tue May 14 08:05:58 2019 +0000 +++ b/ST_DUO.cpp Tue May 14 20:30:07 2019 +0000 @@ -3,19 +3,20 @@ int StatusDUO=DUO_DEFAULT; -bool ButtonSTART = false; -bool ButtonABBRUCH = false; + +extern DigitalIn InputKontrollmodul; +extern DigitalIn CutSignal; +int val_CutSignal = 0; -/* -extern volatile bool buttonSTART_pressed; -extern volatile bool buttonSTART_enabled; +bool Fila_Good = false; + +bool ABS = false; -extern volatile bool buttonAbbruch_pressed; -extern volatile bool buttonAbbruch_enabled; -*/ +bool PLA = true; - +bool ButtonSTART = false; +bool ButtonABBRUCH = false; extern PwmOut Servo; @@ -31,6 +32,31 @@ extern PwmOut Spleisser_1; extern PwmOut Spleisser_2; + +bool get_InputKontrollmodul() +{ + val_CutSignal = CutSignal.read(); + if( val_CutSignal == 1) + { + wait(0.01); + if(val_CutSignal == 1) + { + return true; + } + } + else if(val_CutSignal == 0) + { + wait(0.01); + if(val_CutSignal == 0) + { + return false; + } + } + else return false; +} + + + void EntryDuoDefault() { StatusDUO=DUO_DEFAULT; @@ -41,6 +67,7 @@ Stepper_1_Leerlauf(); Stepper_2_Leerlauf(); Stepper_3_Leerlauf(); + Set_Servo_Bad_Fil(); DisplaySendeBefehl(0x0C); DisplaySendeBefehl(0x01); @@ -48,63 +75,111 @@ DisplaySendeString("Modus: DUO-Betrieb"); gotoxy(1,4); DisplaySendeString("Start PLA"); + + PLA = true; + ABS = false; StatusDUO=DUO_START; } -void EntryDuoFilamentIN() +void EntryDuoEinlegen() { - DisplaySendeBefehl(0x01); - gotoxy(1,1); - DisplaySendeString("Betrieb gestartet "); - gotoxy(1,3); - DisplaySendeString("Filament einlegen "); - gotoxy(1,4); - DisplaySendeString(" Abbruch"); - - // Set_Cutter(200, 200, 2); - - motors[0]->run(StepperMotor::FWD, 100); - StatusDUO=DUO_FilamentIN; + DisplaySendeBefehl(0x01); + gotoxy(1,1); + DisplaySendeString("Filament einlgenen"); + gotoxy(1,4); + DisplaySendeString(" Abbruch"); + + Stepper_1_Run('V', 300); + + StatusDUO=DUO_EINLEGEN; } -void EntryDuoSchneiden1() +void DuoWechselFilament() +{ + int static x = 0; + + if((PLA == true)&& (x == 0)) + { + gotoxy(1,4); + DisplaySendeString("Start ABS"); + + PLA = false; + ABS = true; + x = 1; + } + + if( (ABS == true)&& (x == 0)) + { + gotoxy(1,4); + DisplaySendeString("Start PLA"); + + PLA = true; + ABS = false; + } + + if(x == 1) + { + x = 0; + } + wait(0.3); + StatusDUO=DUO_START; +} + +void EntryDuoFilaCut1() { + /********************************* + + CUT PROZESS + + **********************************/ + DisplaySendeBefehl(0x01); + gotoxy(1,1); + DisplaySendeString("Filament wird ge-"); + gotoxy(1,3); + DisplaySendeString("schnitten"); + + Stepper_1_Stop(); + Stepper_3_Leerlauf(); + + Stepper_3_SetPara(100, 100); + Stepper_1_SetPara(100, 100); + + Set_Cutter(500, 0, 1); + motors2[0]->move(StepperMotor::FWD, 128*400*5); + motors[0]->move(StepperMotor::BWD, 128*400*0.3); + Set_Cutter(600, 0, 1); + + motors2[0]->wait_while_active(); + motors[0]->move(StepperMotor::FWD, 128*400*0.3); + motors[0]->wait_while_active(); + + wait(10); + Set_Servo_Good_Fil(); Stepper_1_SetHome(); + Stepper_1_Run('V', 150); + DisplaySendeBefehl(0x01); gotoxy(1,1); - DisplaySendeString("Filament an Eingang"); + DisplaySendeString("Filament ist gut "); gotoxy(1,3); - DisplaySendeString("Wird gefoerdert..."); + DisplaySendeString("wird gefoerdert... "); gotoxy(1,4); - DisplaySendeString("Spleissen Abbruch"); - - StatusDUO=DUO_Schneiden1; - -} -void EntryDuoSchneiden2() -{ - Stepper_1_SetHome(); + DisplaySendeString(" Abbruch"); - DisplaySendeBefehl(0x01); - gotoxy(1,1); - DisplaySendeString("Spleissen"); - gotoxy(1,3); - DisplaySendeString(""); - gotoxy(1,4); - DisplaySendeString(" Abbruch"); - - - - Set_Spleisser(200, 200, 2); - Stepper_2_Move('V', 400); - printf("Spleissen\r\n"); - - - StatusDUO=DUO_Schneiden2; - + StatusDUO=DUO_FILA_CUT1; +} + +void EntryDuoFilaBad1() +{ + Stepper_1_SetPara(TRAVELSPEED+100, TRAVELACC+300); + Stepper_1_GoHome(); + // Set_Servo_Bad_Fil(); + //Stepper_1_Run('V', 150); + + StatusDUO=DUO_FILA_BAD1; } @@ -112,81 +187,108 @@ { ButtonSTART = get_Button_1(); ButtonABBRUCH = get_Button_2(); + Fila_Good = get_InputKontrollmodul(); switch(StatusDUO) { case DUO_DEFAULT: - //buttonAbbruch_diable_cb(); - //buttonSTART_enabled_cb(); + EntryDuoStart(); break; case DUO_START: + printf("MODUS DUO\n\r"); if(ButtonSTART==true) { - - ButtonSTART=false; - // buttonSTART_diable_cb(); - //buttonAbbruch_enabled_cb(); - EntryDuoFilamentIN(); + ButtonSTART=false; + EntryDuoEinlegen(); } - + else if(ButtonABBRUCH == true) + { + ButtonABBRUCH=false; + DuoWechselFilament(); + } + break; - case DUO_FilamentIN: - if(LS_1 == 0) + case DUO_EINLEGEN: + if(Fila_Good == false) //für Test->==false wenn gedrückt(heisst Filament ist gut) { - EntryDuoSchneiden1(); + EntryDuoFilaCut1(); } - if(ButtonABBRUCH == true) + else if(ButtonABBRUCH == true) { - ButtonABBRUCH = false; - //buttonAbbruch_pressed=false; - //buttonAbbruch_diable_cb(); + ButtonABBRUCH=false; EntryDuoDefault(); } break; - case DUO_Schneiden1: - if(ButtonABBRUCH == true) - { - ButtonABBRUCH = false; - //buttonAbbruch_pressed=false; - //buttonAbbruch_diable_cb(); - EntryDuoDefault(); + case DUO_FILA_CUT1: + if(Fila_Good == true) //für Test->==true wenn gedrückt(heisst Filament ist schlecht) + { + EntryDuoFilaBad1(); } - if(ButtonSTART == true) + else if(LS_3 == 0) { - ButtonSTART = false; - EntryDuoSchneiden2(); - + EntryDuoDefault();// nur für test + //EntryFilaGood2(); } - - break; - - case DUO_Schneiden2: - if(ButtonABBRUCH == true) - { - ButtonABBRUCH = false; - EntryDuoDefault(); + else if(ButtonABBRUCH == true) + { + ButtonABBRUCH=false; + EntryDuoDefault(); } break; - case DUO_Spleissen: + case DUO_FILA_BAD1: + if(Fila_Good == false) //für Test->==false wenn gedrückt(heisst Filament ist gut) + { + + } + else if(ButtonABBRUCH == true) + { + ButtonABBRUCH=false; + EntryDuoDefault(); + } + break; - case DUO_Normalbetrieb: + case DUO_FILA_GOOD2: + break; + + case DUO_FILA_GOOD3: + break; + + case DUO_FILA_CUT2: break; - case DUO_Finish: + case DUO_FILA_AUSSCHUSS: + break; + + case DUO_FILA_CUT3_1: + break; + + case DUO_FILA_CUT3_2: + break; + + case DUO_SPLEISSEN_VORBE_BAD: break; - case DUO_FERTIG: + case DUO_SPLEISSEN_BAD: + break; + + case DUO_SPLEISSEN_VORBE_GOOD: break; - case DUO_STOERUNG: + case DUO_SPLEISSEN_GOOD: + break; + + case DUO_FILA_BAD2: + break; + + case DUO_FERTIG_BAD: break; }