![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
tr
variables.hpp@15:2af7ca4c5eb9, 2019-01-29 (annotated)
- Committer:
- nerit
- Date:
- Tue Jan 29 07:05:20 2019 +0000
- Revision:
- 15:2af7ca4c5eb9
- Parent:
- 14:24c5d58e8bc6
Reinvio versione V6 del 10 01 19
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nerit | 6:3fca0ca1949e | 1 | /* |
nerit | 6:3fca0ca1949e | 2 | variabili generali di programma e set iniziali |
nerit | 6:3fca0ca1949e | 3 | */ |
nerit | 6:3fca0ca1949e | 4 | |
nerit | 6:3fca0ca1949e | 5 | // SET INIZIALI DI MACCHINA |
nerit | 6:3fca0ca1949e | 6 | bool canDataCheckEnable=false; // a true per attivare il controllo del quinconce anche con dati CAN |
nerit | 7:c9fd242538d9 | 7 | int speedFromPick = 0; // definisce se il controllo di velocità della ruota di semina è gestita dai becchi (set a 1) o dai fori sul disco (set a 0) |
nerit | 14:24c5d58e8bc6 | 8 | bool encoder=true; // true quando montato motore DC con encoder incorporato |
nerit | 6:3fca0ca1949e | 9 | // NOTA: SE ENCODER=TRUE ALLORA SPEEDFROMPICK DEVE ESSERE MESSO A 0 |
nerit | 6:3fca0ca1949e | 10 | int tamburoStandard=1; // a 1 per tamburo parallelo alla ruota di semina, a 0 per zucca |
nerit | 14:24c5d58e8bc6 | 11 | int cambiaStep=0; |
nerit | 6:3fca0ca1949e | 12 | |
nerit | 6:3fca0ca1949e | 13 | bool tankLevelEnable = false; |
nerit | 6:3fca0ca1949e | 14 | bool seedSensorEnable=false; |
nerit | 6:3fca0ca1949e | 15 | bool stendiNylonEnable=false; |
nerit | 6:3fca0ca1949e | 16 | bool currentCheckEnable=false; |
nerit | 6:3fca0ca1949e | 17 | uint8_t cellsCountSet=1; |
nerit | 15:2af7ca4c5eb9 | 18 | int changeStep=0; |
nerit | 6:3fca0ca1949e | 19 | |
nerit | 6:3fca0ca1949e | 20 | // VARIABILI DI PROGRAMMA |
nerit | 0:1e09cd7d66b4 | 21 | int zeroRequestBuf=0; |
nerit | 0:1e09cd7d66b4 | 22 | int runRequestBuf=0; |
nerit | 0:1e09cd7d66b4 | 23 | |
nerit | 0:1e09cd7d66b4 | 24 | // define cycle variable related to the external command |
nerit | 0:1e09cd7d66b4 | 25 | int oldTractorSpeedRead=0; |
nerit | 0:1e09cd7d66b4 | 26 | int startCycle=0; // activate motors and functions |
nerit | 0:1e09cd7d66b4 | 27 | int enableCycle=0; // enable regular cycle |
nerit | 0:1e09cd7d66b4 | 28 | int zeroCycle=0; // azzeramento motori richiesto |
nerit | 0:1e09cd7d66b4 | 29 | int OldStartCycle=0; // use for triggering command change |
nerit | 0:1e09cd7d66b4 | 30 | int OldEnableCycle=0; |
nerit | 0:1e09cd7d66b4 | 31 | int oldZeroCycle=0; // memoria azzeramento motori su richiesta |
nerit | 0:1e09cd7d66b4 | 32 | int zeroCycleEnd=0; // ciclo di azzeramento completato |
nerit | 0:1e09cd7d66b4 | 33 | int zeroTrigger=0; |
nerit | 6:3fca0ca1949e | 34 | int TBzeroPinInput=0; // segnale invertito micro tamburo |
nerit | 6:3fca0ca1949e | 35 | int seedWheelZeroPinInput=0; // segnale invertito sensore ruota di semina |
nerit | 0:1e09cd7d66b4 | 36 | int SD_faultA=0; |
nerit | 0:1e09cd7d66b4 | 37 | int SD_faultB=0; |
nerit | 6:3fca0ca1949e | 38 | int DC_brake=1; // comando gestione frenatura motore DC |
nerit | 6:3fca0ca1949e | 39 | int DC_forward=1; // comando gestione direzione motore DC |
nerit | 0:1e09cd7d66b4 | 40 | |
nerit | 0:1e09cd7d66b4 | 41 | int oldFaseLavoro=0; |
nerit | 0:1e09cd7d66b4 | 42 | |
nerit | 0:1e09cd7d66b4 | 43 | // define logic internal variables |
nerit | 0:1e09cd7d66b4 | 44 | double tractorSpeed_MtS_timed=0.0f; // tractor speed calculated from pulse interval time |
nerit | 0:1e09cd7d66b4 | 45 | double speedForDisplay[5]={0.0f,0.0f,0.0f,0.0f,0.0f}; |
nerit | 0:1e09cd7d66b4 | 46 | double totalSpeed=0.0f; |
nerit | 0:1e09cd7d66b4 | 47 | double OLDpulseSpeedInterval=1000.01f; // tractor speed calculated from pulse interval time |
nerit | 0:1e09cd7d66b4 | 48 | double pulseDistance=0.0f; // linear space between pulse |
nerit | 0:1e09cd7d66b4 | 49 | double pulseDistanceCalc=0.0f; |
nerit | 0:1e09cd7d66b4 | 50 | double speedPerimeter=0.0f; // perimeter of tractor speed wheel |
nerit | 0:1e09cd7d66b4 | 51 | double seedPerimeter=0.0f; // perimeter of seed wheel |
nerit | 0:1e09cd7d66b4 | 52 | double mediaSpeed[5]={0.0f,0.0f,0.0f,0.0f,0.0f}; |
nerit | 0:1e09cd7d66b4 | 53 | int pntMedia=0; |
nerit | 0:1e09cd7d66b4 | 54 | int actualPulseReadTimer=0; // timer read at previous pulse |
nerit | 0:1e09cd7d66b4 | 55 | double pulseSpeedInterval=0.0f; // delta time of pulse |
nerit | 0:1e09cd7d66b4 | 56 | int lastPulseRead=0; |
nerit | 0:1e09cd7d66b4 | 57 | int oldLastPulseRead=0; |
nerit | 0:1e09cd7d66b4 | 58 | int pulseRised=0; // pulse from speed wheel occured. Define when is possible to determine speed of up down motor. |
nerit | 0:1e09cd7d66b4 | 59 | int pulseRised1 = 0; |
nerit | 0:1e09cd7d66b4 | 60 | int pulseRised2 = 0; |
nerit | 6:3fca0ca1949e | 61 | |
nerit | 0:1e09cd7d66b4 | 62 | double rapportoRuote = 0.0f; |
nerit | 0:1e09cd7d66b4 | 63 | double TBrpm = 0.0f; |
nerit | 0:1e09cd7d66b4 | 64 | double TBfrequency = 0.0f; |
nerit | 0:1e09cd7d66b4 | 65 | double TBperiod = 0.0f; |
nerit | 0:1e09cd7d66b4 | 66 | double oldPeriodoTB = 0.0f; |
nerit | 0:1e09cd7d66b4 | 67 | int SDzeroCyclePulse=0; |
nerit | 0:1e09cd7d66b4 | 68 | int TBzeroCyclePulse=0; |
nerit | 0:1e09cd7d66b4 | 69 | int SDzeroed=0; |
nerit | 0:1e09cd7d66b4 | 70 | int TBzeroed=0; |
nerit | 0:1e09cd7d66b4 | 71 | int oldOnSDzero=0; |
nerit | 0:1e09cd7d66b4 | 72 | int oldOnTBzero=0; |
nerit | 0:1e09cd7d66b4 | 73 | int oldOffSDzero=0; |
nerit | 0:1e09cd7d66b4 | 74 | int oldOffTBzero=0; |
nerit | 0:1e09cd7d66b4 | 75 | int SDzeroPinTrig=0; |
nerit | 0:1e09cd7d66b4 | 76 | int TBzeroPinTrig=0; |
nerit | 0:1e09cd7d66b4 | 77 | int SDzeroDebounced=0; |
nerit | 0:1e09cd7d66b4 | 78 | int SDrunZero=0; |
nerit | 0:1e09cd7d66b4 | 79 | int TBrunZero=0; |
nerit | 0:1e09cd7d66b4 | 80 | int syncroCheck=0; |
nerit | 0:1e09cd7d66b4 | 81 | double memoStepTB=0.0f; |
nerit | 0:1e09cd7d66b4 | 82 | double erroreSyncro=0.0f; |
nerit | 0:1e09cd7d66b4 | 83 | double errorePercentuale=1.0f; |
nerit | 0:1e09cd7d66b4 | 84 | int oldSeedWheelZeroPinInput=0; |
nerit | 0:1e09cd7d66b4 | 85 | int oldTBzeroPinInput=0; |
nerit | 0:1e09cd7d66b4 | 86 | int stopCicloTB = 0; |
nerit | 0:1e09cd7d66b4 | 87 | int startCicloTB = 0; |
nerit | 0:1e09cd7d66b4 | 88 | int cicloTbinCorso = 0; |
nerit | 0:1e09cd7d66b4 | 89 | int beccoPronto =0; |
nerit | 0:1e09cd7d66b4 | 90 | int memoIntraPick=0; |
nerit | 0:1e09cd7d66b4 | 91 | |
nerit | 0:1e09cd7d66b4 | 92 | double realSpeed = 0.0f; |
nerit | 0:1e09cd7d66b4 | 93 | double realGiroSD = 0.0f; |
nerit | 0:1e09cd7d66b4 | 94 | double tempoBecco = 0.0f; |
nerit | 0:1e09cd7d66b4 | 95 | double frequenzaReale = 0.0f; |
nerit | 0:1e09cd7d66b4 | 96 | double semiPeriodoReale = 0.0f; |
nerit | 0:1e09cd7d66b4 | 97 | double tempoTraBecchi_mS = 0.0f; |
nerit | 0:1e09cd7d66b4 | 98 | double tempoGiroSD = 0.0f; |
nerit | 0:1e09cd7d66b4 | 99 | |
nerit | 0:1e09cd7d66b4 | 100 | // variable for speed and step calculation |
nerit | 0:1e09cd7d66b4 | 101 | uint32_t prePosSD=0; // actual position of seed wheel (step of motor) |
nerit | 0:1e09cd7d66b4 | 102 | uint32_t SDactualPosition=0; // actual position of seed wheel (step of motor) |
nerit | 0:1e09cd7d66b4 | 103 | uint32_t TBactualPosition=0; |
nerit | 5:3b95bbfe2dc9 | 104 | uint32_t posForQuinc=0; |
nerit | 0:1e09cd7d66b4 | 105 | |
nerit | 0:1e09cd7d66b4 | 106 | int cycleStopRequest=0; // when cycle end request the zero of SD and UD |
nerit | 0:1e09cd7d66b4 | 107 | |
nerit | 0:1e09cd7d66b4 | 108 | double duty_DC=0.0f; |
nerit | 0:1e09cd7d66b4 | 109 | double oldDuty_DC=0.0f; |
nerit | 0:1e09cd7d66b4 | 110 | |
nerit | 0:1e09cd7d66b4 | 111 | double dcActualDuty = 0.0f; // valore di lavoro del duty cycle |
nerit | 4:d32258ec411f | 112 | double olddcActualDuty = 0.0f; // valore di lavoro del duty cycle |
nerit | 0:1e09cd7d66b4 | 113 | double correzione = 0.0f; |
nerit | 0:1e09cd7d66b4 | 114 | double periodo =0.0f; |
nerit | 0:1e09cd7d66b4 | 115 | double ePpos = 0.0f; |
nerit | 0:1e09cd7d66b4 | 116 | int aspettaStart=1; |
nerit | 0:1e09cd7d66b4 | 117 | int countCicli=0; |
nerit | 0:1e09cd7d66b4 | 118 | uint32_t fase = 0; |
nerit | 0:1e09cd7d66b4 | 119 | |
nerit | 0:1e09cd7d66b4 | 120 | int clocca=0; |
nerit | 0:1e09cd7d66b4 | 121 | int enableSpeed=0; |
nerit | 0:1e09cd7d66b4 | 122 | double speedOfSeedWheel =0.0f; |
nerit | 0:1e09cd7d66b4 | 123 | int lowSpeed = 0; |
nerit | 0:1e09cd7d66b4 | 124 | double valore=0.0f; |
nerit | 0:1e09cd7d66b4 | 125 | //char val1[8]={0,0,0,0,0,0,0,0}; |
nerit | 0:1e09cd7d66b4 | 126 | |
nerit | 0:1e09cd7d66b4 | 127 | uint8_t enableSimula=0; |
nerit | 0:1e09cd7d66b4 | 128 | uint8_t speedSimula=0; |
nerit | 0:1e09cd7d66b4 | 129 | uint8_t avviaSimula=0; |
nerit | 0:1e09cd7d66b4 | 130 | double oldSimulaSpeed=0.0f; |
nerit | 0:1e09cd7d66b4 | 131 | int selezionato =0; |
nerit | 0:1e09cd7d66b4 | 132 | int simOk=0; |
nerit | 0:1e09cd7d66b4 | 133 | |
nerit | 0:1e09cd7d66b4 | 134 | float SD_CurrentAnalog=0.0f; // valore di corrente sull'ingresso |
nerit | 0:1e09cd7d66b4 | 135 | float SD_CurrentScaled=0.0f; // valore di corrente convertito in scala |
nerit | 0:1e09cd7d66b4 | 136 | float SD_CurrentFactor=40.0f; // fattore di scala sensore 40mV/A |
nerit | 0:1e09cd7d66b4 | 137 | float SD_CurrentPeak=0.0f; // valore massimo corrente |
nerit | 0:1e09cd7d66b4 | 138 | float SD_CurrentMid=0.0f; // valore medio corrente |
nerit | 0:1e09cd7d66b4 | 139 | float SD_CurrentLast=0.0f; // valore precedente corrente |
nerit | 0:1e09cd7d66b4 | 140 | float SD_CurrentStart=0.0f; // valore a vuoto corrente (circa il 50% della tensione di alimentazione del sensore) |
nerit | 0:1e09cd7d66b4 | 141 | bool reduceCurrent=false; |
nerit | 0:1e09cd7d66b4 | 142 | bool incrementCurrent=false; |
nerit | 0:1e09cd7d66b4 | 143 | double boostDcOut=0.0f; |
nerit | 0:1e09cd7d66b4 | 144 | |
nerit | 0:1e09cd7d66b4 | 145 | float SD_analogMatrix[21]={0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f}; |
nerit | 0:1e09cd7d66b4 | 146 | int SD_analogIndex[11]={0,0,0,0,0,0,0,0,0,0}; |
nerit | 0:1e09cd7d66b4 | 147 | int frenata=0; |
nerit | 0:1e09cd7d66b4 | 148 | int accensione=1; |
nerit | 0:1e09cd7d66b4 | 149 | double SDsectorStep =0.0f; |
nerit | 0:1e09cd7d66b4 | 150 | double TBsectorStep = 0.0f; |
nerit | 0:1e09cd7d66b4 | 151 | double KcorT = 0.0f; |
nerit | 0:1e09cd7d66b4 | 152 | |
nerit | 0:1e09cd7d66b4 | 153 | int trigSD=0; |
nerit | 0:1e09cd7d66b4 | 154 | int trigTB=0; |
nerit | 0:1e09cd7d66b4 | 155 | int inhibit=0; |
nerit | 0:1e09cd7d66b4 | 156 | int trigCicli=0; |
nerit | 0:1e09cd7d66b4 | 157 | int avvicinamento=0; |
nerit | 0:1e09cd7d66b4 | 158 | int lowSpeedRequired=0; |
nerit | 0:1e09cd7d66b4 | 159 | |
nerit | 0:1e09cd7d66b4 | 160 | uint8_t alarmHighRegister=0x00; |
nerit | 0:1e09cd7d66b4 | 161 | uint8_t alarmLowRegister=0x00; |
nerit | 0:1e09cd7d66b4 | 162 | double TBgiroStep=0.0f; |
nerit | 0:1e09cd7d66b4 | 163 | int firstStart=1; |
nerit | 8:0e643ea7834f | 164 | int noSDzeroRequest=0; |
nerit | 0:1e09cd7d66b4 | 165 | int timeHole=0; |
nerit | 0:1e09cd7d66b4 | 166 | int memoTimeHole=0; |
nerit | 0:1e09cd7d66b4 | 167 | int lockStart=0; |
nerit | 0:1e09cd7d66b4 | 168 | |
nerit | 0:1e09cd7d66b4 | 169 | uint8_t quincStart=0; |
nerit | 0:1e09cd7d66b4 | 170 | uint8_t oldQuincIn=0; |
nerit | 0:1e09cd7d66b4 | 171 | double scostamento = 0.0f; |
nerit | 0:1e09cd7d66b4 | 172 | uint8_t quincEnable=0; |
nerit | 0:1e09cd7d66b4 | 173 | uint8_t quincCnt=0; |
nerit | 0:1e09cd7d66b4 | 174 | double percento=0.0f; |
nerit | 0:1e09cd7d66b4 | 175 | uint32_t masterSinc=0; |
nerit | 5:3b95bbfe2dc9 | 176 | uint32_t mast2_Sinc=0; |
nerit | 0:1e09cd7d66b4 | 177 | bool quincClock=false; |
nerit | 1:e88bf5011af6 | 178 | double oldQuincTimeSD=0.0f; |
nerit | 4:d32258ec411f | 179 | uint8_t sincroQui=0; |
nerit | 4:d32258ec411f | 180 | uint8_t quincPIDminus=0; |
nerit | 4:d32258ec411f | 181 | uint8_t quincPIDplus=0; |
nerit | 4:d32258ec411f | 182 | uint8_t quincLIMminus=0; |
nerit | 4:d32258ec411f | 183 | uint8_t quincLIMplus=0; |
nerit | 4:d32258ec411f | 184 | double memoCorrCorr=0.0f; |
nerit | 5:3b95bbfe2dc9 | 185 | double speedFromMaster=0.0f; |
nerit | 5:3b95bbfe2dc9 | 186 | uint8_t quincSector=0; |
nerit | 5:3b95bbfe2dc9 | 187 | uint8_t canDataCheck=0; |
nerit | 5:3b95bbfe2dc9 | 188 | double tempoBecchiPerQuinc=0.0f; |
nerit | 5:3b95bbfe2dc9 | 189 | int countPicks=0; |
nerit | 6:3fca0ca1949e | 190 | uint8_t quinconceActive=0; |
nerit | 7:c9fd242538d9 | 191 | uint8_t oldQuinconceOut=0; |
nerit | 4:d32258ec411f | 192 | |
nerit | 0:1e09cd7d66b4 | 193 | double stepGrado = 0.0f; |
nerit | 0:1e09cd7d66b4 | 194 | double TBfaseStep =0.0f; |
nerit | 0:1e09cd7d66b4 | 195 | double angoloPh=7.0f; |
nerit | 0:1e09cd7d66b4 | 196 | double angoloAv=0.0f; |
nerit | 0:1e09cd7d66b4 | 197 | |
nerit | 0:1e09cd7d66b4 | 198 | uint8_t checkSDrotation=0; |
nerit | 0:1e09cd7d66b4 | 199 | uint8_t comandiDaCan=0; |
nerit | 0:1e09cd7d66b4 | 200 | uint8_t azzeraDaCan=0; |
nerit | 0:1e09cd7d66b4 | 201 | uint8_t loadDaCan=0; |
nerit | 0:1e09cd7d66b4 | 202 | uint8_t loadDaCanInCorso=0; |
nerit | 0:1e09cd7d66b4 | 203 | uint8_t cntCellsForLoad=0; |
nerit | 0:1e09cd7d66b4 | 204 | uint8_t trigRepos=0; |
nerit | 0:1e09cd7d66b4 | 205 | uint8_t forzaFase=0; |
nerit | 0:1e09cd7d66b4 | 206 | uint8_t erroreTamburo=0; |
nerit | 0:1e09cd7d66b4 | 207 | uint8_t cntCellsForReload=0; |
nerit | 0:1e09cd7d66b4 | 208 | uint8_t cntTbError=0; |
nerit | 0:1e09cd7d66b4 | 209 | |
nerit | 0:1e09cd7d66b4 | 210 | uint8_t cellsCounterLow=0; |
nerit | 0:1e09cd7d66b4 | 211 | uint8_t cellsCounterHig=0; |
nerit | 0:1e09cd7d66b4 | 212 | uint8_t pickCounterLow=0; |
nerit | 0:1e09cd7d66b4 | 213 | uint8_t pickCounterHig=0; |
nerit | 7:c9fd242538d9 | 214 | uint8_t seedSee=0; |
nerit | 0:1e09cd7d66b4 | 215 | |
nerit | 9:503e2aba047c | 216 | uint8_t cntCellsCorrect=0; |
nerit | 9:503e2aba047c | 217 | |
nerit | 0:1e09cd7d66b4 | 218 | uint8_t all_semiFiniti = 0; // semi finiti (generato dal relativo sensore) |
nerit | 0:1e09cd7d66b4 | 219 | uint8_t all_pickSignal = 0; // errore segnale becchi (generato dal tempo tra un becco ed il successivo) |
nerit | 0:1e09cd7d66b4 | 220 | uint8_t all_cellSignal = 0; // errore segnale celle (generato dal sensore tamburo ) |
nerit | 0:1e09cd7d66b4 | 221 | uint8_t all_lowBattery = 0; // allarme batteria (valore interno di tritecnica) |
nerit | 0:1e09cd7d66b4 | 222 | uint8_t all_overCurrDC = 0; // sovracorrente motore DC (generato dal sensore di corrente) |
nerit | 0:1e09cd7d66b4 | 223 | uint8_t all_stopSistem = 0; // sistema in stop (a tempo con ruota ferma) |
nerit | 0:1e09cd7d66b4 | 224 | uint8_t all_upElements = 0; // elementi sollevati (generato dal relativo sensore) |
nerit | 0:1e09cd7d66b4 | 225 | uint8_t all_noSeedOnCe = 0; // fallanza di semina (manca il seme nella cella) |
nerit | 0:1e09cd7d66b4 | 226 | uint8_t all_cfgnErrors = 0; // errore di configurazione (incongruenza dei parametri impostati) |
nerit | 0:1e09cd7d66b4 | 227 | uint8_t all_noDcRotati = 0; // ruota di semina bloccata (arriva la velocità ma non i becchi) |
nerit | 0:1e09cd7d66b4 | 228 | uint8_t all_noStepRota = 0; // tamburo di semina bloccato (comando il tamburo ma non ricevo il sensore) |
nerit | 0:1e09cd7d66b4 | 229 | uint8_t all_speedError = 0; // errore sensore velocità (tempo impulsi non costante) |
nerit | 0:1e09cd7d66b4 | 230 | uint8_t all_noSpeedSen = 0; // mancanza segnale di velocità (sento i becchi ma non la velocita) |
nerit | 0:1e09cd7d66b4 | 231 | uint8_t all_no_Zeroing = 0; // mancato azzeramento sistema (generato dal timeout del comando motore DC) |
nerit | 0:1e09cd7d66b4 | 232 | uint8_t all_genericals = 0; // allarme generico |
nerit | 0:1e09cd7d66b4 | 233 | uint8_t resetComandi=0; |
nerit | 0:1e09cd7d66b4 | 234 | |
nerit | 15:2af7ca4c5eb9 | 235 | //uint32_t spazioCoperto=0; |