Francesco Pistone
/
FORIGO_Modula_V6_R2C_DE_HwV5_OTTOBRE2018
tr
Diff: main.cpp
- Revision:
- 6:3fca0ca1949e
- Parent:
- 5:3b95bbfe2dc9
- Child:
- 7:c9fd242538d9
--- a/main.cpp Wed Jul 04 05:51:03 2018 +0000 +++ b/main.cpp Thu Jul 05 16:30:54 2018 +0000 @@ -130,6 +130,7 @@ speedTimer.reset(); pulseRised=1; oldTractorSpeedRead=1; + spazioCoperto+= pulseDistance; } speedFilter.reset(); speedClock=1; @@ -190,9 +191,6 @@ }else{ intraPickDistance = seedPerimeter/25.0f; // 25 è il numero di fori presenti nel disco di semina } - if (anticipoMax > ((360.0f/pickNumber)-(avvioGradi+16.0f))){ - anticipoMax=(360.0f/pickNumber)-(avvioGradi+16.0f); - } } //******************************************************* void cambiaTB(double perio){ @@ -250,7 +248,6 @@ avvioGradi = costante da terminale tritecnica TBdeltaStep=(fixedStepGiroSD/pickNumber)-(stepGrado*avvioGradi); TBfaseStep = (stepGrado*angoloFase); - anticipoMax = valore in gradi del massimo anticipo proporzionale alla velocità della ruota di semina */ if ((tractorSpeed_MtS_timed>0.01f)){ @@ -651,6 +648,47 @@ mast2_Sinc = mast2_Sinc + ((uint32_t) rxMsg.data[7]); canDataCheck=1; } + if (rxMsg.id==RX_Configure){ + uint8_t flags = rxMsg.data[0]; + uint16_t steps = (uint32_t) rxMsg.data[1]*0xFF00; + steps = steps + ((uint32_t)rxMsg.data[2]); + cellsCountSet = rxMsg.data[3]; + if ((flags&0x01)==0x01){ + encoder=true; + }else{ + encoder=false; + } + if ((flags&0x02)==0x02){ + tankLevelEnable=true; + }else{ + tankLevelEnable=false; + } + if ((flags&0x04)==0x04){ + seedSensorEnable=true; + }else{ + seedSensorEnable=false; + } + if ((flags&0x08)==0x08){ + stendiNylonEnable=true; + }else{ + stendiNylonEnable=false; + } + if ((flags&0x10)==0x10){ + canDataCheckEnable=true; + }else{ + canDataCheckEnable=false; + } + if ((flags&0x20)==0x20){ + tamburoStandard=1; + }else{ + tamburoStandard=0; + } + if ((flags&0x40)==0x40){ + currentCheckEnable=true; + }else{ + currentCheckEnable=false; + } + } } #endif #if defined(overWriteCanSimulation) @@ -1128,8 +1166,8 @@ if(speedForCorrection >= speedOfSeedWheel){ fase1=TBdeltaStep; }else{ - //fase1=(TBdeltaStep)-(((speedOfSeedWheel-speedForCorrection)/1.25f)*(TBfaseStep)); - fase1=(TBdeltaStep)-(((speedOfSeedWheel)/1.25f)*(TBfaseStep)); + //fase1=(TBdeltaStep)-(((speedOfSeedWheel-speedForCorrection)/maxWorkSpeed)*(TBfaseStep)); + fase1=(TBdeltaStep)-(((speedOfSeedWheel)/maxWorkSpeed)*(TBfaseStep)); } if (fase1 > limite){ fase1 -= limite; // se la fase calcolata supera gli step del settore riporta il valore nell'arco precedente (es. fase 1 800, limite 750, risulta 50) @@ -1275,7 +1313,7 @@ // torna indietro per sbloccare il tamburo if ((TBmotorDirecti==1)&&(erroreTamburo==1)){ cntCellsForReload++; - if (cntCellsForReload > 2){ + if (cntCellsForReload >= cellsCountSet){ TBmotorDirecti=0; erroreTamburo=0; } @@ -1396,6 +1434,10 @@ tractorSpeed_MtS_timed = 0.0f; enableSpeed=0; } + // esegue il controllo di velocità massima + if ((double)speedTimer.read_ms()<=minIntervalPulse){ + tractorSpeed_MtS_timed = 4.5f; + } //*************************************************************************************************************** // cycle logic control section //*************************************************************************************************************** @@ -1427,7 +1469,7 @@ dutyTeorico = tabComan[ii+1]; } } - if (tractorSpeed_MtS_timed > tabSpeed[16]){dutyTeorico=tractorSpeed_MtS_timed/1.25f;} + if (tractorSpeed_MtS_timed > tabSpeed[16]){dutyTeorico=tractorSpeed_MtS_timed/maxWorkSpeed;} #if !defined(speedMaster) quinCalc(); #endif @@ -1498,23 +1540,23 @@ #endif } // introduce il controllo di corrente - if (incrementCurrent){ - boostDcOut +=0.005f; - } - if (reduceCurrent){ - boostDcOut -=0.005f; + if (currentCheckEnable==true){ + if (incrementCurrent){ + boostDcOut +=0.005f; + } + if (reduceCurrent){ + boostDcOut -=0.005f; + } + if (boostDcOut >= 0.2f){ + boostDcOut=0.2f; + all_genericals=1; + } + if (boostDcOut <=-0.2f){ + boostDcOut=-0.2f; + all_genericals=1; + } + correzione += boostDcOut; } - if (boostDcOut >= 0.2f){ - boostDcOut=0.2f; - all_genericals=1; - } - if (boostDcOut <=-0.2f){ - boostDcOut=-0.2f; - all_genericals=1; - } - - //correzione += boostDcOut; - DC_brake=0; DC_forward=1; DC_prepare(); @@ -1588,7 +1630,7 @@ }else{ ritardoMassimo = (double)timeIntraPick; } - int tempoDiSincro = (int)((double)(ritardoMassimo - ((tempoBecco/2.0f)+((speedOfSeedWheel/1.25f)*ritardoMassimo)))); // + int tempoDiSincro = (int)((double)(ritardoMassimo - ((tempoBecco/2.0f)+((speedOfSeedWheel/maxWorkSpeed)*ritardoMassimo)))); // if (tempoDiSincro <= 1){tempoDiSincro=1;} if ((sincroTimer.read_ms()>= tempoDiSincro)){ if (tractorSpeed_MtS_timed >= minWorkSpeed){startCicloTB=1;}