Messa in campo 4 file - 26/06/2020 Francia
Dependencies: mbed X_NUCLEO_IHM03A1_for
Fork of FORIGO_Modula_V7_3_VdcStep_maggio2020 by
Diff: main.cpp
- Revision:
- 20:4a400a4cc419
- Parent:
- 19:231b8931cabc
- Child:
- 21:3e6576c2e126
--- a/main.cpp Tue Apr 23 16:01:54 2019 +0000 +++ b/main.cpp Fri Apr 26 13:46:42 2019 +0000 @@ -975,6 +975,12 @@ avviaSimula = rxMsg.data[2]; selezionato = rxMsg.data[3]; comandiDaCan = rxMsg.data[4]; + speedStepp = rxMsg.data[5]; + if (speedStepp==0){ + simStepper=0; + }else{ + simStepper=1; + } #if defined(pcSerial) #if defined(canDataReceived) pc.printf("Speed simula %d \n",speedSimula); @@ -1716,6 +1722,21 @@ //************************************************************************************************************** if (inProva==0) { + // simulazione stepper + if (simStepper==1){ + oldSimStepper=true; + simStepSpeed= ((double)speedStepp*180.45f)/50.0f; + if (oldSimStepSpeed!=simStepSpeed){ + motor->run(StepperMotor::FWD,simStepSpeed); + oldSimStepSpeed=simStepSpeed; + } + }else{ + if (oldSimStepper==true){ + oldSimStepper=false; + motor->soft_hiz(); + oldSimStepSpeed=0.0f; + } + } if ((startCycleSimulation==0)&&(enableSimula==0)) { runRequestBuf=1;//0; } else { @@ -1886,7 +1907,7 @@ oldTBzeroPinInput=0; } } - if ((TBzeroPinInput==1)&&(oldTBzeroPinInput==0)) { + if (((TBzeroPinInput==1)&&(oldTBzeroPinInput==0))&&(simStepper==0)) { oldTBzeroPinInput=1; if (loadDaCanInCorso==0) { stopCicloTB=1; @@ -1967,7 +1988,7 @@ delaySeedCheck.start(); #endif } - if ((double)TBactualPosition > ((TBgiroStep/cellsNumber)*1.8f)&&(erroreTamburo==0)) { + if (((double)TBactualPosition > ((TBgiroStep/cellsNumber)*1.8f)&&(erroreTamburo==0))&&(simStepper==0)) { if (firstStart==0) { if (tractorSpeed_MtS_timed>0.4f){ if (cntTbError>5) { @@ -2021,7 +2042,7 @@ } // ---------------------------------------- // read and manage joystick - if (loadDaCan==1) { + if ((loadDaCan==1)&(simStepper==0)) { if (tractorSpeed_MtS_timed==0.0f) { #if defined(pcSerial) #if defined(checkLoop) @@ -2106,7 +2127,7 @@ oldLocalTractorSpeed=0.0f; } } - if ((tractorSpeed_MtS_timed>0.01f)) { + if ((tractorSpeed_MtS_timed>0.01f)&&(simStepper==0)) { #if defined(pcSerial) #if defined(Qncc) pc.printf("TsP: %f SpW: %f InPic: %f EPerc: %f Duty:%f \n",tractorSpeed_MtS_timed,speedOfSeedWheel,timeIntraPick, errorePercentuale, dcActualDuty); @@ -2458,8 +2479,10 @@ pc.printf("A5\n"); #endif #endif - motor->soft_hiz(); - motor->set_home(); + if(simStepper==0){ + motor->soft_hiz(); + motor->set_home(); + } cntSpeedError=0; timeIntraPick=0.0f; memoIntraPick=0.001f;