Update

Dependencies:   mbed mbed-rtos X_NUCLEO_IHM02A1

Files at this revision

API Documentation at this revision

Comitter:
scherfa2
Date:
Tue May 14 20:30:07 2019 +0000
Parent:
39:6cc9a40bc8a6
Commit message:
Update

Changed in this revision

SETUP.h Show annotated file Show diff for this revision Revisions of this file
STEPPER.cpp Show annotated file Show diff for this revision Revisions of this file
STEPPER.h Show annotated file Show diff for this revision Revisions of this file
ST_DUO.cpp Show annotated file Show diff for this revision Revisions of this file
ST_DUO.h Show annotated file Show diff for this revision Revisions of this file
ST_SOLO.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SETUP.h	Tue May 14 08:05:58 2019 +0000
+++ b/SETUP.h	Tue May 14 20:30:07 2019 +0000
@@ -103,8 +103,8 @@
 
     // Weiche
     #define SERVO_FR              240 // [Hz]
-    #define GOOD_FIL             28.5 // [°] (max 90)
-    #define BAD_FIL                60 // [°] (min 0)
+    #define GOOD_FIL             25.5 // [°] (max 90)
+    #define BAD_FIL                55 // [°] (min 0)
     
     // Cutter
     #define CUTTER_FRQ_1        20000 // [Hz]
--- a/STEPPER.cpp	Tue May 14 08:05:58 2019 +0000
+++ b/STEPPER.cpp	Tue May 14 20:30:07 2019 +0000
@@ -128,7 +128,7 @@
 
 
 /* ---------------------- Get Marked Position ------------------------------- */
-/*
+
 int Stepper_1_GetMark()
 {
     return motors[0]->get_mark();
@@ -145,7 +145,7 @@
 {
     return motors2[1]->get_mark();
 }
-*/
+
 /* ---------------------------- END ----------------------------------------- */
 
 
--- a/STEPPER.h	Tue May 14 08:05:58 2019 +0000
+++ b/STEPPER.h	Tue May 14 20:30:07 2019 +0000
@@ -57,11 +57,11 @@
 void Stepper_3_GoMark();
 void Stepper_4_GoMark();
 
-/* Gibt Position welche markiert wurden zurück */ /*
+/* Gibt Position welche markiert wurden zurück */ 
 int Stepper_1_GetMark();
 int Stepper_1_GetMark();                            // Braucht man eigentlich nicht
 int Stepper_1_GetMark();                
-int Stepper_1_GetMark();*/
+int Stepper_1_GetMark();
 /* ---------------------------- END ----------------------------------------- */
 
 
--- 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;
              
     }   
--- a/ST_DUO.h	Tue May 14 08:05:58 2019 +0000
+++ b/ST_DUO.h	Tue May 14 20:30:07 2019 +0000
@@ -5,14 +5,21 @@
 {
     DUO_DEFAULT,
     DUO_START,
-    DUO_FilamentIN,
-    DUO_Schneiden1,
-    DUO_Schneiden2,
-    DUO_Spleissen,
-    DUO_Normalbetrieb,
-    DUO_Finish,
-    DUO_FERTIG,
-    DUO_STOERUNG
+    DUO_EINLEGEN,
+    DUO_FILA_CUT1,
+    DUO_FILA_BAD1,
+    DUO_FILA_GOOD2,
+    DUO_FILA_GOOD3,
+    DUO_FILA_CUT2,
+    DUO_FILA_AUSSCHUSS,
+    DUO_FILA_CUT3_1,
+    DUO_FILA_CUT3_2,
+    DUO_SPLEISSEN_VORBE_BAD,
+    DUO_SPLEISSEN_BAD,
+    DUO_SPLEISSEN_VORBE_GOOD,
+    DUO_SPLEISSEN_GOOD,
+    DUO_FILA_BAD2,
+    DUO_FERTIG_BAD
 };
 
 void EntryDUO();
--- a/ST_SOLO.cpp	Tue May 14 08:05:58 2019 +0000
+++ b/ST_SOLO.cpp	Tue May 14 20:30:07 2019 +0000
@@ -168,6 +168,8 @@
     Stepper_1_Leerlauf();
     Stepper_2_Leerlauf();
 
+    printf("Funktion_SOLOSTART\r");
+    
     DisplaySendeBefehl(0x01);
     DisplaySendeBefehl(0x0C);
     gotoxy(1, 1);
@@ -325,8 +327,9 @@
 
 
         case SOLO_DEFAULT:
+           printf("MODUS SOLO\n\r");
 
-            entry_SOLO_START();
+           entry_SOLO_START();
 
             break;
 
@@ -335,7 +338,7 @@
 
 
         case SOLO_START:
-
+            printf("MODUS SOLO\n\r");
             if(material == 1) {
                 gotoxy(1, 4);
                 DisplaySendeString("Start            ABS");
--- a/main.cpp	Tue May 14 08:05:58 2019 +0000
+++ b/main.cpp	Tue May 14 20:30:07 2019 +0000
@@ -16,6 +16,9 @@
 /* Status Spleisser definieren*/
 int StatusSpleisser = ST_SOLO;
 
+extern int StatusDUO;
+extern int StatusSOLO;
+
 
 /*Buttons initialisieren*/
 
@@ -46,7 +49,9 @@
 
 /*Input initalisieren für Status Spleisser*/
 DigitalIn InputKontrollmodul(COM_SIGNAL);
+int val_InputKontrollmodul = 0;
 
+DigitalIn CutSignal(CUT_SIGNAL);
 /* Motor Control Expansion Board. */
 XNucleoIHM02A1 *x_nucleo_ihm02a1_1;
 XNucleoIHM02A12 *x_nucleo_ihm02a1_2;
@@ -224,23 +229,35 @@
 
     /* -------------------- ---- STATE_MACHINE ------------------------------ */
     while(1) {
+        val_InputKontrollmodul=InputKontrollmodul;
+      //  printf("%i",val_InputKontrollmodul);
+        
+       //val_InputKontrollmodul = InputKontrollmodul.read();
         switch (StatusSpleisser) {
             case ST_SOLO:
-                if(InputKontrollmodul == 0) {
+                if(InputKontrollmodul == 0) 
+                {
                     EntrySOLO();
-                } else {
+                } 
+                else if(InputKontrollmodul == 1)
+                {
+                    StatusDUO =DUO_DEFAULT;
                     StatusSpleisser = ST_DUO;
                 }
                 break;
             case ST_DUO:
                 if(InputKontrollmodul == 1) {
+                    
                     EntryDUO();
-                } else {
+                } 
+                else if (InputKontrollmodul == 0)
+                {
+                    StatusSOLO =SOLO_DEFAULT;
                     StatusSpleisser = ST_SOLO;
                 }
-                break;
-
+                break;     
         }
+       
     }
     /* ------------------------------ END ----------------------------------- */