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