vo

Dependencies:   mbed CANMsg

Revision:
0:1e09cd7d66b4
Child:
1:e88bf5011af6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/variables.hpp	Wed Jun 13 08:52:42 2018 +0000
@@ -0,0 +1,210 @@
+int zeroRequestBuf=0;
+int runRequestBuf=0;
+
+// define cycle variable related to the external command
+int oldTractorSpeedRead=0;
+int startCycle=0;                   // activate motors and functions 
+int enableCycle=0;                  // enable regular cycle
+int zeroCycle=0;                    // azzeramento motori richiesto
+int OldStartCycle=0;                // use for triggering command change
+int OldEnableCycle=0;
+int oldZeroCycle=0;                 // memoria azzeramento motori su richiesta
+int zeroCycleEnd=0;                 // ciclo di azzeramento completato
+int zeroTrigger=0;
+int TBzeroPinInput=0;            // segnale invertito micro tamburo 
+int seedWheelZeroPinInput=0;    // segnale invertito sensore ruota di semina
+int SD_faultA=0;
+int SD_faultB=0;
+int DC_brake=1;
+int DC_forward=1;
+
+
+int oldFaseLavoro=0;
+
+// define logic internal variables
+double tractorSpeed_MtS_timed=0.0f;   // tractor speed calculated from pulse interval time
+double speedForDisplay[5]={0.0f,0.0f,0.0f,0.0f,0.0f};
+double totalSpeed=0.0f;
+double OLDpulseSpeedInterval=1000.01f;   // tractor speed calculated from pulse interval time
+double pulseDistance=0.0f;            // linear space between pulse
+double pulseDistanceCalc=0.0f;
+double speedPerimeter=0.0f;           // perimeter of tractor speed wheel 
+double seedPerimeter=0.0f;            // perimeter of seed wheel 
+double mediaSpeed[5]={0.0f,0.0f,0.0f,0.0f,0.0f};
+int pntMedia=0;
+int actualPulseReadTimer=0;             // timer read at previous pulse
+double pulseSpeedInterval=0.0f;            // delta time of pulse
+int lastPulseRead=0;
+int oldLastPulseRead=0;
+int pulseRised=0;                    // pulse from speed wheel occured. Define when is possible to determine speed of up down motor. 
+int pulseRised1 = 0;
+int pulseRised2 = 0;
+                                     // Set from interrupt routine and Reset from main after up down motor speed calculated
+double rapportoRuote = 0.0f;
+double TBrpm = 0.0f;
+double TBfrequency = 0.0f;
+double TBperiod = 0.0f;
+double oldPeriodoTB = 0.0f;
+int SDzeroCyclePulse=0;
+int TBzeroCyclePulse=0;
+int SDzeroed=0;
+int TBzeroed=0;
+int oldOnSDzero=0;
+int oldOnTBzero=0;
+int oldOffSDzero=0;
+int oldOffTBzero=0;
+int SDzeroPinTrig=0;
+int TBzeroPinTrig=0;
+int SDzeroDebounced=0;
+int SDrunZero=0;
+int TBrunZero=0;
+int syncroCheck=0;
+double memoStepTB=0.0f;
+double erroreSyncro=0.0f;
+double errorePercentuale=1.0f;
+int oldSeedWheelZeroPinInput=0;
+int oldTBzeroPinInput=0;
+int stopCicloTB = 0;
+int startCicloTB = 0;
+int cicloTbinCorso = 0;
+int beccoPronto =0;
+int memoIntraPick=0;
+
+double realSpeed = 0.0f;
+double realGiroSD = 0.0f;
+double tempoBecco = 0.0f;
+double frequenzaReale = 0.0f;
+double semiPeriodoReale = 0.0f;
+double tempoTraBecchi_mS = 0.0f;
+double tempoGiroSD = 0.0f;
+
+// variable for speed and step calculation
+uint32_t prePosSD=0;        // actual position of seed wheel (step of motor)
+uint32_t SDactualPosition=0;        // actual position of seed wheel (step of motor)
+uint32_t TBactualPosition=0;
+
+int cycleStopRequest=0;             // when cycle end request the zero of SD and UD
+
+double duty_DC=0.0f;
+double oldDuty_DC=0.0f;
+
+double dcActualDuty = 0.0f;  // valore di lavoro del duty cycle
+double correzione = 0.0f;
+double periodo =0.0f;
+double ePpos = 0.0f;
+int aspettaStart=1;
+int countCicli=0;
+uint32_t fase = 0;
+
+int clocca=0;
+int enableSDcontrol=0;
+int enableSpeed=0;
+double speedOfSeedWheel =0.0f;
+int lowSpeed = 0;
+double valore=0.0f;
+//char val1[8]={0,0,0,0,0,0,0,0};
+
+uint8_t enableSimula=0;
+uint8_t speedSimula=0;
+uint8_t avviaSimula=0;
+double oldSimulaSpeed=0.0f;
+int selezionato =0;
+int simOk=0;
+
+float SD_CurrentAnalog=0.0f;                    // valore di corrente sull'ingresso
+float SD_CurrentScaled=0.0f;                    // valore di corrente convertito in scala
+float SD_CurrentFactor=40.0f;                   // fattore di scala sensore 40mV/A
+float SD_CurrentPeak=0.0f;                      // valore massimo corrente
+float SD_CurrentMid=0.0f;                       // valore medio corrente
+float SD_CurrentLast=0.0f;                      // valore precedente corrente
+float SD_CurrentStart=0.0f;                     // valore a vuoto corrente (circa il 50% della tensione di alimentazione del sensore)
+bool reduceCurrent=false;
+bool incrementCurrent=false;
+double boostDcOut=0.0f;
+
+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};
+int SD_analogIndex[11]={0,0,0,0,0,0,0,0,0,0};
+int frenata=0;
+int accensione=1;
+double SDsectorStep =0.0f;
+double TBsectorStep = 0.0f;
+double KcorT = 0.0f;
+
+int trigSD=0;
+int trigTB=0;
+int inhibit=0;
+int trigCicli=0;
+int avvicinamento=0;
+int lowSpeedRequired=0;
+
+uint8_t alarmHighRegister=0x00;
+uint8_t alarmLowRegister=0x00;
+double TBgiroStep=0.0f;
+int firstStart=1;
+int timeHole=0;
+int memoTimeHole=0;
+int lockStart=0;
+
+uint8_t quincStart=0;
+uint8_t quincStop=0;
+uint8_t oldQuincIn=0;
+double scostamento = 0.0f;
+double quincError = 0.0f;
+uint8_t quincEnable=0;
+uint8_t quincCnt=0;
+double memoDutyStop=0.0f;
+uint8_t trigStop=0;
+double propoQuinc=0.0f;
+uint8_t accelera=0;
+uint8_t decelera=0;
+double percento=0.0f;
+double memoDuty=0.0f;
+uint32_t masterSinc=0;
+uint8_t quincVerify=0;
+bool trigDaMaster=false;
+bool trigSlave= false;
+bool quincInibit=false;
+bool quincClock=false;
+bool correggiSD=false;
+                                                // se indefinito utilizza il tamburo ortogonale per i semi di zucca
+double stepGrado = 0.0f;
+double TBfaseStep =0.0f;
+int tamburoStandard=1;                          // tamburo parallelo alla ruota di semina
+int speedFromPick = 1;                          // definisce se il controllo di velocità della ruota di semina è gestita dai becchi (set a 1) o dai fori sul disco (set a 0)
+double angoloPh=7.0f;
+double angoloAv=0.0f;
+
+uint8_t checkSDrotation=0;
+uint8_t comandiDaCan=0;
+uint8_t azzeraDaCan=0;
+uint8_t loadDaCan=0;
+uint8_t loadDaCanInCorso=0;
+uint8_t cntCellsForLoad=0;
+uint8_t trigRepos=0;
+uint8_t forzaFase=0;
+uint8_t erroreTamburo=0;
+uint8_t cntCellsForReload=0;
+uint8_t cntTbError=0;
+
+uint8_t cellsCounterLow=0;
+uint8_t cellsCounterHig=0;
+uint8_t pickCounterLow=0;
+uint8_t pickCounterHig=0;
+
+uint8_t all_semiFiniti = 0;     // semi finiti (generato dal relativo sensore)
+uint8_t all_pickSignal = 0;     // errore segnale becchi (generato dal tempo tra un becco ed il successivo)
+uint8_t all_cellSignal = 0;     // errore segnale celle (generato dal sensore tamburo )
+uint8_t all_lowBattery = 0;     // allarme batteria (valore interno di tritecnica)
+uint8_t all_overCurrDC = 0;     // sovracorrente motore DC  (generato dal sensore di corrente)
+uint8_t all_stopSistem = 0;     // sistema in stop (a tempo con ruota ferma)
+uint8_t all_upElements = 0;     // elementi sollevati   (generato dal relativo sensore)
+uint8_t all_noSeedOnCe = 0;     // fallanza di semina (manca il seme nella cella)
+uint8_t all_cfgnErrors = 0;     // errore di configurazione     (incongruenza dei parametri impostati)
+uint8_t all_noDcRotati = 0;     // ruota di semina bloccata (arriva la velocità ma non i becchi)
+uint8_t all_noStepRota = 0;     // tamburo di semina bloccato   (comando il tamburo ma non ricevo il sensore)
+uint8_t all_speedError = 0;     // errore sensore velocità  (tempo impulsi non costante)
+uint8_t all_noSpeedSen = 0;     // mancanza segnale di velocità (sento i becchi ma non la velocita)
+uint8_t all_no_Zeroing = 0;     // mancato azzeramento sistema (generato dal timeout del comando motore DC)
+uint8_t all_genericals = 0;     // allarme generico
+uint8_t resetComandi=0;
+