Messa in campo 4 file - 26/06/2020 Francia

Dependencies:   mbed X_NUCLEO_IHM03A1_for

Fork of FORIGO_Modula_V7_3_VdcStep_maggio2020 by Francesco Pistone

Revision:
18:7c978f69cc51
Parent:
17:9629eb019892
Child:
19:231b8931cabc
--- a/main.cpp	Fri Apr 05 07:52:39 2019 +0000
+++ b/main.cpp	Fri Apr 12 12:20:05 2019 +0000
@@ -197,18 +197,11 @@
             TBpassPosition= (uint32_t) motor->get_position();
             if (TBpassPosition >= TBoldPosition){
                 TBactualPosition= ((TBpassPosition-TBoldPosition)*TBreductionRatio);//*10;
-                #if defined(pcSerial)
-                    #if defined(rtosData) 
-                        printf(" 1   Position: %d TBpass: %d Tbold: %d \r\n", TBactualPosition, TBpassPosition, TBoldPosition);
-                    #endif
-                #endif
             }else{
                 TBactualPosition=((((2097152-TBoldPosition)+TBpassPosition))*TBreductionRatio);//*10;
-                #if defined(pcSerial)
-                    #if defined(rtosData) 
-                        printf(" 2   Position: %d TBpass: %d Tbold: %d \r\n", TBactualPosition, TBpassPosition, TBoldPosition);
-                    #endif
-                #endif
+                TBactualPosition= 1;
+                TBoldPosition=0;
+                motor->set_home();
             }
             //wait_us(50); // 50 mS di intervallo lettura
         //}
@@ -366,8 +359,7 @@
     #endif
 }
 //*******************************************************
-void step_TBPulseOut()
-{
+void step_TBPulseOut(){
     TBmotorStepOut=!TBmotorStepOut;
     if (TBmotorStepOut==0) {
         if (TBmotorDirecti==TBforward) {
@@ -399,6 +391,9 @@
                 motor->step_clock_mode_enable(StepperMotor::FWD);
             #endif
         #endif
+        #if defined(provaStepper)
+            motor->run(StepperMotor::FWD,150.0f);
+        #endif
     } else {
         TBmotorDirecti=TBreverse;
         #if !defined(runner)
@@ -408,6 +403,9 @@
                 motor->step_clock_mode_enable(StepperMotor::BWD);
             #endif
         #endif
+        #if defined(provaStepper)
+            motor->run(StepperMotor::BWD,100.0f);
+        #endif
     }
     #if defined(pcSerial)
         #if defined(inversione)
@@ -1447,7 +1445,7 @@
         #endif
     }
 #endif
-
+// ----------------------------------------
 void aggiornati(){
     #if defined(runner)
         legPos.detach();
@@ -1589,7 +1587,7 @@
             motor->run(StepperMotor::BWD,100.0f);
             //motor->step_clock_mode_enable(StepperMotor::FWD);
         #else
-            motor->run(StepperMotor::BWD,5.0f);
+            motor->run(StepperMotor::BWD,100.0f);
             //motor->step_clock_mode_enable(StepperMotor::BWD);
         #endif
         // attiva l'out per il controllo dello stepper in stepClockMode
@@ -1600,7 +1598,7 @@
             #endif
         #endif
         //TBticker.attach(&step_TBPulseOut,0.0005f);  // clock time are seconds and attach seed motor stepper controls
-        //TATicker.attach(&invertiLo,3.0f);
+        TATicker.attach(&invertiLo,3.0f);
     #else
         // definire il pin di clock che è PB_3
         motor->set_home();
@@ -1824,13 +1822,13 @@
                     if ((tractorSpeed_MtS_timed==0.0f)) {
                         if ((firstStart==0)&&(simOk==0)&&(enableSimula==0)) {
                             cntSpeedError++;
-                            if (cntSpeedError >= 3){
+                            if (cntSpeedError >= 5){
                                 all_noSpeedSen=1;
                             }
                         }
                     }
                     if (tractorSpeed_MtS_timed>0.2f){
-                        double oldLastPr = (double)oldLastPulseRead*1.8f;
+                        double oldLastPr = (double)oldLastPulseRead*2.8f;
                         if((double)speedTimeOut.read_us()> (oldLastPr)) {
                             if ((firstStart==0)&&(simOk==0)&&(enableSimula==0)) {
                                 all_speedError =1;
@@ -1971,7 +1969,7 @@
             }
             if ((double)TBactualPosition > ((TBgiroStep/cellsNumber)*1.8f)&&(erroreTamburo==0)) {
                 if (firstStart==0) {
-                    if (tractorSpeed_MtS_timed>0.5f){
+                    if (tractorSpeed_MtS_timed>0.4f){
                         if (cntTbError>5) {
                             all_cellSignal=1;
                             #if defined(seedSensor)
@@ -2461,6 +2459,10 @@
                         #endif
                     #endif
                     motor->soft_hiz();
+                    motor->set_home();
+                    cntSpeedError=0;    
+                    timeIntraPick=0.0f;
+                    memoIntraPick=0.0f;
                     pntMedia=0;
                     #if defined(pcSerial)
                         #if defined(stopSignal)