Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-rtos X_NUCLEO_IHM02A1
Diff: ST_SOLO.cpp
- Revision:
- 39:6cc9a40bc8a6
- Parent:
- 38:3776ee18e56f
- Child:
- 40:117b324843ee
--- a/ST_SOLO.cpp Mon May 13 10:11:48 2019 +0000 +++ b/ST_SOLO.cpp Tue May 14 08:05:58 2019 +0000 @@ -66,16 +66,14 @@ int StatusSOLO=SOLO_DEFAULT; + extern PwmOut Servo; -/*extern volatile bool buttonSTART_pressed; -extern volatile bool buttonSTART_enabled; - -extern volatile bool buttonAbbruch_pressed; -extern volatile bool buttonAbbruch_enabled;*/ extern DigitalIn Button1; extern DigitalIn Button2; +bool SOLO_Button1 = false; +bool SOLO_Button2 = false; extern DigitalIn LS_1; @@ -101,20 +99,401 @@ int val_LS2 = 0; int val_LS3 = 0; -bool SOLOButtonSTART = false; -bool SOLOButtonABBRUCH = false; -int count = 0; Timer machNichts; -void enable_Buttons() +void entry_SOLO_DEFAULT() +{ + val_LS3 = LS_3.read(); + if(val_LS3 == 0) { + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("ABBRUCH: "); + gotoxy(1, 2); + DisplaySendeString("Filament links"); + gotoxy(1, 4); + DisplaySendeString("entfernen"); + + Stepper_2_SetPara(TRAVELSPEED, TRAVELACC); + Stepper_2_Move('V', 5*400); + } + + DisplaySendeBefehl(0x01); + val_LS1 = LS_1.read(); + while(val_LS1 == 0) { + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("ABBRUCH: "); + gotoxy(1, 2); + DisplaySendeString("Filament rechts"); + gotoxy(1, 4); + DisplaySendeString("entfernen"); + Stepper_1_SetPara(TRAVELSPEED, TRAVELACC); + Stepper_1_Run('R', TRAVELSPEED); + val_LS1 = LS_1.read(); + } + + StatusSOLO = SOLO_DEFAULT; +} + + + + +void entry_SOLO_DEFAULT_END() +{ + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("Filament links"); + gotoxy(1, 3); + DisplaySendeString("entfernen"); + gotoxy(1, 4); + DisplaySendeString("Bestaetigen"); + + while(SOLO_Button1 == false) { + SOLO_Button1 = get_Button_1(); + } + SOLO_Button1 = false; + + StatusSOLO = SOLO_DEFAULT; +} + + + +void entry_SOLO_START() +{ + Stepper_1_Leerlauf(); + Stepper_2_Leerlauf(); + + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("MODUS: SOLO-Betrieb"); + + Set_Servo_Good_Fil(); + //Servo_Off(); + + Thread::wait(1000); // Damit Button nicht zwei mal gedrückt + + StatusSOLO = SOLO_START; +} + + + + + + +void entry_SOLO_EinlegenIN() +{ + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("Filament rechts"); + gotoxy(1, 3); + DisplaySendeString("einlegen"); + gotoxy(1, 4); + DisplaySendeString(" Abbruch"); + + StatusSOLO = SOLO_EinlegenIN; +} + + + + +void entry_SOLO_INtoSPLEISSER() +{ + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("Filament rechts"); + gotoxy(1, 3); + DisplaySendeString("bereit"); + gotoxy(1, 4); + DisplaySendeString("Weiter Abbruch"); + + StatusSOLO = SOLO_INtoSPLEISSER; +} + + + + +void entry_SOLO_EinlegenOUT() +{ + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("Filament links"); + gotoxy(1, 3); + DisplaySendeString("einlegen"); + gotoxy(1, 4); + DisplaySendeString(" Abbruch"); + + StatusSOLO = SOLO_EinlegenOUT; +} + + + + +void entry_SOLO_OUTtoSPLEISSER() +{ + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("Filamente bereit"); + gotoxy(1, 4); + DisplaySendeString("Spleissen Abbruch"); + + StatusSOLO = SOLO_OUTtoSPLEISSER; +} + + + + + +void entry_SOLO_Spleissen() +{ + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("ACHTUNG:"); + gotoxy(1, 2); + DisplaySendeString("SPLEISSENUNG!!!"); + + StatusSOLO = SOLO_Spleissen; +} + + + + + +void entry_SOLO_FERTIG() +{ + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("Filament wird"); + gotoxy(1, 2); + DisplaySendeString("abgekuehlt"); + + Thread::wait(COOLINGTIME*1000); + + StatusSOLO = SOLO_FERTIG; +} + + + + + +void Fkt_SOLO_Spleissen() { - // buttonSTART_enabled_cb(); - //buttonAbbruch_enabled_cb(); + Stepper_2_SetPara(PRECISIONSPEED, PRECISIONACC); + Stepper_2_Move('R', 0.11*400); + + Stepper_1_Move('R', 0.08*400); + Stepper_2_Move('R', 0.08*400); + + Set_Spleisser(ARConTIME, ARCoffTIME, REPETITONS); + + + Stepper_1_SetPara(FILSPEED, FILACC); + Stepper_2_SetPara(FILSPEED, FILACC); + + motors[0]->move(StepperMotor::BWD, 0.53*400*128); // kein Move wegen whait!!!! + Thread::wait(10); + Stepper_2_Move('R', 0.70*400); } + + + + + + + + + +void EntrySOLO() +{ + + SOLO_Button1 = get_Button_1(); + SOLO_Button2 = get_Button_2(); + + switch(StatusSOLO) { + + + case SOLO_DEFAULT: + + entry_SOLO_START(); + + break; + + + + + + case SOLO_START: + + if(material == 1) { + gotoxy(1, 4); + DisplaySendeString("Start ABS"); + } else if(material == 0) { + gotoxy(1, 4); + DisplaySendeString("Start PLA"); + } + + if(SOLO_Button1 == true) { + SOLO_Button1 = false; + entry_SOLO_EinlegenIN(); + } + + if(SOLO_Button2 == true) { + SOLO_Button2 = false; + material = !material; + Thread::wait(300); + } + + break; + + + + + + case SOLO_EinlegenIN: + + val_LS2 = LS_2.read(); + val_LS3 = LS_3.read(); + if(val_LS2 == 1) { + Stepper_1_SetPara(TRAVELSPEED, TRAVELACC); + Stepper_1_Run('V', TRAVELSPEED); + } else if (val_LS2 == 0 && val_LS3 == 1) { + Stepper_1_Run('V', PRECISIONSPEED);; + } else if (val_LS2 == 0 && val_LS3 == 0) { + Stepper_1_Stop(); + Stepper_1_SetPara(PRECISIONSPEED, PRECISIONACC); + Stepper_1_Move('R', 0.1*400); + entry_SOLO_INtoSPLEISSER(); + } + + if(SOLO_Button2 == true) { + SOLO_Button2 = false; + entry_SOLO_DEFAULT(); + } + + break; + + + + + + case SOLO_INtoSPLEISSER: + + if(SOLO_Button1 == true) { + SOLO_Button1 = false; + entry_SOLO_EinlegenOUT(); + } + + if(SOLO_Button2 == true) { + SOLO_Button2 = false; + entry_SOLO_DEFAULT(); + } + + break; + + + + + + + case SOLO_EinlegenOUT: + + val_LS3 = LS_3.read(); + if(val_LS3 == 1) { + Stepper_2_SetPara(PRECISIONSPEED, PRECISIONACC); + Stepper_2_Run('R', PRECISIONSPEED); + } else if (val_LS3 == 0) { + Stepper_2_Stop(); + entry_SOLO_OUTtoSPLEISSER(); + } + + if(SOLO_Button2 == true) { + SOLO_Button2 = false; + entry_SOLO_DEFAULT(); + } + + break; + + + + + case SOLO_OUTtoSPLEISSER: + + if(SOLO_Button1 == true) { + SOLO_Button1 = false; + entry_SOLO_Spleissen(); + } + + if(SOLO_Button2 == true) { + SOLO_Button2 = false; + entry_SOLO_DEFAULT(); + } + + break; + + case SOLO_Spleissen: + + Fkt_SOLO_Spleissen(); + + entry_SOLO_FERTIG(); + + break; + + + + + + case SOLO_FERTIG: + + DisplaySendeBefehl(0x01); + DisplaySendeBefehl(0x0C); + gotoxy(1, 1); + DisplaySendeString("Filament wird"); + gotoxy(1, 2); + DisplaySendeString("ausgeworfen"); + + val_LS3 = LS_3.read(); + while(val_LS3 == 0) { + Stepper_1_SetPara(TRAVELSPEED, SLOWACC); + Stepper_2_SetPara(TRAVELSPEED, SLOWACC); + + motors[0]->run(StepperMotor::FWD, TRAVELSPEED+200); + motors[1]->run(StepperMotor::FWD, TRAVELSPEED+200); + + //Stepper_1_Run('V', TRAVELSPEED+100); + //Stepper_2_Run('V', TRAVELSPEED+100); + + val_LS3 = LS_3.read(); + } + + Stepper_1_Leerlauf(); + Stepper_2_Leerlauf(); + + entry_SOLO_DEFAULT_END(); + + break; + + case SOLO_STOERUNG: + + break; + + } +} + + +/* + void entry_SOLO_DEFAULT() { StatusSOLO = SOLO_DEFAULT; @@ -201,7 +580,7 @@ void EntrySOLO() { - + SOLOButtonSTART = get_Button_1(); SOLOButtonSTART = get_Button_2(); switch(StatusSOLO) { @@ -225,7 +604,7 @@ } if(SOLOButtonSTART == true) { - + SOLOButtonSTART = false; //buttonAbbruch_pressed = false; //buttonAbbruch_diable_cb(); @@ -235,7 +614,7 @@ if(SOLOButtonSTART == true) { - + SOLOButtonSTART = false; //buttonSTART_pressed = false; //buttonSTART_diable_cb(); @@ -405,12 +784,12 @@ //motors[0]->move(StepperMotor::FWD, 0.2*400*128); motors[1]->move(StepperMotor::FWD, 0.05*400*128); - + //Set_Cutter(400, 200, 4); motors[1]->wait_while_active(); - + motors[1]->set_max_speed(300); motors[1]->set_acceleration(300); @@ -421,10 +800,10 @@ motors[1]->move(StepperMotor::FWD, 1*400*128); motors[1]->wait_while_active(); Stepper_2_Leerlauf(); - /* + motors[0]->perform_prepared_actions(); motors2[0]->perform_prepared_actions(); - */ + @@ -434,14 +813,6 @@ //Stepper_3_Move('V', 1.3*400); - - - - /* - Stepper_3_Move('V', 1*400); - Stepper_1_Move('V', 1*400); - */ - StatusSOLO = SOLO_STOERUNG; break; @@ -454,5 +825,4 @@ } } - - +*/