Stabilus 322699 wDoublePID, ErrorGetter

Dependencies:   mbed QEI PID DmTftLibraryEx

Committer:
lex9296
Date:
Fri Mar 11 10:10:21 2022 +0000
Revision:
30:e45282a70a4d
Parent:
29:7ce8c5779f5e
Child:
31:913f664c6189
March 11, 2022. Scope is Working.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lex9296 28:443c82750dd9 1
GregCr 0:9c0917bfde97 2
lex9296 23:b9d23a2f390e 3 //Warning: Incompatible redefinition of macro "MBED_RAM_SIZE" in "tmp/HU5Hqj", Line: 39, Col: 10
lex9296 23:b9d23a2f390e 4 #ifndef MBED_RAM_SIZE
lex9296 23:b9d23a2f390e 5 #define MBED_RAM_SIZE 0x00018000
lex9296 23:b9d23a2f390e 6 #endif
lex9296 23:b9d23a2f390e 7
lex9296 23:b9d23a2f390e 8 #include "QEI.h"
lex9296 23:b9d23a2f390e 9 #include "SWPos.h"
lex9296 23:b9d23a2f390e 10
lex9296 30:e45282a70a4d 11 #include "DmTftIli9341.h"
lex9296 30:e45282a70a4d 12
GregCr 0:9c0917bfde97 13 #include "Timers.h"
lex9296 23:b9d23a2f390e 14 //#include "Menu.h"
GregCr 0:9c0917bfde97 15 #include "Eeprom.h"
lex9296 23:b9d23a2f390e 16 //#include "main.h"
lex9296 23:b9d23a2f390e 17 //#include "app_config.h"
GregCr 0:9c0917bfde97 18
lex9296 27:654100855f5c 19 #define MAX_CHAR_PER_LINE 28
lex9296 27:654100855f5c 20 #define TEXT_ROW_SPACING 16
lex9296 27:654100855f5c 21 #define FONT_CHAR_WIDTH 8
lex9296 27:654100855f5c 22 #define FONT_CHAR_HEIGHT 16
lex9296 27:654100855f5c 23
lex9296 27:654100855f5c 24 //#include "mbed.h"
lex9296 27:654100855f5c 25 #include "DisplayDriver.h"
lex9296 27:654100855f5c 26 //#include "DmTftIli9341.h"
lex9296 27:654100855f5c 27 //#include "DmTouch.h"
lex9296 27:654100855f5c 28 //#include "DmTouchCalibration.h"
lex9296 27:654100855f5c 29
lex9296 29:7ce8c5779f5e 30 int32_t i32_Pulses;
lex9296 29:7ce8c5779f5e 31 //
lex9296 29:7ce8c5779f5e 32 static void SampleAndStore (void);
lex9296 29:7ce8c5779f5e 33 Ticker SampleTimer; // LA: To Sample 1AI any ms
lex9296 29:7ce8c5779f5e 34 float af_PlotSamples[240]; // LA: "Horiz" Plot Array
lex9296 29:7ce8c5779f5e 35
lex9296 30:e45282a70a4d 36 uint16_t aui16_PlotSamples[240];
lex9296 30:e45282a70a4d 37 uint16_t aui16_PlotClears_Lo[240];
lex9296 30:e45282a70a4d 38 uint16_t aui16_PlotClears_Hi[240];
lex9296 30:e45282a70a4d 39
lex9296 26:bfca0c471a87 40 // LA: Theory of Operation
lex9296 26:bfca0c471a87 41 // ===================
lex9296 26:bfca0c471a87 42 //
lex9296 26:bfca0c471a87 43 // Il PWM funziona da sè in Interrupt
lex9296 26:bfca0c471a87 44 // Il QEI funziona da sè in Interrupt
lex9296 26:bfca0c471a87 45 // 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 46 //
lex9296 26:bfca0c471a87 47 // PQM
lex9296 26:bfca0c471a87 48 //
lex9296 26:bfca0c471a87 49 // Il rinfresco del Display e la gestione del motion vanno fatte il più frequentemente possibile ma fuori dal loop dei Ticker.
lex9296 26:bfca0c471a87 50 // Con qst versione (LA0005, che termina un FORK (il successivo è LA0010) quanto detto sopra è FUNZIONANTE.
lex9296 26:bfca0c471a87 51 // Questo messaggio è incluso nel "commitment"
lex9296 26:bfca0c471a87 52
GregCr 0:9c0917bfde97 53 /*!
GregCr 0:9c0917bfde97 54 * \brief Define IO for Unused Pin
GregCr 0:9c0917bfde97 55 */
lex9296 23:b9d23a2f390e 56 //DigitalOut F_CS (D6); // MBED description of pin
lex9296 23:b9d23a2f390e 57 //DigitalOut SD_CS (D8); // MBED description of pin
lex9296 23:b9d23a2f390e 58
lex9296 23:b9d23a2f390e 59 DigitalIn userButton (USER_BUTTON);
mverdy 15:ed7ed20b7114 60
lex9296 23:b9d23a2f390e 61 AnalogIn adc_temp (ADC_TEMP);
lex9296 23:b9d23a2f390e 62 AnalogIn adc_vref (ADC_VREF);
lex9296 23:b9d23a2f390e 63 AnalogIn adc_vbat (ADC_VBAT);
GregCr 0:9c0917bfde97 64
lex9296 29:7ce8c5779f5e 65 AnalogIn ADC12_IN9 (PA_4); // STM32 PA4
lex9296 29:7ce8c5779f5e 66 AnalogIn ADC12_IN15 (PB_0); // STM32 PB0
lex9296 29:7ce8c5779f5e 67
lex9296 23:b9d23a2f390e 68 // PWM
lex9296 23:b9d23a2f390e 69 // ===
lex9296 23:b9d23a2f390e 70 //
lex9296 25:5fd2d69e2927 71 PwmOut PWM_PB3(PWM_OUT); // LA: PWM_OUT = D3 = PB_3
mverdy 14:ebd89dacc807 72
lex9296 28:443c82750dd9 73 // QEI
lex9296 28:443c82750dd9 74 // ===
lex9296 28:443c82750dd9 75 //
lex9296 28:443c82750dd9 76 QEI Stabilus322699 (PA_1, PA_0, NC, 100, QEI::X4_ENCODING);
lex9296 28:443c82750dd9 77
lex9296 23:b9d23a2f390e 78 // Motion
lex9296 23:b9d23a2f390e 79 // ======
lex9296 23:b9d23a2f390e 80 //
lex9296 28:443c82750dd9 81 //Ticker POS_MotionScan; // LA: Non uso un Ticker. Agisce sotto Interrupt e falsa la lettura QEI e la sincronicità del PWM
lex9296 23:b9d23a2f390e 82 //
lex9296 23:b9d23a2f390e 83 in_sPosizionatoreSW in_PosizionatoreSW;
lex9296 23:b9d23a2f390e 84 out_sPosizionatoreSW out_PosizionatoreSW;
GregCr 0:9c0917bfde97 85
lex9296 23:b9d23a2f390e 86 // LCD Display
lex9296 23:b9d23a2f390e 87 // ===========
lex9296 23:b9d23a2f390e 88 //
lex9296 28:443c82750dd9 89 //Ticker LCD_RefreshViews; // LA: Non uso un Ticker. Agisce sotto Interrupt e falsa la lettura QEI e la sincronicità del PWM
mverdy 15:ed7ed20b7114 90
lex9296 22:12c555cade79 91 void FactoryReset (void) {
mverdy 15:ed7ed20b7114 92 EepromFactoryReset( );
mverdy 15:ed7ed20b7114 93 HAL_NVIC_SystemReset( );
mverdy 15:ed7ed20b7114 94 }
lex9296 23:b9d23a2f390e 95
lex9296 23:b9d23a2f390e 96 // =======
lex9296 23:b9d23a2f390e 97 // =======
lex9296 23:b9d23a2f390e 98 // Main(s)
lex9296 23:b9d23a2f390e 99 // =======
lex9296 23:b9d23a2f390e 100 // =======
lex9296 23:b9d23a2f390e 101 //
lex9296 23:b9d23a2f390e 102 int main (void){
lex9296 28:443c82750dd9 103 char StringText[MAX_CHAR_PER_LINE + 1]; // don't forget the /0 (end of string)
lex9296 28:443c82750dd9 104 //char StringText2[MAX_CHAR_PER_LINE + 1];
lex9296 28:443c82750dd9 105 //char StringText3[MAX_CHAR_PER_LINE + 1];
lex9296 28:443c82750dd9 106
lex9296 28:443c82750dd9 107 //uint16_t ui16_TestColor = 0x0000;
lex9296 28:443c82750dd9 108 //uint16_t ui16_TestStep = 0x0000;
lex9296 28:443c82750dd9 109 //
lex9296 28:443c82750dd9 110 //uint16_t ui16_R = 0x00;
lex9296 28:443c82750dd9 111 //uint16_t ui16_G = 0x00;
lex9296 28:443c82750dd9 112 //uint16_t ui16_B = 0x00;
lex9296 28:443c82750dd9 113
lex9296 28:443c82750dd9 114 uint32_t ui32_PreCallms;
lex9296 28:443c82750dd9 115 uint32_t ui32_PostCallms;
lex9296 28:443c82750dd9 116 uint32_t ui32_Samplems;
lex9296 28:443c82750dd9 117
lex9296 23:b9d23a2f390e 118 EepromInit(); // LA: Inizializza la EEProm
lex9296 23:b9d23a2f390e 119 TimersInit(); // LA: Parte il Timer a 1ms
lex9296 23:b9d23a2f390e 120
lex9296 29:7ce8c5779f5e 121 SampleTimer.attach_us( &SampleAndStore, 1000 );
lex9296 29:7ce8c5779f5e 122
lex9296 23:b9d23a2f390e 123 // LA: FactoryReset se "userButton" premuto all'avvio
lex9296 23:b9d23a2f390e 124 //
lex9296 23:b9d23a2f390e 125 if (userButton == 0) {
lex9296 23:b9d23a2f390e 126 FactoryReset();
lex9296 23:b9d23a2f390e 127 }
lex9296 28:443c82750dd9 128 DisplayDriverInit();
lex9296 23:b9d23a2f390e 129
lex9296 28:443c82750dd9 130 PWM_PB3.period_us(100); // LA: Avvia il PWM con TimeBase 100us
lex9296 28:443c82750dd9 131 PWM_PB3.pulsewidth_us(0); // 0.. 100us -> 0.. 100%, Set to ZERO
lex9296 23:b9d23a2f390e 132
lex9296 23:b9d23a2f390e 133 // LA: Motion (1st) Setup
lex9296 23:b9d23a2f390e 134 //
lex9296 28:443c82750dd9 135 in_PosizionatoreSW.b_AxisPowered = true;
lex9296 28:443c82750dd9 136 in_PosizionatoreSW.b_ACPos_Homed = true;
lex9296 23:b9d23a2f390e 137 in_PosizionatoreSW.i32_Max_Speed = 1024; // [ui]
lex9296 23:b9d23a2f390e 138 in_PosizionatoreSW.i32_ZeroSpeed = 0; //
lex9296 23:b9d23a2f390e 139
lex9296 23:b9d23a2f390e 140 in_PosizionatoreSW.b_JogMode = false;
lex9296 23:b9d23a2f390e 141 in_PosizionatoreSW.b_JogFW = false;
lex9296 23:b9d23a2f390e 142 in_PosizionatoreSW.b_JogBW = false;
lex9296 23:b9d23a2f390e 143 in_PosizionatoreSW.i32_JogAccel_ms = 500; // [ms]
lex9296 23:b9d23a2f390e 144 in_PosizionatoreSW.i32_JogDecel_ms = 250; //
lex9296 23:b9d23a2f390e 145 //
lex9296 23:b9d23a2f390e 146 in_PosizionatoreSW.f_JogSpeed_x100_FW = 25.0; // % of "i32_Max_Speed"
lex9296 23:b9d23a2f390e 147 in_PosizionatoreSW.f_JogSpeed_x100_BW = 25.0; //
lex9296 23:b9d23a2f390e 148
lex9296 28:443c82750dd9 149 in_PosizionatoreSW.b_ServoLock = true;
lex9296 23:b9d23a2f390e 150 in_PosizionatoreSW.rtServoLock_Q = false;
lex9296 23:b9d23a2f390e 151 //
lex9296 28:443c82750dd9 152 in_PosizionatoreSW.i64_TargetPosition = 1000; // [ui]
lex9296 28:443c82750dd9 153 in_PosizionatoreSW.i64_ActualPosition = 200; //
lex9296 28:443c82750dd9 154 in_PosizionatoreSW.i64_AccelerationWindow = 50; // LA: Spazio concesso all'accelerazione.
lex9296 28:443c82750dd9 155 in_PosizionatoreSW.i64_DecelerationWindow = 50; // Spazio concesso alla decelerazione, è prioritario rispetto all'accelerazione.
lex9296 28:443c82750dd9 156 in_PosizionatoreSW.i64_diToleranceWindow = 10; // Finestra di Tolleranza
lex9296 23:b9d23a2f390e 157 //
lex9296 23:b9d23a2f390e 158 in_PosizionatoreSW.f_MaximumSpeed_x100_FW = 25.0; // % of "i32_Max_Speed"
lex9296 23:b9d23a2f390e 159 in_PosizionatoreSW.f_MaximumSpeed_x100_BW = 25.0; //
lex9296 23:b9d23a2f390e 160 in_PosizionatoreSW.f_ServoLockSpeed_x100_FW = 5.0; //
lex9296 23:b9d23a2f390e 161 in_PosizionatoreSW.f_ServoLockSpeed_x100_BW = 5.0; //
lex9296 23:b9d23a2f390e 162
lex9296 28:443c82750dd9 163 // LA: Color RGB Component(s)
lex9296 28:443c82750dd9 164 // ======================
lex9296 28:443c82750dd9 165 //
lex9296 28:443c82750dd9 166 // RED 0000 1000 0000 0000 min 0x0800 02048
lex9296 28:443c82750dd9 167 // 1111 1000 0000 0000 max 0xf800 63488
lex9296 28:443c82750dd9 168 //
lex9296 28:443c82750dd9 169 // GREEN 0000 0000 0010 0000 min 0x0020 00032
lex9296 28:443c82750dd9 170 // 0000 0111 1110 0000 max 0x07e0 02016
lex9296 28:443c82750dd9 171 //
lex9296 28:443c82750dd9 172 // BLUE 0000 0000 0000 0001 min 0x0001 00001
lex9296 28:443c82750dd9 173 // 0000 0000 0001 1111 max 0x001f 00031
lex9296 28:443c82750dd9 174 //
lex9296 28:443c82750dd9 175 // La componente ROSSA ha 5 bit di escursione (0.. 31),
lex9296 28:443c82750dd9 176 // La componente VERDE ha 6 bit di escursione (0.. 63),
lex9296 28:443c82750dd9 177 // La componente BLU ha 5 bit di escursione (0.. 31),
lex9296 28:443c82750dd9 178 //
lex9296 28:443c82750dd9 179 // Le componenti RGB di "Color" sono quindi scritte negli appropriati registri come segue:
lex9296 28:443c82750dd9 180 //
lex9296 28:443c82750dd9 181 // writeReg(RED, (Color & 0xf800) >> 11);
lex9296 28:443c82750dd9 182 // writeReg(GREEN, (Color & 0x07e0) >> 5);
lex9296 28:443c82750dd9 183 // writeReg(BLUE, (Color & 0x001f));
lex9296 28:443c82750dd9 184 //
lex9296 28:443c82750dd9 185 LCM_SetTextColor(Scale2RGBColor (31, 31, 31), Scale2RGBColor (0, 0, 0)); // LA: Black on White
lex9296 28:443c82750dd9 186 LCM_ClearScreen (Scale2RGBColor (31, 31, 31));
lex9296 23:b9d23a2f390e 187
lex9296 28:443c82750dd9 188 // ui16_TestColor = Scale2RGBColor (ui16_R, ui16_G, ui16_B);
lex9296 28:443c82750dd9 189 // LCM_SetTextColor (
lex9296 28:443c82750dd9 190 // Scale2RGBColor (0, 0, 0),
lex9296 28:443c82750dd9 191 // Scale2RGBColor (31, 31, 31)
lex9296 28:443c82750dd9 192 // );
lex9296 29:7ce8c5779f5e 193 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 0), "You Start Me Up ...");
lex9296 28:443c82750dd9 194
lex9296 28:443c82750dd9 195 while (1) {
lex9296 28:443c82750dd9 196 static int32_t Pulses_Prec;
lex9296 28:443c82750dd9 197 static uint32_t ms_0002_prec;
lex9296 28:443c82750dd9 198 static uint32_t ms_0003_prec;
lex9296 23:b9d23a2f390e 199
lex9296 28:443c82750dd9 200 float f_ai0000_Aux;
lex9296 29:7ce8c5779f5e 201 //
lex9296 28:443c82750dd9 202 float f_ai0000_prec;
lex9296 28:443c82750dd9 203 float f_ai0001_prec;
lex9296 28:443c82750dd9 204 float f_ai0002_prec;
lex9296 29:7ce8c5779f5e 205 float f_ai0003_prec;
lex9296 29:7ce8c5779f5e 206 float f_ai0004_prec;
lex9296 28:443c82750dd9 207
lex9296 29:7ce8c5779f5e 208 /*
lex9296 28:443c82750dd9 209 i32_Pulses = Stabilus322699.getPulses();
lex9296 28:443c82750dd9 210 PWM_PB3.pulsewidth_us(((float)i32_Pulses/ (float)5000.0)* (float)100.0); // 0.. 100us -> 0.. 100%
lex9296 28:443c82750dd9 211
lex9296 28:443c82750dd9 212 in_PosizionatoreSW.i64_ActualPosition = (int64_t) i32_Pulses; //
lex9296 27:654100855f5c 213
lex9296 28:443c82750dd9 214 ui32_PreCallms = TimersTimerValue(); // Freezes the Actual Sample.
lex9296 28:443c82750dd9 215 PosizionatoreSW (in_PosizionatoreSW, out_PosizionatoreSW);
lex9296 28:443c82750dd9 216 ui32_PostCallms = TimersTimerValue();
lex9296 28:443c82750dd9 217 //
lex9296 28:443c82750dd9 218 if (ui32_PostCallms >= ui32_PreCallms)
lex9296 28:443c82750dd9 219 ui32_Samplems = ui32_PostCallms- ui32_PreCallms; // Result => Actual - Previous
lex9296 28:443c82750dd9 220 else
lex9296 28:443c82750dd9 221 ui32_Samplems = ui32_PostCallms+ (0x7fffffff- ui32_PreCallms); // Result => Actual+ (Rollover- Previous)
lex9296 29:7ce8c5779f5e 222 */
lex9296 29:7ce8c5779f5e 223 // Override
lex9296 29:7ce8c5779f5e 224 //
lex9296 29:7ce8c5779f5e 225
lex9296 27:654100855f5c 226
lex9296 28:443c82750dd9 227 // LA: Wedge 4 LCDRefresh
lex9296 30:e45282a70a4d 228 /*
lex9296 28:443c82750dd9 229 if (
lex9296 28:443c82750dd9 230 (i32_Pulses != Pulses_Prec)
lex9296 28:443c82750dd9 231 ) {
lex9296 28:443c82750dd9 232 sprintf (StringText,
lex9296 28:443c82750dd9 233 "Pulses: %d ", i32_Pulses);
lex9296 28:443c82750dd9 234 LCM_SetTextColor (Scale2RGBColor (0, 0, 31), Scale2RGBColor (31, 31, 0));
lex9296 28:443c82750dd9 235 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 1), StringText);
lex9296 28:443c82750dd9 236 }
lex9296 30:e45282a70a4d 237 */
lex9296 28:443c82750dd9 238
lex9296 28:443c82750dd9 239 // if (out_PosizionatoreSW.ui32_PassedActual_ms != ms_0003_prec) {
lex9296 28:443c82750dd9 240 if (ui32_Samplems != ms_0003_prec) {
lex9296 28:443c82750dd9 241 sprintf (StringText,
lex9296 28:443c82750dd9 242 // "PassedActual_ms: %d ", out_PosizionatoreSW.ui32_PassedActual_ms);
lex9296 28:443c82750dd9 243 "PassedActual_ms: %d ", ui32_Samplems);
lex9296 28:443c82750dd9 244 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 245 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 2), StringText);
lex9296 28:443c82750dd9 246 // ms_0003_prec = out_PosizionatoreSW.ui32_PassedActual_ms;
lex9296 28:443c82750dd9 247 ms_0003_prec = ui32_Samplems;
lex9296 28:443c82750dd9 248 }
lex9296 28:443c82750dd9 249
lex9296 28:443c82750dd9 250 if (out_PosizionatoreSW.i32_ATVSpeed != ms_0002_prec) {
lex9296 28:443c82750dd9 251 sprintf (StringText,
lex9296 28:443c82750dd9 252 "Speed[ui]: %d ", out_PosizionatoreSW.i32_ATVSpeed);
lex9296 28:443c82750dd9 253 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 254 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 3), StringText);
lex9296 28:443c82750dd9 255 ms_0002_prec = out_PosizionatoreSW.i32_ATVSpeed;
lex9296 28:443c82750dd9 256 }
lex9296 27:654100855f5c 257
lex9296 28:443c82750dd9 258 f_ai0000_Aux = adc_temp.read();
lex9296 28:443c82750dd9 259 if (f_ai0000_Aux != f_ai0000_prec) {
lex9296 28:443c82750dd9 260 sprintf (StringText,
lex9296 28:443c82750dd9 261 // "ADC Temp = %f\n", (f_ai0000_Aux* 100));
lex9296 28:443c82750dd9 262 "ADC Temp = %f ", (f_ai0000_Aux* 100));
lex9296 28:443c82750dd9 263 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 264 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 4), StringText);
lex9296 28:443c82750dd9 265 f_ai0000_prec = f_ai0000_Aux;
lex9296 28:443c82750dd9 266 }
lex9296 27:654100855f5c 267
lex9296 28:443c82750dd9 268 f_ai0000_Aux = adc_vbat.read();
lex9296 28:443c82750dd9 269 if (f_ai0000_Aux != f_ai0001_prec) {
lex9296 28:443c82750dd9 270 sprintf (StringText,
lex9296 28:443c82750dd9 271 // "ADC VBat = %f\n", (f_ai0000_Aux* 100));
lex9296 28:443c82750dd9 272 "ADC VBat = %f ", (f_ai0000_Aux));
lex9296 28:443c82750dd9 273 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 274 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 5), StringText);
lex9296 28:443c82750dd9 275 f_ai0001_prec = f_ai0000_Aux;
lex9296 28:443c82750dd9 276 }
lex9296 27:654100855f5c 277
lex9296 28:443c82750dd9 278 f_ai0000_Aux = adc_vref.read();
lex9296 28:443c82750dd9 279 if (f_ai0000_Aux != f_ai0002_prec) {
lex9296 28:443c82750dd9 280 sprintf (StringText,
lex9296 28:443c82750dd9 281 // "ADC VRef = %f\n", (f_ai0000_Aux* 100));
lex9296 28:443c82750dd9 282 "ADC VRef = %f ", (f_ai0000_Aux));
lex9296 28:443c82750dd9 283 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 284 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 6), StringText);
lex9296 28:443c82750dd9 285 f_ai0002_prec = f_ai0000_Aux;
lex9296 28:443c82750dd9 286 }
lex9296 29:7ce8c5779f5e 287
lex9296 29:7ce8c5779f5e 288 f_ai0000_Aux = ADC12_IN9.read();
lex9296 29:7ce8c5779f5e 289 if (f_ai0000_Aux != f_ai0003_prec) {
lex9296 29:7ce8c5779f5e 290 sprintf (StringText,
lex9296 29:7ce8c5779f5e 291 "ADC12.09 = %f ", (f_ai0000_Aux));
lex9296 29:7ce8c5779f5e 292 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 29:7ce8c5779f5e 293 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 8), StringText);
lex9296 29:7ce8c5779f5e 294 f_ai0003_prec = f_ai0000_Aux;
lex9296 29:7ce8c5779f5e 295 }
lex9296 29:7ce8c5779f5e 296
lex9296 29:7ce8c5779f5e 297 f_ai0000_Aux = ADC12_IN15.read();
lex9296 29:7ce8c5779f5e 298 if (f_ai0000_Aux != f_ai0004_prec) {
lex9296 29:7ce8c5779f5e 299 sprintf (StringText,
lex9296 29:7ce8c5779f5e 300 "ADC12.15 = %f ", (f_ai0000_Aux));
lex9296 29:7ce8c5779f5e 301 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 29:7ce8c5779f5e 302 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 9), StringText);
lex9296 29:7ce8c5779f5e 303 f_ai0004_prec = f_ai0000_Aux;
lex9296 29:7ce8c5779f5e 304 }
lex9296 29:7ce8c5779f5e 305
lex9296 29:7ce8c5779f5e 306 // LA: Scope, Theory of operation.
lex9296 29:7ce8c5779f5e 307 // ===========================
lex9296 29:7ce8c5779f5e 308 //
lex9296 29:7ce8c5779f5e 309 // 1) Sample a Value @ any Step
lex9296 29:7ce8c5779f5e 310 // 2) Store @ the correct ms
lex9296 29:7ce8c5779f5e 311 // 3) Plot the current Section of the Sampling Vector
lex9296 29:7ce8c5779f5e 312 //
lex9296 29:7ce8c5779f5e 313
lex9296 30:e45282a70a4d 314 LCM_PlotVector();
lex9296 30:e45282a70a4d 315 // getDmTft().setPixel (0,0,1);
lex9296 28:443c82750dd9 316 }
lex9296 28:443c82750dd9 317 }
lex9296 28:443c82750dd9 318
lex9296 29:7ce8c5779f5e 319 static void SampleAndStore (void) {
lex9296 29:7ce8c5779f5e 320 int16_t i16_SampleIndex;
lex9296 29:7ce8c5779f5e 321 //float f_SampleAux;
lex9296 29:7ce8c5779f5e 322
lex9296 29:7ce8c5779f5e 323 af_PlotSamples[240- 1] = ADC12_IN9.read();
lex9296 29:7ce8c5779f5e 324 for (i16_SampleIndex = 0; i16_SampleIndex < (240- 1); i16_SampleIndex++) {
lex9296 29:7ce8c5779f5e 325 af_PlotSamples[i16_SampleIndex] = af_PlotSamples[i16_SampleIndex+ 1];
lex9296 29:7ce8c5779f5e 326 }
lex9296 29:7ce8c5779f5e 327
lex9296 29:7ce8c5779f5e 328 i32_Pulses++;
lex9296 29:7ce8c5779f5e 329 }
lex9296 29:7ce8c5779f5e 330
lex9296 29:7ce8c5779f5e 331 // Funziona, resta solo da plottare.
lex9296 29:7ce8c5779f5e 332 // Funziona, resta solo da plottare.
lex9296 29:7ce8c5779f5e 333 // Funziona, resta solo da plottare.
lex9296 29:7ce8c5779f5e 334 // Funziona, resta solo da plottare.
lex9296 29:7ce8c5779f5e 335
lex9296 28:443c82750dd9 336 /*
lex9296 27:654100855f5c 337 while (ui16_TestStep < 32) {
lex9296 27:654100855f5c 338
lex9296 27:654100855f5c 339 ui16_TestColor = Scale2RGBColor (ui16_R, ui16_G, ui16_B);
lex9296 27:654100855f5c 340 LCM_ClearScreen (ui16_TestColor);
lex9296 27:654100855f5c 341 LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor));
lex9296 27:654100855f5c 342 sprintf (StringText,
lex9296 27:654100855f5c 343 "Color: %04x %04x ", ui16_TestColor, ui16_TestStep);
lex9296 27:654100855f5c 344 LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), StringText);
lex9296 27:654100855f5c 345 sprintf (StringText,
lex9296 27:654100855f5c 346 "R:%02x G:%02x B:%02x ", ui16_R, ui16_G, ui16_B);
lex9296 27:654100855f5c 347 LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 5), StringText);
lex9296 27:654100855f5c 348 // delay (500);
lex9296 27:654100855f5c 349
lex9296 27:654100855f5c 350 ui16_R++;
lex9296 27:654100855f5c 351 ui16_G++;
lex9296 27:654100855f5c 352 ui16_B++;
lex9296 27:654100855f5c 353 // ui16_TestColor += 0x0841;
lex9296 27:654100855f5c 354 ui16_TestStep ++;
lex9296 27:654100855f5c 355 }
lex9296 27:654100855f5c 356 delay (2500);
lex9296 28:443c82750dd9 357 */