ok
This commit is contained in:
parent
07cdd89071
commit
299d4997da
8 changed files with 611 additions and 685 deletions
|
@ -103,7 +103,7 @@
|
|||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>6</nTsel>
|
||||
<nTsel>0</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
|
@ -114,7 +114,7 @@
|
|||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile></tIfile>
|
||||
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
|
||||
<pMon>BIN\UL2CM3.DLL</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
|
@ -130,7 +130,7 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<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=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=784,58,1378,752,0)(133=-1,-1,-1,-1,0)(160=900,145,1348,559,0)(161=476,349,924,763,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=764,77,1367,711,0)(151=-1,-1,-1,-1,0)</Name>
|
||||
<Name>(1010=1544,437,1920,994,1)(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=1029,93,1623,787,0)(131=-1,-1,-1,-1,0)(132=1285,441,1879,1135,1)(133=-1,-1,-1,-1,0)(160=900,145,1348,559,0)(161=476,349,924,763,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=1317,406,1920,1040,1)(151=-1,-1,-1,-1,0)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
@ -145,7 +145,7 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>UL2CM3</Key>
|
||||
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM))</Name>
|
||||
<Name>-UAny -O206 -S8 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
@ -153,40 +153,7 @@
|
|||
<Name>-U-O142 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>96</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134223920</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\96</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>56</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134223654</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\56</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<Breakpoint/>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
|
@ -198,6 +165,21 @@
|
|||
<WinNumber>1</WinNumber>
|
||||
<ItemText>NiveauBatterie</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>res</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>angle_voile</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>retourCapteur,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
|
@ -208,7 +190,7 @@
|
|||
<aLwin>1</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>1</aSer1>
|
||||
<aSer2>1</aSer2>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>1</viewmode>
|
||||
<vrSel>0</vrSel>
|
||||
|
@ -350,7 +332,7 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGDARM</Key>
|
||||
<Name>(1010=-1,-1,-1,-1,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=120,153,415,450,0)(120=204,207,625,634,0)(121=-1,-1,-1,-1,0)(122=896,89,1317,516,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=248,17,842,768,0)(131=521,17,1115,768,0)(132=709,17,1303,768,0)(133=-1,-1,-1,-1,0)(160=251,288,699,702,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)</Name>
|
||||
<Name>(1010=-1,-1,-1,-1,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=120,153,415,450,0)(120=204,207,625,634,0)(121=-1,-1,-1,-1,0)(122=896,89,1317,516,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=248,17,842,768,0)(131=521,17,1115,768,0)(132=896,77,1490,828,1)(133=-1,-1,-1,-1,0)(160=1068,325,1516,739,1)(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)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
@ -383,104 +365,7 @@
|
|||
<Name>-U-O142 -O2254 -S0 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>31</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134223390</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\31</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>32</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134223394</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\32</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>77</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>..\Src\Voilier.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>3</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>35</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>..\Src\Voilier.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>4</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>36</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>..\Src\Voilier.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>5</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>81</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>..\Src\Voilier.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<Breakpoint/>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
|
@ -502,7 +387,7 @@
|
|||
<aLwin>1</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>1</aSer1>
|
||||
<aSer2>1</aSer2>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>1</viewmode>
|
||||
<vrSel>0</vrSel>
|
||||
|
@ -630,7 +515,7 @@
|
|||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\Voile.c</PathWithFileName>
|
||||
|
|
File diff suppressed because it is too large
Load diff
16
Src/Allure.c
16
Src/Allure.c
|
@ -53,19 +53,19 @@ void ConfAllure(void) {
|
|||
Tim3Initializer.IC2Polarity = LL_TIM_IC_POLARITY_RISING;
|
||||
Tim3Initializer.IC2Prescaler = LL_TIM_ICPSC_DIV1;
|
||||
LL_TIM_ENCODER_Init(TIM3, &Tim3Initializer);
|
||||
LL_TIM_SetAutoReload(TIM3, 359);
|
||||
LL_TIM_SetAutoReload(TIM3, 719);
|
||||
LL_TIM_EnableCounter(TIM3);
|
||||
}
|
||||
|
||||
int retourCapteur;
|
||||
int RecupAllure(void) {
|
||||
if (!initialized) {
|
||||
return 180; //Si jamais la girouette n'est pas initialisée, on relache les voiles (comme en cas d'alerte dee chavirement)
|
||||
} else {
|
||||
int retourCapteur = (int)LL_TIM_GetCounter(TIM3);
|
||||
if (retourCapteur < 180) {
|
||||
return retourCapteur;
|
||||
retourCapteur = (int)LL_TIM_GetCounter(TIM3);
|
||||
if (retourCapteur < 360) {
|
||||
return (retourCapteur/2);
|
||||
} else {
|
||||
return retourCapteur - 360;
|
||||
return (retourCapteur + 720)/2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ char * AllureToString(int alpha) {
|
|||
if (alpha_abs < 45) {
|
||||
return "Vent debout";
|
||||
} else if (alpha < 55) {
|
||||
return "Près";
|
||||
return "Pres";
|
||||
} else if (alpha < 65) {
|
||||
return "Bon plein";
|
||||
} else if (alpha < 80) {
|
||||
|
@ -87,7 +87,7 @@ char * AllureToString(int alpha) {
|
|||
} else if (alpha < 155) {
|
||||
return "Grand largue";
|
||||
} else if (alpha < 180) {
|
||||
return "Vent arrière";
|
||||
return "Vent arriere";
|
||||
} else {
|
||||
return "ERROR";
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "stm32f1xx_ll_tim.h" // TIMER
|
||||
#include "maths.h"
|
||||
|
||||
#define MAX_PWM (19999)
|
||||
#define MAX_PWM (50)
|
||||
#define MAX_PWM_OUTPUT (34999)
|
||||
|
||||
/**
|
||||
|
@ -70,7 +70,12 @@ void ConfGouvernail(void) {
|
|||
*/
|
||||
int LireTelecommande(void) {
|
||||
int lecture = LL_TIM_IC_GetCaptureCH2(TIM4) + 1;
|
||||
return ((lecture - 1500) / 5);
|
||||
int Valeur_Lue = ((lecture - 1500) / 5);
|
||||
if (abs(Valeur_Lue) < 10) {
|
||||
return 0;
|
||||
} else {
|
||||
return Valeur_Lue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,18 +7,14 @@
|
|||
#include "stm32f1xx_ll_rcc.h" // utile dans la fonction SystemClock_Config
|
||||
#include "Voile.h"
|
||||
|
||||
#define SEUIL45DEGRESSENS1 (1853)
|
||||
|
||||
#define SEUIL45DEGRESSENS2 (2457)
|
||||
|
||||
|
||||
// Seuil represente la valeur (en %) en dessous de laquelle le niveau de batterie est consideree faible
|
||||
#define Seuil (20)
|
||||
|
||||
// Seuil represente la valeur de l'angle au dessus de laquelle le chavirement est trop prononcé
|
||||
#define SeuilAngle (40)
|
||||
|
||||
|
||||
int drapeauRecupSecurite = 0; // Flag qui est mis à 1 toute les 10 sec pour recuperer niveau batterie/rouli et envoi régulier
|
||||
int drapeauDangerBatterie = 0; //Flag qui est mis à 1 toute les 10 sec si batterie faible --> envoie message alarme
|
||||
int drapeauDangerRouli = 0; //Flag qui est mis à 1 toute les 10 sec si rouli pas bon --> envoie message alarme
|
||||
|
||||
void ConfSecurite(){
|
||||
//On est pas sûrs pour ADC 1, voir datasheet page 28
|
||||
|
||||
|
@ -100,7 +96,7 @@ int CalculerDangerNiveauBatterie(int niveau){
|
|||
|
||||
|
||||
int CalculerDangerChavirement(int gamma){
|
||||
if ( gamma >= SeuilAngle)
|
||||
if ((gamma > SEUIL45DEGRESSENS2) || (gamma < SEUIL45DEGRESSENS1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -117,6 +113,6 @@ int RecupRouli(){
|
|||
while(!LL_ADC_IsActiveFlag_JEOS(ADC1)){}
|
||||
// R?cuperation de la valeur apres conversion
|
||||
int NiveauChavirement = LL_ADC_INJ_ReadConversionData12(ADC1,LL_ADC_INJ_RANK_1);
|
||||
return 0; // Trouver le calcul de l'angle
|
||||
return NiveauChavirement;
|
||||
}
|
||||
|
||||
|
|
60
Src/Voile.c
60
Src/Voile.c
|
@ -3,6 +3,7 @@
|
|||
#include "stm32f1xx_ll_tim.h"
|
||||
#include "stm32f1xx_ll_bus.h"
|
||||
#include "maths.h" //Remplacer par maths.h quand on va tout faire marcher.
|
||||
#include "string.h"
|
||||
|
||||
#define ARR (19999)
|
||||
#define PSC (71)
|
||||
|
@ -10,22 +11,22 @@
|
|||
#define channel (1)
|
||||
#define A_ALPHA_TO_BETA (2.0/3.0) //Coefficient directeur de la partie linéaire de la fonction transformant l'allure en angle de voile
|
||||
#define B_ALPHA_TO_BETA (-30.0) //Ordonnée a l'origine de cette même fonction
|
||||
#define GAMMA_90 (19900) //Valeur du registre commandant la largeur de la PWM pour les voiles lachées
|
||||
#define GAMMA_0 (100) //Valeur du registre commandant la largeur de la PWM pour les voiles bordées au maximum
|
||||
#define GAMMA_90 (2100) //Valeur du registre commandant la largeur de la PWM pour les voiles lachées
|
||||
#define GAMMA_0 (1000) //Valeur du registre commandant la largeur de la PWM pour les voiles bordées au maximum
|
||||
#define A_BETA_TO_GAMMA ((GAMMA_90 - GAMMA_0)/90.0) //Coefficient directeur de la relation entre l'angle de voile et la PWM
|
||||
#define B_BETA_TO_GAMMA (GAMMA_0) //Ordonnée a l'origine
|
||||
|
||||
//Valeurs de CCR1 pour la PWM output
|
||||
#define POSITION_00 1000
|
||||
#define POSITION_10 1100
|
||||
#define POSITION_20 1200
|
||||
#define POSITION_30 1300
|
||||
#define POSITION_40 1400
|
||||
#define POSITION_50 1500
|
||||
#define POSITION_60 1600
|
||||
#define POSITION_70 1700
|
||||
#define POSITION_80 1800
|
||||
#define POSITION_90 1900
|
||||
#define POSITION_00 2100
|
||||
#define POSITION_10 1880
|
||||
#define POSITION_20 1770
|
||||
#define POSITION_30 1660
|
||||
#define POSITION_40 1550
|
||||
#define POSITION_50 1440
|
||||
#define POSITION_60 1330
|
||||
#define POSITION_70 1220
|
||||
#define POSITION_80 1110
|
||||
#define POSITION_90 1000
|
||||
|
||||
|
||||
int angleVoileActuel = 0; //angle de la voile. Mis à jour quans on la tend. de 0 à 45.
|
||||
|
@ -34,6 +35,7 @@ int angleVoileActuel = 0; //angle de la voile. Mis
|
|||
|
||||
void ConfVoile(void){
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); //Enable l'horloge du GPIOA
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_TIM1);
|
||||
LL_TIM_SetAutoReload(Timer, ARR); //On règle l'ARR
|
||||
LL_TIM_SetPrescaler(Timer, PSC); //On règle le PSC
|
||||
LL_GPIO_SetPinMode(GPIOA,LL_GPIO_PIN_8,LL_GPIO_MODE_ALTERNATE); //Pin en mode output alternate
|
||||
|
@ -45,6 +47,7 @@ void ConfVoile(void){
|
|||
LL_TIM_EnableCounter(Timer); //On commence le comptage
|
||||
}
|
||||
|
||||
float res;
|
||||
|
||||
int RecupTensionVoile(void){
|
||||
return angleVoileActuel;
|
||||
|
@ -53,17 +56,18 @@ int RecupTensionVoile(void){
|
|||
|
||||
int CalculerTension(int alpha){
|
||||
if (abs(alpha) < 45){
|
||||
res = 0;
|
||||
return 0;
|
||||
} else {
|
||||
float res = A_ALPHA_TO_BETA * (float)abs(alpha) + B_ALPHA_TO_BETA;
|
||||
res = A_ALPHA_TO_BETA * (float)abs(alpha) + B_ALPHA_TO_BETA;
|
||||
return (int)res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float angle_voile;
|
||||
void TendreVoile(int theta)
|
||||
{
|
||||
if (theta < 5){
|
||||
/*if (theta < 5){
|
||||
Timer->CCR1 = POSITION_00;
|
||||
angleVoileActuel = 0;
|
||||
}
|
||||
|
@ -102,12 +106,30 @@ void TendreVoile(int theta)
|
|||
else{
|
||||
Timer->CCR1 = POSITION_90;
|
||||
angleVoileActuel = 90;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
//Timer->CCR1 = (int)(A_BETA_TO_GAMMA * (float)theta + B_BETA_TO_GAMMA) ;
|
||||
angleVoileActuel = (A_BETA_TO_GAMMA * (float)theta + B_BETA_TO_GAMMA) ;
|
||||
Timer->CCR1 = (int)angleVoileActuel ;
|
||||
}
|
||||
|
||||
char * TensionVoileToString(int theta) {
|
||||
return "";
|
||||
if (theta < 10) {
|
||||
return "Voiles bordees";
|
||||
} else if (theta < 20) {
|
||||
return "Voiles a 20 degres";
|
||||
} else if (theta < 30) {
|
||||
return "Voiles a 30 degres";
|
||||
} else if (theta < 40) {
|
||||
return "Voiles a 40 degres";
|
||||
} else if (theta < 50) {
|
||||
return "Voiles a 50 degres";
|
||||
} else if (theta < 60) {
|
||||
return "Voiles a 60 degres";
|
||||
} else if (theta < 70) {
|
||||
return "Voiles a 70 degres";
|
||||
} else if (theta < 80) {
|
||||
return "Voiles a 80 degres";
|
||||
} else {
|
||||
return "Voiles choquees";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,11 +59,11 @@ void Task100ms(){
|
|||
|
||||
int dangerRoulis = 0; //Variable qui permet de ne pas tendre les voiles si il y a trop de roulis
|
||||
|
||||
//Anti-Chavirement
|
||||
//Anti-Chavirement
|
||||
if(CalculerDangerChavirement(RecupRouli())){//renvoi boolean : int à 0 si faux et 1 si vrai
|
||||
dangerRoulis = 1; //Pour pas retendre directement les voiles juste après.
|
||||
TendreVoile(90); //si il y a danger on relache les voiles (relacher les voiles = les mettre <20> 90)
|
||||
EnvoiExceptionnel("Risque de chavirement, voiles choquées");//Et on prévient l'utilisateur
|
||||
TendreVoile(0); //si il y a danger on relache les voiles (relacher les voiles = les mettre <20> 90)
|
||||
EnvoiExceptionnel("Risque de chavirement, voiles choquees");//Et on prévient l'utilisateur
|
||||
}
|
||||
|
||||
//Anti-Chavirement
|
||||
|
|
|
@ -5,4 +5,5 @@ int Concatenate(char * chaine1, char * chaine2, int sizechaine1, int sizechaine2
|
|||
|
||||
int size_of(char * chaine);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue