From 18e312d6c56c585aaf7ecd728076e9f76d641040 Mon Sep 17 00:00:00 2001 From: Simon Paris Date: Thu, 13 Apr 2023 13:27:48 +0200 Subject: [PATCH] Controle Voile et Debug PWM channel --- implementation/girouette.c | 2 +- implementation/servo.c | 6 +++--- keilproject/Source/Principale.c | 6 +++++- keilproject/voilier.uvoptx | 11 ++++++++--- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/implementation/girouette.c b/implementation/girouette.c index 15bd619..1706225 100644 --- a/implementation/girouette.c +++ b/implementation/girouette.c @@ -2,7 +2,7 @@ void MyGirouette_Init(TIM_TypeDef *TIMX) { - + RCC->APB1ENR |=RCC_APB1ENR_TIM4EN; //configuration gpiob6 et gpiob7 en entrées In_Floating imposer par le timer4 MyGPIO_Struct_TypeDef MyGPIO={GPIOB,6,In_Floating}; MyGPIO_Init(&MyGPIO); diff --git a/implementation/servo.c b/implementation/servo.c index b88ee3a..c763582 100644 --- a/implementation/servo.c +++ b/implementation/servo.c @@ -13,8 +13,8 @@ void MyServo_Init(void) MyTimer_Base_Init(&Timer); //Pin Timer 2 Channel 1 PA0 - MyTimer_PWM(TIM2, 1); - MyTimer_DutyCycle(TIM2, 1, 750); + MyTimer_PWM(TIM2, 2); + MyTimer_DutyCycle(TIM2, 2, 750); MyTimer_Base_Start(Timer); } @@ -26,5 +26,5 @@ void MyServo_ChangeAngle(uint8_t Angle) int DC = 500 + (Angle * 500 / 180); - MyTimer_DutyCycle(TIM2, 1, DC); + MyTimer_DutyCycle(TIM2, 2, DC); } diff --git a/keilproject/Source/Principale.c b/keilproject/Source/Principale.c index 3b33f9d..52900f3 100644 --- a/keilproject/Source/Principale.c +++ b/keilproject/Source/Principale.c @@ -25,11 +25,15 @@ int main (void) MyServo_ChangeAngle(90); //MyRTC_GetTime(&sec, &min, &hour, &day, &date, &month, &year); while(1){ - Lecture_accelerometre(&GX,&GY,&GZ); + Lecture_accelerometre(&GX,&GY,&GZ); if(GZ < 5.5) + { MyServo_ChangeAngle(179); + } Angle_Girouette=MyGirouette_Angle(TIM4); + MyServo_ChangeAngle(Angle_Girouette/4); }; + } void initImplementation(void) diff --git a/keilproject/voilier.uvoptx b/keilproject/voilier.uvoptx index 2eb6932..dda724d 100644 --- a/keilproject/voilier.uvoptx +++ b/keilproject/voilier.uvoptx @@ -75,7 +75,7 @@ 1 0 - 0 + 1 18 @@ -125,7 +125,7 @@ 0 DLGDARM - (1010=752,272,1128,829,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=429,109,850,536,0)(121=247,294,668,721,0)(122=875,109,1296,536,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=123,134,717,885,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) + (1010=752,272,1128,829,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=832,432,1253,859,0)(121=247,294,668,721,0)(122=875,109,1296,536,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=751,208,1345,959,0)(132=-1,-1,-1,-1,0)(133=235,63,829,814,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) 0 @@ -150,6 +150,11 @@ 1 returnValue + + 2 + 1 + Angle_Girouette + 0 @@ -257,7 +262,7 @@ 1 0 - 1 + 0 18