![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Forked to initiate the Current Loop Gain
Dependencies: mbed QEI DmTftLibraryEx
Diff: main.cpp
- Revision:
- 29:7ce8c5779f5e
- Parent:
- 28:443c82750dd9
- Child:
- 30:e45282a70a4d
--- a/main.cpp Fri Mar 04 14:03:57 2022 +0000 +++ b/main.cpp Fri Mar 04 15:31:53 2022 +0000 @@ -25,6 +25,12 @@ //#include "DmTouch.h" //#include "DmTouchCalibration.h" +int32_t i32_Pulses; +// +static void SampleAndStore (void); +Ticker SampleTimer; // LA: To Sample 1AI any ms +float af_PlotSamples[240]; // LA: "Horiz" Plot Array + // LA: Theory of Operation // =================== // @@ -50,6 +56,9 @@ AnalogIn adc_vref (ADC_VREF); AnalogIn adc_vbat (ADC_VBAT); +AnalogIn ADC12_IN9 (PA_4); // STM32 PA4 +AnalogIn ADC12_IN15 (PB_0); // STM32 PB0 + // PWM // === // @@ -100,10 +109,11 @@ uint32_t ui32_PostCallms; uint32_t ui32_Samplems; - EepromInit(); // LA: Inizializza la EEProm TimersInit(); // LA: Parte il Timer a 1ms + SampleTimer.attach_us( &SampleAndStore, 1000 ); + // LA: FactoryReset se "userButton" premuto all'avvio // if (userButton == 0) { @@ -174,19 +184,22 @@ // Scale2RGBColor (0, 0, 0), // Scale2RGBColor (31, 31, 31) // ); - LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 0), "You Start Me Up ..."); + LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 0), "You Start Me Up ..."); while (1) { static int32_t Pulses_Prec; static uint32_t ms_0002_prec; static uint32_t ms_0003_prec; - int32_t i32_Pulses; float f_ai0000_Aux; + // float f_ai0000_prec; float f_ai0001_prec; float f_ai0002_prec; + float f_ai0003_prec; + float f_ai0004_prec; +/* i32_Pulses = Stabilus322699.getPulses(); PWM_PB3.pulsewidth_us(((float)i32_Pulses/ (float)5000.0)* (float)100.0); // 0.. 100us -> 0.. 100% @@ -200,7 +213,10 @@ ui32_Samplems = ui32_PostCallms- ui32_PreCallms; // Result => Actual - Previous else ui32_Samplems = ui32_PostCallms+ (0x7fffffff- ui32_PreCallms); // Result => Actual+ (Rollover- Previous) - +*/ +// Override +// + // LA: Wedge 4 LCDRefresh if ( @@ -260,9 +276,53 @@ LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 6), StringText); f_ai0002_prec = f_ai0000_Aux; } + + f_ai0000_Aux = ADC12_IN9.read(); + if (f_ai0000_Aux != f_ai0003_prec) { + sprintf (StringText, + "ADC12.09 = %f ", (f_ai0000_Aux)); + LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31)); + LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 8), StringText); + f_ai0003_prec = f_ai0000_Aux; + } + + f_ai0000_Aux = ADC12_IN15.read(); + if (f_ai0000_Aux != f_ai0004_prec) { + sprintf (StringText, + "ADC12.15 = %f ", (f_ai0000_Aux)); + LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31)); + LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 9), StringText); + f_ai0004_prec = f_ai0000_Aux; + } + + // LA: Scope, Theory of operation. + // =========================== + // + // 1) Sample a Value @ any Step + // 2) Store @ the correct ms + // 3) Plot the current Section of the Sampling Vector + // + } } +static void SampleAndStore (void) { +int16_t i16_SampleIndex; +//float f_SampleAux; + + af_PlotSamples[240- 1] = ADC12_IN9.read(); + for (i16_SampleIndex = 0; i16_SampleIndex < (240- 1); i16_SampleIndex++) { + af_PlotSamples[i16_SampleIndex] = af_PlotSamples[i16_SampleIndex+ 1]; + } + + i32_Pulses++; +} + +// Funziona, resta solo da plottare. +// Funziona, resta solo da plottare. +// Funziona, resta solo da plottare. +// Funziona, resta solo da plottare. + /* while (ui16_TestStep < 32) {