Stabilus 322699 wDoublePID
Dependencies: mbed QEI PID DmTftLibraryEx
main.cpp@32:1be3d79ff4db, 2022-04-08 (annotated)
- Committer:
- lex9296
- Date:
- Fri Apr 08 05:27:20 2022 +0000
- Revision:
- 32:1be3d79ff4db
- Parent:
- 31:913f664c6189
- Child:
- 33:f77aa3ecf87d
Actuator is Working, but I might need some Current Loop.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GregCr | 0:9c0917bfde97 | 1 | |
lex9296 | 23:b9d23a2f390e | 2 | //Warning: Incompatible redefinition of macro "MBED_RAM_SIZE" in "tmp/HU5Hqj", Line: 39, Col: 10 |
lex9296 | 23:b9d23a2f390e | 3 | #ifndef MBED_RAM_SIZE |
lex9296 | 23:b9d23a2f390e | 4 | #define MBED_RAM_SIZE 0x00018000 |
lex9296 | 23:b9d23a2f390e | 5 | #endif |
lex9296 | 23:b9d23a2f390e | 6 | |
lex9296 | 23:b9d23a2f390e | 7 | #include "QEI.h" |
lex9296 | 23:b9d23a2f390e | 8 | #include "SWPos.h" |
lex9296 | 23:b9d23a2f390e | 9 | |
GregCr | 0:9c0917bfde97 | 10 | #include "Timers.h" |
GregCr | 0:9c0917bfde97 | 11 | #include "Eeprom.h" |
GregCr | 0:9c0917bfde97 | 12 | |
lex9296 | 27:654100855f5c | 13 | #define MAX_CHAR_PER_LINE 28 |
lex9296 | 27:654100855f5c | 14 | #define TEXT_ROW_SPACING 16 |
lex9296 | 27:654100855f5c | 15 | #define FONT_CHAR_WIDTH 8 |
lex9296 | 27:654100855f5c | 16 | #define FONT_CHAR_HEIGHT 16 |
lex9296 | 27:654100855f5c | 17 | |
lex9296 | 27:654100855f5c | 18 | #include "DisplayDriver.h" |
lex9296 | 27:654100855f5c | 19 | |
lex9296 | 32:1be3d79ff4db | 20 | void LCM_ShowTactics( |
lex9296 | 32:1be3d79ff4db | 21 | int32_t i32_Pulses, |
lex9296 | 32:1be3d79ff4db | 22 | int32_t i32_ATVSpeed, |
lex9296 | 32:1be3d79ff4db | 23 | float f_ai0000_Aux, |
lex9296 | 32:1be3d79ff4db | 24 | float f_ai0001_Aux, |
lex9296 | 32:1be3d79ff4db | 25 | float f_ai0002_Aux, |
lex9296 | 32:1be3d79ff4db | 26 | float f_ai0003_Aux, |
lex9296 | 32:1be3d79ff4db | 27 | float f_ai0004_Aux, |
lex9296 | 32:1be3d79ff4db | 28 | float f_ai0005_Aux |
lex9296 | 32:1be3d79ff4db | 29 | ); |
lex9296 | 29:7ce8c5779f5e | 30 | static void SampleAndStore (void); |
lex9296 | 32:1be3d79ff4db | 31 | |
lex9296 | 29:7ce8c5779f5e | 32 | Ticker SampleTimer; // LA: To Sample 1AI any ms |
lex9296 | 29:7ce8c5779f5e | 33 | float af_PlotSamples[240]; // LA: "Horiz" Plot Array |
lex9296 | 29:7ce8c5779f5e | 34 | |
lex9296 | 30:e45282a70a4d | 35 | uint16_t aui16_PlotSamples[240]; |
lex9296 | 30:e45282a70a4d | 36 | uint16_t aui16_PlotClears_Lo[240]; |
lex9296 | 30:e45282a70a4d | 37 | uint16_t aui16_PlotClears_Hi[240]; |
lex9296 | 30:e45282a70a4d | 38 | |
lex9296 | 26:bfca0c471a87 | 39 | // LA: Theory of Operation |
lex9296 | 26:bfca0c471a87 | 40 | // =================== |
lex9296 | 26:bfca0c471a87 | 41 | // |
lex9296 | 26:bfca0c471a87 | 42 | // Il PWM funziona da sè in Interrupt |
lex9296 | 26:bfca0c471a87 | 43 | // Il QEI funziona da sè in Interrupt |
lex9296 | 26:bfca0c471a87 | 44 | // Se si creano dei Ticker (Che sono a loro volta interrupt(s)) è possibile che PWM e QEI perdano correlazione con l'HW. |
lex9296 | 26:bfca0c471a87 | 45 | // |
lex9296 | 26:bfca0c471a87 | 46 | // PQM |
lex9296 | 26:bfca0c471a87 | 47 | // |
lex9296 | 26:bfca0c471a87 | 48 | // Il rinfresco del Display e la gestione del motion vanno fatte il più frequentemente possibile ma fuori dal loop dei Ticker. |
lex9296 | 26:bfca0c471a87 | 49 | // Con qst versione (LA0005, che termina un FORK (il successivo è LA0010) quanto detto sopra è FUNZIONANTE. |
lex9296 | 26:bfca0c471a87 | 50 | // Questo messaggio è incluso nel "commitment" |
lex9296 | 26:bfca0c471a87 | 51 | |
GregCr | 0:9c0917bfde97 | 52 | /*! |
GregCr | 0:9c0917bfde97 | 53 | * \brief Define IO for Unused Pin |
GregCr | 0:9c0917bfde97 | 54 | */ |
lex9296 | 23:b9d23a2f390e | 55 | //DigitalOut F_CS (D6); // MBED description of pin |
lex9296 | 23:b9d23a2f390e | 56 | //DigitalOut SD_CS (D8); // MBED description of pin |
lex9296 | 23:b9d23a2f390e | 57 | |
lex9296 | 23:b9d23a2f390e | 58 | DigitalIn userButton (USER_BUTTON); |
lex9296 | 32:1be3d79ff4db | 59 | // |
lex9296 | 32:1be3d79ff4db | 60 | DigitalOut rENA_Off (PC_0); // CN7.38 - Power Enable Relay, Power Disabled when true |
lex9296 | 32:1be3d79ff4db | 61 | DigitalOut rDIR_FWD (PC_1); // CN7.36 - Move Direction Relay Bridge, Move FW(Extends) when true |
mverdy | 15:ed7ed20b7114 | 62 | |
lex9296 | 23:b9d23a2f390e | 63 | AnalogIn adc_temp (ADC_TEMP); |
lex9296 | 23:b9d23a2f390e | 64 | AnalogIn adc_vref (ADC_VREF); |
lex9296 | 23:b9d23a2f390e | 65 | AnalogIn adc_vbat (ADC_VBAT); |
GregCr | 0:9c0917bfde97 | 66 | |
lex9296 | 29:7ce8c5779f5e | 67 | AnalogIn ADC12_IN9 (PA_4); // STM32 PA4 |
lex9296 | 29:7ce8c5779f5e | 68 | AnalogIn ADC12_IN15 (PB_0); // STM32 PB0 |
lex9296 | 29:7ce8c5779f5e | 69 | |
lex9296 | 23:b9d23a2f390e | 70 | // PWM |
lex9296 | 23:b9d23a2f390e | 71 | // === |
lex9296 | 23:b9d23a2f390e | 72 | // |
lex9296 | 25:5fd2d69e2927 | 73 | PwmOut PWM_PB3(PWM_OUT); // LA: PWM_OUT = D3 = PB_3 |
mverdy | 14:ebd89dacc807 | 74 | |
lex9296 | 28:443c82750dd9 | 75 | // QEI |
lex9296 | 28:443c82750dd9 | 76 | // === |
lex9296 | 28:443c82750dd9 | 77 | // |
lex9296 | 28:443c82750dd9 | 78 | QEI Stabilus322699 (PA_1, PA_0, NC, 100, QEI::X4_ENCODING); |
lex9296 | 32:1be3d79ff4db | 79 | //DigitalIn Hall_A (PA_1); |
lex9296 | 32:1be3d79ff4db | 80 | //DigitalIn Hall_B (PA_0); |
lex9296 | 28:443c82750dd9 | 81 | |
lex9296 | 23:b9d23a2f390e | 82 | // Motion |
lex9296 | 23:b9d23a2f390e | 83 | // ====== |
lex9296 | 23:b9d23a2f390e | 84 | // |
lex9296 | 28:443c82750dd9 | 85 | //Ticker POS_MotionScan; // LA: Non uso un Ticker. Agisce sotto Interrupt e falsa la lettura QEI e la sincronicità del PWM |
lex9296 | 23:b9d23a2f390e | 86 | // |
lex9296 | 23:b9d23a2f390e | 87 | in_sPosizionatoreSW in_PosizionatoreSW; |
lex9296 | 23:b9d23a2f390e | 88 | out_sPosizionatoreSW out_PosizionatoreSW; |
GregCr | 0:9c0917bfde97 | 89 | |
lex9296 | 23:b9d23a2f390e | 90 | // LCD Display |
lex9296 | 23:b9d23a2f390e | 91 | // =========== |
lex9296 | 23:b9d23a2f390e | 92 | // |
lex9296 | 28:443c82750dd9 | 93 | //Ticker LCD_RefreshViews; // LA: Non uso un Ticker. Agisce sotto Interrupt e falsa la lettura QEI e la sincronicità del PWM |
mverdy | 15:ed7ed20b7114 | 94 | |
lex9296 | 22:12c555cade79 | 95 | void FactoryReset (void) { |
mverdy | 15:ed7ed20b7114 | 96 | EepromFactoryReset( ); |
mverdy | 15:ed7ed20b7114 | 97 | HAL_NVIC_SystemReset( ); |
mverdy | 15:ed7ed20b7114 | 98 | } |
lex9296 | 23:b9d23a2f390e | 99 | |
lex9296 | 23:b9d23a2f390e | 100 | // ======= |
lex9296 | 23:b9d23a2f390e | 101 | // ======= |
lex9296 | 23:b9d23a2f390e | 102 | // Main(s) |
lex9296 | 23:b9d23a2f390e | 103 | // ======= |
lex9296 | 23:b9d23a2f390e | 104 | // ======= |
lex9296 | 23:b9d23a2f390e | 105 | // |
lex9296 | 23:b9d23a2f390e | 106 | int main (void){ |
lex9296 | 32:1be3d79ff4db | 107 | const float cf_PWMPeriod_s = 0.010; |
lex9296 | 28:443c82750dd9 | 108 | |
lex9296 | 32:1be3d79ff4db | 109 | rDIR_FWD = true; // LA: Actuator Extends |
lex9296 | 32:1be3d79ff4db | 110 | rENA_Off = true; // LA: Drive Power is Off |
lex9296 | 28:443c82750dd9 | 111 | |
lex9296 | 23:b9d23a2f390e | 112 | EepromInit(); // LA: Inizializza la EEProm |
lex9296 | 23:b9d23a2f390e | 113 | TimersInit(); // LA: Parte il Timer a 1ms |
lex9296 | 23:b9d23a2f390e | 114 | |
lex9296 | 32:1be3d79ff4db | 115 | SampleTimer.attach_us(&SampleAndStore, 250); |
lex9296 | 29:7ce8c5779f5e | 116 | |
lex9296 | 23:b9d23a2f390e | 117 | // LA: FactoryReset se "userButton" premuto all'avvio |
lex9296 | 23:b9d23a2f390e | 118 | // |
lex9296 | 23:b9d23a2f390e | 119 | if (userButton == 0) { |
lex9296 | 23:b9d23a2f390e | 120 | FactoryReset(); |
lex9296 | 23:b9d23a2f390e | 121 | } |
lex9296 | 28:443c82750dd9 | 122 | DisplayDriverInit(); |
lex9296 | 23:b9d23a2f390e | 123 | |
lex9296 | 32:1be3d79ff4db | 124 | PWM_PB3.period(cf_PWMPeriod_s); // LA: Avvia il PWM con TimeBase x [s] |
lex9296 | 32:1be3d79ff4db | 125 | PWM_PB3.write((float) 0.0); // Set to 0% |
lex9296 | 23:b9d23a2f390e | 126 | |
lex9296 | 23:b9d23a2f390e | 127 | // LA: Motion (1st) Setup |
lex9296 | 23:b9d23a2f390e | 128 | // |
lex9296 | 28:443c82750dd9 | 129 | in_PosizionatoreSW.b_AxisPowered = true; |
lex9296 | 28:443c82750dd9 | 130 | in_PosizionatoreSW.b_ACPos_Homed = true; |
lex9296 | 23:b9d23a2f390e | 131 | in_PosizionatoreSW.i32_Max_Speed = 1024; // [ui] |
lex9296 | 23:b9d23a2f390e | 132 | in_PosizionatoreSW.i32_ZeroSpeed = 0; // |
lex9296 | 23:b9d23a2f390e | 133 | |
lex9296 | 32:1be3d79ff4db | 134 | // POS Mode |
lex9296 | 32:1be3d79ff4db | 135 | // ======== |
lex9296 | 32:1be3d79ff4db | 136 | // |
lex9296 | 32:1be3d79ff4db | 137 | in_PosizionatoreSW.b_ServoLock = true; |
lex9296 | 32:1be3d79ff4db | 138 | in_PosizionatoreSW.rtServoLock_Q = false; |
lex9296 | 32:1be3d79ff4db | 139 | // |
lex9296 | 32:1be3d79ff4db | 140 | in_PosizionatoreSW.i64_TargetPosition = 3200; // [ui] |
lex9296 | 32:1be3d79ff4db | 141 | in_PosizionatoreSW.i64_ActualPosition = Stabilus322699.getPulses(); // |
lex9296 | 32:1be3d79ff4db | 142 | in_PosizionatoreSW.i64_AccelerationWindow = 64; // LA: Spazio concesso all'accelerazione. |
lex9296 | 32:1be3d79ff4db | 143 | in_PosizionatoreSW.i64_DecelerationWindow = 512; // Spazio concesso alla decelerazione, è prioritario rispetto all'accelerazione. |
lex9296 | 32:1be3d79ff4db | 144 | in_PosizionatoreSW.i64_diToleranceWindow = 10; // Finestra di Tolleranza |
lex9296 | 32:1be3d79ff4db | 145 | // |
lex9296 | 32:1be3d79ff4db | 146 | in_PosizionatoreSW.f_MaximumSpeed_x100_FW = 16.0; // % of "i32_Max_Speed" |
lex9296 | 32:1be3d79ff4db | 147 | in_PosizionatoreSW.f_MaximumSpeed_x100_BW = 60.0; // |
lex9296 | 32:1be3d79ff4db | 148 | in_PosizionatoreSW.f_ServoLockSpeed_x100_FW = 4.8; // Riferimento di velocità minima a cui (appena) si muove l'asse [verso FW] |
lex9296 | 32:1be3d79ff4db | 149 | in_PosizionatoreSW.f_ServoLockSpeed_x100_BW = 18.0; // Riferimento di velocità minima a cui (appena) si muove l'asse [verso BW] |
lex9296 | 32:1be3d79ff4db | 150 | |
lex9296 | 32:1be3d79ff4db | 151 | // JOG Mode |
lex9296 | 32:1be3d79ff4db | 152 | // ======== |
lex9296 | 32:1be3d79ff4db | 153 | // |
lex9296 | 23:b9d23a2f390e | 154 | in_PosizionatoreSW.b_JogMode = false; |
lex9296 | 23:b9d23a2f390e | 155 | in_PosizionatoreSW.b_JogFW = false; |
lex9296 | 23:b9d23a2f390e | 156 | in_PosizionatoreSW.b_JogBW = false; |
lex9296 | 23:b9d23a2f390e | 157 | in_PosizionatoreSW.i32_JogAccel_ms = 500; // [ms] |
lex9296 | 23:b9d23a2f390e | 158 | in_PosizionatoreSW.i32_JogDecel_ms = 250; // |
lex9296 | 23:b9d23a2f390e | 159 | // |
lex9296 | 32:1be3d79ff4db | 160 | in_PosizionatoreSW.f_JogSpeed_x100_FW = (in_PosizionatoreSW.f_MaximumSpeed_x100_FW/ 2); // LA: JOG's the Half of Max POS's Speed |
lex9296 | 32:1be3d79ff4db | 161 | in_PosizionatoreSW.f_JogSpeed_x100_BW = (in_PosizionatoreSW.f_MaximumSpeed_x100_BW/ 2); // |
lex9296 | 23:b9d23a2f390e | 162 | |
lex9296 | 23:b9d23a2f390e | 163 | |
lex9296 | 28:443c82750dd9 | 164 | // LA: Color RGB Component(s) |
lex9296 | 28:443c82750dd9 | 165 | // ====================== |
lex9296 | 28:443c82750dd9 | 166 | // |
lex9296 | 28:443c82750dd9 | 167 | // RED 0000 1000 0000 0000 min 0x0800 02048 |
lex9296 | 28:443c82750dd9 | 168 | // 1111 1000 0000 0000 max 0xf800 63488 |
lex9296 | 28:443c82750dd9 | 169 | // |
lex9296 | 28:443c82750dd9 | 170 | // GREEN 0000 0000 0010 0000 min 0x0020 00032 |
lex9296 | 28:443c82750dd9 | 171 | // 0000 0111 1110 0000 max 0x07e0 02016 |
lex9296 | 28:443c82750dd9 | 172 | // |
lex9296 | 28:443c82750dd9 | 173 | // BLUE 0000 0000 0000 0001 min 0x0001 00001 |
lex9296 | 28:443c82750dd9 | 174 | // 0000 0000 0001 1111 max 0x001f 00031 |
lex9296 | 28:443c82750dd9 | 175 | // |
lex9296 | 28:443c82750dd9 | 176 | // La componente ROSSA ha 5 bit di escursione (0.. 31), |
lex9296 | 28:443c82750dd9 | 177 | // La componente VERDE ha 6 bit di escursione (0.. 63), |
lex9296 | 28:443c82750dd9 | 178 | // La componente BLU ha 5 bit di escursione (0.. 31), |
lex9296 | 28:443c82750dd9 | 179 | // |
lex9296 | 28:443c82750dd9 | 180 | // Le componenti RGB di "Color" sono quindi scritte negli appropriati registri come segue: |
lex9296 | 28:443c82750dd9 | 181 | // |
lex9296 | 28:443c82750dd9 | 182 | // writeReg(RED, (Color & 0xf800) >> 11); |
lex9296 | 28:443c82750dd9 | 183 | // writeReg(GREEN, (Color & 0x07e0) >> 5); |
lex9296 | 28:443c82750dd9 | 184 | // writeReg(BLUE, (Color & 0x001f)); |
lex9296 | 28:443c82750dd9 | 185 | // |
lex9296 | 32:1be3d79ff4db | 186 | LCM_SetTextColor(Scale2RGBColor (0, 0, 0), Scale2RGBColor (31, 0, 0)); // LA: Red on Black |
lex9296 | 32:1be3d79ff4db | 187 | LCM_ClearScreen (Scale2RGBColor (0, 0, 0)); // Black Background |
lex9296 | 32:1be3d79ff4db | 188 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 0), "You Start Me Up ..."); // Intro Text |
lex9296 | 23:b9d23a2f390e | 189 | |
lex9296 | 32:1be3d79ff4db | 190 | // rDIR_FWD = false; // Collapse |
lex9296 | 32:1be3d79ff4db | 191 | // rENA_Off = false; // Power On |
lex9296 | 32:1be3d79ff4db | 192 | |
lex9296 | 32:1be3d79ff4db | 193 | in_PosizionatoreSW.b_ServoLock = true; |
lex9296 | 32:1be3d79ff4db | 194 | in_PosizionatoreSW.rtServoLock_Q = true; |
lex9296 | 28:443c82750dd9 | 195 | |
lex9296 | 28:443c82750dd9 | 196 | while (1) { |
lex9296 | 32:1be3d79ff4db | 197 | float f_PWMPercent; |
lex9296 | 28:443c82750dd9 | 198 | |
lex9296 | 32:1be3d79ff4db | 199 | in_PosizionatoreSW.i64_ActualPosition = Stabilus322699.getPulses(); |
lex9296 | 32:1be3d79ff4db | 200 | // |
lex9296 | 32:1be3d79ff4db | 201 | PosizionatoreSW (in_PosizionatoreSW, out_PosizionatoreSW); |
lex9296 | 32:1be3d79ff4db | 202 | in_PosizionatoreSW.rtServoLock_Q = false; |
lex9296 | 32:1be3d79ff4db | 203 | |
lex9296 | 32:1be3d79ff4db | 204 | // int64_t i64_StartPosition; |
lex9296 | 32:1be3d79ff4db | 205 | // int64_t i64_Distance; |
lex9296 | 32:1be3d79ff4db | 206 | // bool b_Accelerating; // LA: bACPos_Accelerating |
lex9296 | 32:1be3d79ff4db | 207 | // bool b_MaxSpeedReached; |
lex9296 | 32:1be3d79ff4db | 208 | // bool b_Decelerating; // bACPos_Decelerating |
lex9296 | 32:1be3d79ff4db | 209 | // bool b_InPosition; |
lex9296 | 32:1be3d79ff4db | 210 | // bool b_InToleranceFW; |
lex9296 | 32:1be3d79ff4db | 211 | // bool b_InToleranceBW; |
lex9296 | 32:1be3d79ff4db | 212 | |
lex9296 | 32:1be3d79ff4db | 213 | // int32_t i32_ATVSpeed; |
lex9296 | 32:1be3d79ff4db | 214 | f_PWMPercent = ((float)out_PosizionatoreSW.i32_ATVSpeed)/ (float)in_PosizionatoreSW.i32_Max_Speed; // LA: In Range (float) 0.. 1 |
lex9296 | 32:1be3d79ff4db | 215 | PWM_PB3.write((float) 1.0- f_PWMPercent); // Set to x% |
lex9296 | 27:654100855f5c | 216 | |
lex9296 | 32:1be3d79ff4db | 217 | // bool b_ATVDirectionFW; |
lex9296 | 32:1be3d79ff4db | 218 | rDIR_FWD = out_PosizionatoreSW.b_ATVDirectionFW; |
lex9296 | 32:1be3d79ff4db | 219 | |
lex9296 | 32:1be3d79ff4db | 220 | // bool b_ATVDirectionBW; |
lex9296 | 32:1be3d79ff4db | 221 | |
lex9296 | 32:1be3d79ff4db | 222 | // bool b_STW1_On; |
lex9296 | 32:1be3d79ff4db | 223 | // bool b_STW1_NoCStop; |
lex9296 | 32:1be3d79ff4db | 224 | // bool b_STW1_NoQStop; |
lex9296 | 32:1be3d79ff4db | 225 | // bool b_STW1_Enable; |
lex9296 | 32:1be3d79ff4db | 226 | rENA_Off = !out_PosizionatoreSW.b_STW1_Enable; |
lex9296 | 29:7ce8c5779f5e | 227 | |
lex9296 | 29:7ce8c5779f5e | 228 | // LA: Scope, Theory of operation. |
lex9296 | 29:7ce8c5779f5e | 229 | // =========================== |
lex9296 | 29:7ce8c5779f5e | 230 | // |
lex9296 | 29:7ce8c5779f5e | 231 | // 1) Sample a Value @ any Step |
lex9296 | 29:7ce8c5779f5e | 232 | // 2) Store @ the correct ms |
lex9296 | 29:7ce8c5779f5e | 233 | // 3) Plot the current Section of the Sampling Vector |
lex9296 | 29:7ce8c5779f5e | 234 | // |
lex9296 | 32:1be3d79ff4db | 235 | LCM_ShowTactics ( |
lex9296 | 32:1be3d79ff4db | 236 | Stabilus322699.getPulses(), // Row 1 |
lex9296 | 29:7ce8c5779f5e | 237 | |
lex9296 | 32:1be3d79ff4db | 238 | out_PosizionatoreSW.i32_ATVSpeed, // 3 |
lex9296 | 32:1be3d79ff4db | 239 | adc_temp.read(), // 4 |
lex9296 | 32:1be3d79ff4db | 240 | adc_vbat.read(), // 5 |
lex9296 | 32:1be3d79ff4db | 241 | adc_vref.read(), // 6 |
lex9296 | 32:1be3d79ff4db | 242 | |
lex9296 | 32:1be3d79ff4db | 243 | ADC12_IN9.read(), // 8 |
lex9296 | 32:1be3d79ff4db | 244 | ADC12_IN15.read(), // 9 |
lex9296 | 32:1be3d79ff4db | 245 | (f_PWMPercent* 100) // 10 |
lex9296 | 32:1be3d79ff4db | 246 | ); |
lex9296 | 32:1be3d79ff4db | 247 | |
lex9296 | 32:1be3d79ff4db | 248 | LCM_PlotVector ( |
lex9296 | 32:1be3d79ff4db | 249 | Scale2RGBColor (0, 0, 0), // Back: Black |
lex9296 | 32:1be3d79ff4db | 250 | Scale2RGBColor (31, 0, 0) // Fore: Red |
lex9296 | 32:1be3d79ff4db | 251 | ); |
lex9296 | 32:1be3d79ff4db | 252 | |
lex9296 | 32:1be3d79ff4db | 253 | |
lex9296 | 32:1be3d79ff4db | 254 | if (out_PosizionatoreSW.b_InPosition) |
lex9296 | 32:1be3d79ff4db | 255 | if (in_PosizionatoreSW.i64_TargetPosition > 0) |
lex9296 | 32:1be3d79ff4db | 256 | in_PosizionatoreSW.i64_TargetPosition = 0; |
lex9296 | 32:1be3d79ff4db | 257 | else |
lex9296 | 32:1be3d79ff4db | 258 | in_PosizionatoreSW.i64_TargetPosition = 3200; |
lex9296 | 28:443c82750dd9 | 259 | } |
lex9296 | 28:443c82750dd9 | 260 | } |
lex9296 | 28:443c82750dd9 | 261 | |
lex9296 | 32:1be3d79ff4db | 262 | void LCM_ShowTactics( |
lex9296 | 32:1be3d79ff4db | 263 | int32_t i32_Pulses, |
lex9296 | 32:1be3d79ff4db | 264 | int32_t i32_ATVSpeed, |
lex9296 | 32:1be3d79ff4db | 265 | float f_ai0000_Aux, |
lex9296 | 32:1be3d79ff4db | 266 | float f_ai0001_Aux, |
lex9296 | 32:1be3d79ff4db | 267 | float f_ai0002_Aux, |
lex9296 | 32:1be3d79ff4db | 268 | float f_ai0003_Aux, |
lex9296 | 32:1be3d79ff4db | 269 | float f_ai0004_Aux, |
lex9296 | 32:1be3d79ff4db | 270 | float f_ai0005_Aux |
lex9296 | 32:1be3d79ff4db | 271 | ) { |
lex9296 | 32:1be3d79ff4db | 272 | |
lex9296 | 32:1be3d79ff4db | 273 | char StringText[MAX_CHAR_PER_LINE+ 1]; // don't forget the /0 (end of string) |
lex9296 | 32:1be3d79ff4db | 274 | |
lex9296 | 32:1be3d79ff4db | 275 | static int32_t Pulses_Prec; |
lex9296 | 32:1be3d79ff4db | 276 | static uint32_t ms_0002_prec; |
lex9296 | 32:1be3d79ff4db | 277 | |
lex9296 | 32:1be3d79ff4db | 278 | static float f_ai0000_prec; |
lex9296 | 32:1be3d79ff4db | 279 | static float f_ai0001_prec; |
lex9296 | 32:1be3d79ff4db | 280 | static float f_ai0002_prec; |
lex9296 | 32:1be3d79ff4db | 281 | static float f_ai0003_prec; |
lex9296 | 32:1be3d79ff4db | 282 | static float f_ai0004_prec; |
lex9296 | 32:1be3d79ff4db | 283 | static float f_ai0005_prec; |
lex9296 | 32:1be3d79ff4db | 284 | |
lex9296 | 32:1be3d79ff4db | 285 | if (i32_Pulses != Pulses_Prec) { |
lex9296 | 32:1be3d79ff4db | 286 | sprintf (StringText, |
lex9296 | 32:1be3d79ff4db | 287 | "Pulses: %d ", i32_Pulses); |
lex9296 | 32:1be3d79ff4db | 288 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 1), StringText); |
lex9296 | 32:1be3d79ff4db | 289 | Pulses_Prec = i32_Pulses; |
lex9296 | 32:1be3d79ff4db | 290 | } |
lex9296 | 32:1be3d79ff4db | 291 | |
lex9296 | 32:1be3d79ff4db | 292 | if (i32_ATVSpeed != ms_0002_prec) { |
lex9296 | 32:1be3d79ff4db | 293 | sprintf (StringText, |
lex9296 | 32:1be3d79ff4db | 294 | "Speed[ui]: %d ", i32_ATVSpeed); |
lex9296 | 32:1be3d79ff4db | 295 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 3), StringText); |
lex9296 | 32:1be3d79ff4db | 296 | ms_0002_prec = i32_ATVSpeed; |
lex9296 | 32:1be3d79ff4db | 297 | } |
lex9296 | 32:1be3d79ff4db | 298 | |
lex9296 | 32:1be3d79ff4db | 299 | if (f_ai0000_Aux != f_ai0000_prec) { |
lex9296 | 32:1be3d79ff4db | 300 | sprintf (StringText, |
lex9296 | 32:1be3d79ff4db | 301 | "ADC Temp = %f ", (f_ai0000_Aux* 100)); |
lex9296 | 32:1be3d79ff4db | 302 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 4), StringText); |
lex9296 | 32:1be3d79ff4db | 303 | f_ai0000_prec = f_ai0000_Aux; |
lex9296 | 32:1be3d79ff4db | 304 | } |
lex9296 | 32:1be3d79ff4db | 305 | |
lex9296 | 32:1be3d79ff4db | 306 | if (f_ai0001_Aux != f_ai0001_prec) { |
lex9296 | 32:1be3d79ff4db | 307 | sprintf (StringText, |
lex9296 | 32:1be3d79ff4db | 308 | "ADC VBat = %f ", (f_ai0001_Aux* 10)); |
lex9296 | 32:1be3d79ff4db | 309 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 5), StringText); |
lex9296 | 32:1be3d79ff4db | 310 | f_ai0001_prec = f_ai0001_Aux; |
lex9296 | 32:1be3d79ff4db | 311 | } |
lex9296 | 32:1be3d79ff4db | 312 | |
lex9296 | 32:1be3d79ff4db | 313 | if (f_ai0002_Aux != f_ai0002_prec) { |
lex9296 | 32:1be3d79ff4db | 314 | sprintf (StringText, |
lex9296 | 32:1be3d79ff4db | 315 | "ADC VRef = %f ", (f_ai0002_Aux* 10)); |
lex9296 | 32:1be3d79ff4db | 316 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 6), StringText); |
lex9296 | 32:1be3d79ff4db | 317 | f_ai0002_prec = f_ai0002_Aux; |
lex9296 | 32:1be3d79ff4db | 318 | } |
lex9296 | 32:1be3d79ff4db | 319 | |
lex9296 | 32:1be3d79ff4db | 320 | if (f_ai0003_Aux != f_ai0003_prec) { |
lex9296 | 32:1be3d79ff4db | 321 | sprintf (StringText, |
lex9296 | 32:1be3d79ff4db | 322 | "ADC12.09 = %f ", (f_ai0003_Aux* 10)/ 3); |
lex9296 | 32:1be3d79ff4db | 323 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 8), StringText); |
lex9296 | 32:1be3d79ff4db | 324 | f_ai0003_prec = f_ai0003_Aux; |
lex9296 | 32:1be3d79ff4db | 325 | } |
lex9296 | 32:1be3d79ff4db | 326 | |
lex9296 | 32:1be3d79ff4db | 327 | if (f_ai0004_Aux != f_ai0004_prec) { |
lex9296 | 32:1be3d79ff4db | 328 | sprintf (StringText, |
lex9296 | 32:1be3d79ff4db | 329 | "ADC12.15 = %f ", (f_ai0004_Aux* 10)/ 3); |
lex9296 | 32:1be3d79ff4db | 330 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 9), StringText); |
lex9296 | 32:1be3d79ff4db | 331 | f_ai0004_prec = f_ai0004_Aux; |
lex9296 | 32:1be3d79ff4db | 332 | } |
lex9296 | 32:1be3d79ff4db | 333 | |
lex9296 | 32:1be3d79ff4db | 334 | if (f_ai0005_Aux != f_ai0005_prec) { |
lex9296 | 32:1be3d79ff4db | 335 | sprintf (StringText, |
lex9296 | 32:1be3d79ff4db | 336 | "PB3 PWM%% = %f ", (f_ai0005_Aux)); |
lex9296 | 32:1be3d79ff4db | 337 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 10), StringText); |
lex9296 | 32:1be3d79ff4db | 338 | f_ai0005_prec = f_ai0005_Aux; |
lex9296 | 32:1be3d79ff4db | 339 | } |
lex9296 | 32:1be3d79ff4db | 340 | } |
lex9296 | 32:1be3d79ff4db | 341 | |
lex9296 | 32:1be3d79ff4db | 342 | //static void SampleAndStore (void) { |
lex9296 | 32:1be3d79ff4db | 343 | void SampleAndStore (void) { |
lex9296 | 32:1be3d79ff4db | 344 | //static int32_t i32_Pulses; |
lex9296 | 29:7ce8c5779f5e | 345 | int16_t i16_SampleIndex; |
lex9296 | 29:7ce8c5779f5e | 346 | //float f_SampleAux; |
lex9296 | 29:7ce8c5779f5e | 347 | |
lex9296 | 32:1be3d79ff4db | 348 | // af_PlotSamples[240- 1] = ADC12_IN9.read(); |
lex9296 | 32:1be3d79ff4db | 349 | af_PlotSamples[240- 1] = (float) Stabilus322699.getChannelA() * 0.33f; |
lex9296 | 32:1be3d79ff4db | 350 | |
lex9296 | 32:1be3d79ff4db | 351 | for (i16_SampleIndex = 0; i16_SampleIndex < (240- 1); i16_SampleIndex++) |
lex9296 | 29:7ce8c5779f5e | 352 | af_PlotSamples[i16_SampleIndex] = af_PlotSamples[i16_SampleIndex+ 1]; |
lex9296 | 29:7ce8c5779f5e | 353 | |
lex9296 | 32:1be3d79ff4db | 354 | // i32_Pulses++; |
lex9296 | 29:7ce8c5779f5e | 355 | } |
lex9296 | 29:7ce8c5779f5e | 356 | |
lex9296 | 31:913f664c6189 | 357 | // getDmTft().setPixel (0,0,1); |