Version buguée Fonction écriture ok, PWM output ok, pin a2 output bug, (TAF debug, lecture, conf lecture)

This commit is contained in:
Paul Faure 2020-11-13 01:23:49 +01:00
parent 0da346a774
commit 1feb054b2b
3 changed files with 87 additions and 8 deletions

View file

@ -130,7 +130,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>DLGTARM</Key> <Key>DLGTARM</Key>
<Name>(1010=668,263,1044,820,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=1027,281,1448,686,0)(121=-1,-1,-1,-1,0)(122=348,235,769,640,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=87,183,486,528,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=621,97,1215,791,0)(131=738,113,1332,807,0)(132=784,58,1378,752,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)(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)</Name> <Name>(1010=668,263,1044,820,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=1027,281,1448,686,0)(121=-1,-1,-1,-1,0)(122=348,235,769,640,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=87,183,486,528,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=621,97,1215,791,0)(131=157,121,751,815,0)(132=147,87,741,781,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)(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)</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@ -157,6 +157,70 @@
<Bp> <Bp>
<Number>0</Number> <Number>0</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>35</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219770</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Src\Gouvernail.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/Gouvernail.c\35</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>66</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219278</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Src\Voilier.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/Voilier.c\66</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>67</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219284</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Src\Voilier.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/Voilier.c\67</Expression>
</Bp>
<Bp>
<Number>3</Number>
<Type>0</Type>
<LineNumber>68</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219292</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Src\Voilier.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/Voilier.c\68</Expression>
</Bp>
<Bp>
<Number>4</Number>
<Type>0</Type>
<LineNumber>56</LineNumber> <LineNumber>56</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>0</Address> <Address>0</Address>

View file

@ -1,6 +1,9 @@
#include "stm32f1xx_ll_gpio.h" // GPIO #include "stm32f1xx_ll_gpio.h" // GPIO
#include "stm32f1xx_ll_bus.h" // RCC #include "stm32f1xx_ll_bus.h" // RCC
#include "stm32f1xx_ll_tim.h" // TIMER #include "stm32f1xx_ll_tim.h" // TIMER
#include "maths.h"
#define MAX_PWM (19999)
/** /**
* @brief Configure le récepteur de la télécommande ainsi que le plateau rotatif. * @brief Configure le récepteur de la télécommande ainsi que le plateau rotatif.
@ -22,8 +25,9 @@ void ConfGouvernail(void) {
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_7, LL_GPIO_MODE_FLOATING); LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_7, LL_GPIO_MODE_FLOATING);
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_1, LL_GPIO_MODE_ALTERNATE); LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_1, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinOutputType(GPIOA, LL_GPIO_PIN_1, LL_GPIO_OUTPUT_PUSHPULL); LL_GPIO_SetPinOutputType(GPIOA, LL_GPIO_PIN_1, LL_GPIO_OUTPUT_PUSHPULL);
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_2, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_2, LL_GPIO_MODE_OUTPUT_2MHz);
LL_GPIO_SetPinOutputType(GPIOA, LL_GPIO_PIN_2, LL_GPIO_OUTPUT_PUSHPULL); LL_GPIO_SetPinOutputType(GPIOA, LL_GPIO_PIN_2, LL_GPIO_OUTPUT_PUSHPULL);
LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_2);
//Configuration des timers //Configuration des timers
@ -36,7 +40,7 @@ void ConfGouvernail(void) {
LL_TIM_OC_StructInit(&Tim2Initializer); LL_TIM_OC_StructInit(&Tim2Initializer);
Tim2Initializer.OCMode = LL_TIM_OCMODE_PWM1; Tim2Initializer.OCMode = LL_TIM_OCMODE_PWM1;
LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH2, &Tim2Initializer); LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH2, &Tim2Initializer);
LL_TIM_SetAutoReload(TIM2, 19999); LL_TIM_SetAutoReload(TIM2, MAX_PWM);
LL_TIM_SetPrescaler(TIM2, 71); LL_TIM_SetPrescaler(TIM2, 71);
LL_TIM_OC_SetCompareCH2(TIM2, 0); LL_TIM_OC_SetCompareCH2(TIM2, 0);
LL_TIM_EnableCounter(TIM2); LL_TIM_EnableCounter(TIM2);
@ -60,4 +64,10 @@ int LireTelecommande(void) {
* @retval None * @retval None
*/ */
void CommanderMoteur(int commande) { void CommanderMoteur(int commande) {
if (commande < 0) {
LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_2);
} else {
LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_2);
}
LL_TIM_OC_SetCompareCH2(TIM2, (int)(((float)abs(commande)) * (((float)MAX_PWM) / 100.0)));
} }

View file

@ -59,12 +59,17 @@ void Background(){
TendreVoile(CalculerTension(RecupAllure())); //on tend la voile grâce à la tension obtenue TendreVoile(CalculerTension(RecupAllure())); //on tend la voile grâce à la tension obtenue
//Gouvernail //Gouvernail
/*int valeurTelecommande = LireTelecommande(); //on lit la valeur renvoyée par la télécommande //int commande = LireTelecommande(); //on lit la valeur renvoyée par la télécommande
int vitesse = CalculerVitesse(valeurTelecommande);//gràace à la valeur de la telecommande on calcule la vitesse souhaitée CommanderMoteur(0); //On commande le moteur pour aller à la vitesse voulue
CommanderMoteur(vitesse);//On commande le moteur pour aller à la vitesse voulue CommanderMoteur(-0);
CommanderMoteur(-1);
CommanderMoteur(1);
CommanderMoteur(-50);
CommanderMoteur(50);
CommanderMoteur(-100);
CommanderMoteur(100);
//Anti-Chavirement //Anti-Chavirement
int rouli = RecupRouli(); /*int rouli = RecupRouli();
int danger = CalculerDanger(rouli);//renvoi boolean : int à 0 si faux et 1 si vrai int danger = CalculerDanger(rouli);//renvoi boolean : int à 0 si faux et 1 si vrai
if(danger){ if(danger){
TendreVoile(90); //si il y a danger on relache les voiles (relacher les voiles = les mettre à 90) TendreVoile(90); //si il y a danger on relache les voiles (relacher les voiles = les mettre à 90)