skusku

Dependencies:   mbed bloc_io mbed-rtos html EthernetInterface

Committer:
algrs
Date:
Thu Jan 14 22:34:19 2021 +0000
Revision:
1:fbf189951c5e
Parent:
0:e30c9ba95bd4
skusku

Who changed what in which revision?

UserRevisionLine numberNew contents of line
superphil06 0:e30c9ba95bd4 1
superphil06 0:e30c9ba95bd4 2
superphil06 0:e30c9ba95bd4 3 //#include "EthernetInterface.h"
algrs 1:fbf189951c5e 4 #include <stdio.h>
superphil06 0:e30c9ba95bd4 5 #include <stdlib.h>
superphil06 0:e30c9ba95bd4 6 #include <string.h>
superphil06 0:e30c9ba95bd4 7 #include "mbed.h"
superphil06 0:e30c9ba95bd4 8 #include "rtos.h" // need for main thread sleep
superphil06 0:e30c9ba95bd4 9 #include "html.h" // need for html patch working with web server
superphil06 0:e30c9ba95bd4 10 #include "bloc_io.h"
superphil06 0:e30c9ba95bd4 11 #define RADIUS 0.2F // wheel size
superphil06 0:e30c9ba95bd4 12 #define NBPOLES 8 // magnetic pole number
superphil06 0:e30c9ba95bd4 13 #define DELTA_T 0.1F // speed measurement counting period
algrs 1:fbf189951c5e 14 #define TickVitessePeriode 0.1
algrs 1:fbf189951c5e 15 #define CirconferenceRoue 1.25664F
superphil06 0:e30c9ba95bd4 16
superphil06 0:e30c9ba95bd4 17 Bloc_IO MyPLD(p25,p26,p5,p6,p7,p8,p9,p10,p23,p24);// instantiate object needed to communicate with PLD
algrs 1:fbf189951c5e 18 // analog input connected to mbed
algrs 1:fbf189951c5e 19 // valid pmw mbed pin
superphil06 0:e30c9ba95bd4 20 Serial pc(USBTX, USBRX); // tx, rx
algrs 1:fbf189951c5e 21 // Top_Hall Pin
algrs 1:fbf189951c5e 22
superphil06 0:e30c9ba95bd4 23 /************ persistent file parameters section *****************/
superphil06 0:e30c9ba95bd4 24 LocalFileSystem local("local"); // Create the local filesystem under the name "local"
superphil06 0:e30c9ba95bd4 25
algrs 1:fbf189951c5e 26
superphil06 0:e30c9ba95bd4 27 /********************* web server section **********************************/
superphil06 0:e30c9ba95bd4 28
superphil06 0:e30c9ba95bd4 29 var_field_t tab_balise[10]; //une balise est présente dans le squelette
superphil06 0:e30c9ba95bd4 30 int giCounter=0;// acces counting
superphil06 0:e30c9ba95bd4 31
superphil06 0:e30c9ba95bd4 32
superphil06 0:e30c9ba95bd4 33 /*********************** can bus section ************/
algrs 1:fbf189951c5e 34 // determine message ID used to send Gaz ref over can bus
superphil06 0:e30c9ba95bd4 35 #define _CAN_DEBUG // used to debug can bus activity
superphil06 0:e30c9ba95bd4 36 //#define USE_CAN_REF // uncomment to receive gaz ref over can_bus
superphil06 0:e30c9ba95bd4 37 CAN can_port (p30, p29); // initialisation du Bus CAN sur les broches 30 (rd) et 29(td) for lpc1768 + mbed shield
superphil06 0:e30c9ba95bd4 38 bool bCan_Active=false;
superphil06 0:e30c9ba95bd4 39
superphil06 0:e30c9ba95bd4 40
superphil06 0:e30c9ba95bd4 41 DigitalOut led1(LED1); //initialisation des Leds présentes sur le micro-controleur Mbed*/
superphil06 0:e30c9ba95bd4 42 DigitalOut led2(LED2);
superphil06 0:e30c9ba95bd4 43 DigitalOut led3(LED3); // blink when can message is sent
algrs 1:fbf189951c5e 44 DigitalOut led4(LED4); // blink when can message is received
algrs 1:fbf189951c5e 45
algrs 1:fbf189951c5e 46 InterruptIn TopHallSku(p22);
superphil06 0:e30c9ba95bd4 47
superphil06 0:e30c9ba95bd4 48
algrs 1:fbf189951c5e 49 float fVitesse = 0,fLimiteBridage=15;
algrs 1:fbf189951c5e 50 int iCompteurHallVitesse = 0,iCompteurHallTotal=0,iCompteurHallPartiel=0;
algrs 1:fbf189951c5e 51
algrs 1:fbf189951c5e 52 AnalogIn AINPOIGNEE (p17);
algrs 1:fbf189951c5e 53
algrs 1:fbf189951c5e 54 Ticker Ticky;
algrs 1:fbf189951c5e 55 Ticker TickVitesse;
algrs 1:fbf189951c5e 56 Ticker Bridge;
algrs 1:fbf189951c5e 57 Ticker TickPLD;
algrs 1:fbf189951c5e 58
algrs 1:fbf189951c5e 59 FILE* fichier = NULL;
algrs 1:fbf189951c5e 60
algrs 1:fbf189951c5e 61 int iMode=1;
algrs 1:fbf189951c5e 62 int iSortiePWM=0;
algrs 1:fbf189951c5e 63 int iConsignePWM=0;
algrs 1:fbf189951c5e 64 int iAllow=1;
algrs 1:fbf189951c5e 65 float fPoigneeMax=1,fPoigneeMin=0.5;
algrs 1:fbf189951c5e 66
algrs 1:fbf189951c5e 67
algrs 1:fbf189951c5e 68 int iBit6=0,iBit5=0,iBit4=0,iBit3=0,iBit2=0,iBit1=0,iBit0=0;
superphil06 0:e30c9ba95bd4 69
algrs 1:fbf189951c5e 70 void ModeAutoPWM(void)
algrs 1:fbf189951c5e 71 {
algrs 1:fbf189951c5e 72 if(iMode=1)
algrs 1:fbf189951c5e 73 {
algrs 1:fbf189951c5e 74 iConsignePWM=(((AINPOIGNEE.read()-fPoigneeMin)/(fPoigneeMax-fPoigneeMin))*255);
algrs 1:fbf189951c5e 75 if(iConsignePWM>254)
algrs 1:fbf189951c5e 76 { iConsignePWM=255; }
algrs 1:fbf189951c5e 77 else if (iConsignePWM<10)
algrs 1:fbf189951c5e 78 { iConsignePWM=0; } // FIN DE L'ACTUALISATION DE LA SORTIE PWM IDEALE
algrs 1:fbf189951c5e 79
algrs 1:fbf189951c5e 80 if(iBit5==0) //frein , faire lecture ici
algrs 1:fbf189951c5e 81 { iSortiePWM=0; }
algrs 1:fbf189951c5e 82 else if(iConsignePWM>iSortiePWM && ((fVitesse/1000)<fLimiteBridage))
algrs 1:fbf189951c5e 83 { iSortiePWM++; }
algrs 1:fbf189951c5e 84 else if(iConsignePWM<iSortiePWM )
algrs 1:fbf189951c5e 85 { iSortiePWM--; } // FIN DE L'ACTUALISATION DE LA SORTIE PWM PROGRESSIVE
algrs 1:fbf189951c5e 86 }
algrs 1:fbf189951c5e 87 else if(iMode=0)
algrs 1:fbf189951c5e 88 {
algrs 1:fbf189951c5e 89 iConsignePWM=0;
algrs 1:fbf189951c5e 90 iSortiePWM=0;
algrs 1:fbf189951c5e 91 }
algrs 1:fbf189951c5e 92
algrs 1:fbf189951c5e 93 MyPLD.write(iSortiePWM); // Ecriture sortie
algrs 1:fbf189951c5e 94 }
algrs 1:fbf189951c5e 95
algrs 1:fbf189951c5e 96 void VitesseTopHall()
algrs 1:fbf189951c5e 97 {
algrs 1:fbf189951c5e 98 fVitesse=((2*3.1415*0.2*iCompteurHallVitesse)/(TickVitessePeriode*8*6))*3600;
algrs 1:fbf189951c5e 99 iCompteurHallVitesse=0;
algrs 1:fbf189951c5e 100 }
algrs 1:fbf189951c5e 101
algrs 1:fbf189951c5e 102 void Incrementation()
algrs 1:fbf189951c5e 103 {
algrs 1:fbf189951c5e 104 iCompteurHallVitesse++;
algrs 1:fbf189951c5e 105 iCompteurHallTotal++;
algrs 1:fbf189951c5e 106 iCompteurHallPartiel++;
algrs 1:fbf189951c5e 107 }
superphil06 0:e30c9ba95bd4 108 //************ local function prototypes *******************
superphil06 0:e30c9ba95bd4 109
superphil06 0:e30c9ba95bd4 110
superphil06 0:e30c9ba95bd4 111
algrs 1:fbf189951c5e 112 void LecturePLD(void)
algrs 1:fbf189951c5e 113 {
algrs 1:fbf189951c5e 114 int iLecture=MyPLD.read();
algrs 1:fbf189951c5e 115 if(iLecture>=64){iBit6=1;iLecture=iLecture-64; }else{iBit6=0;}
algrs 1:fbf189951c5e 116 if(iLecture>=32){iBit5=1;iLecture=iLecture-32; }else{iBit5=0;}
algrs 1:fbf189951c5e 117 if(iLecture>=16){iBit4=1;iLecture=iLecture-16; }else{iBit4=0;}
algrs 1:fbf189951c5e 118 if(iLecture>=8) {iBit3=1;iLecture=iLecture-8; }else{iBit3=0;}
algrs 1:fbf189951c5e 119 if(iLecture>=4) {iBit2=1;iLecture=iLecture-4; }else{iBit2=0;}
algrs 1:fbf189951c5e 120 if(iLecture>=2) {iBit1=1;iLecture=iLecture-2; }else{iBit1=0;}
algrs 1:fbf189951c5e 121 if(iLecture>=1) {iBit0=1;iLecture=iLecture-1; }else{iBit0=0;}
algrs 1:fbf189951c5e 122 }
algrs 1:fbf189951c5e 123
algrs 1:fbf189951c5e 124 void LireFichier()
algrs 1:fbf189951c5e 125 {
algrs 1:fbf189951c5e 126 fichier = NULL;
algrs 1:fbf189951c5e 127 fichier = fopen("/local/GR2B.txt", "r");
algrs 1:fbf189951c5e 128
algrs 1:fbf189951c5e 129 pc.printf("\n\r Ouverture du fichier pour lecture... ");
algrs 1:fbf189951c5e 130 if(fichier==NULL)
algrs 1:fbf189951c5e 131 {
algrs 1:fbf189951c5e 132 pc.printf("ERREUR !\n\r");
algrs 1:fbf189951c5e 133 }
algrs 1:fbf189951c5e 134 else
algrs 1:fbf189951c5e 135 {
algrs 1:fbf189951c5e 136 fscanf(fichier, "%g %g %g %d %d",&fPoigneeMin,&fPoigneeMax,&fLimiteBridage,&iCompteurHallTotal,&iCompteurHallPartiel);
algrs 1:fbf189951c5e 137 pc.printf(" SUCCES !\n\r");
algrs 1:fbf189951c5e 138 pc.printf("_____________________________________________________________________________\n\r");
algrs 1:fbf189951c5e 139 pc.printf("PoigneeMin\tPoigneeMax\tLimiteBridage\tCompteursTot\tCompteurPart\n\r");
algrs 1:fbf189951c5e 140 pc.printf("%g\t\t%g\t\t%g\t\t%d\t\t%d\n\r",fPoigneeMin,fPoigneeMax,fLimiteBridage,iCompteurHallTotal,iCompteurHallPartiel);
algrs 1:fbf189951c5e 141 pc.printf("_____________________________________________________________________________\n\r");
algrs 1:fbf189951c5e 142 fclose(fichier);
algrs 1:fbf189951c5e 143 }
algrs 1:fbf189951c5e 144 }
algrs 1:fbf189951c5e 145
algrs 1:fbf189951c5e 146 void SauvegarderFichier()
algrs 1:fbf189951c5e 147 {
algrs 1:fbf189951c5e 148 fclose(fichier);
algrs 1:fbf189951c5e 149 fichier = NULL;
algrs 1:fbf189951c5e 150 fichier = fopen("/local/GR2B.txt", "w");
algrs 1:fbf189951c5e 151
algrs 1:fbf189951c5e 152 pc.printf("\n\r Ouverture du fichier pour ecriture... ");
algrs 1:fbf189951c5e 153
algrs 1:fbf189951c5e 154 if(fichier==NULL)
algrs 1:fbf189951c5e 155 {
algrs 1:fbf189951c5e 156 printf("ERREUR !\n\r(valeurs seulement en mémoire vive)\n\r");
algrs 1:fbf189951c5e 157 }
algrs 1:fbf189951c5e 158 else
algrs 1:fbf189951c5e 159 {
algrs 1:fbf189951c5e 160 fprintf(fichier, "%g %g %g %d %d",fPoigneeMin,fPoigneeMax,fLimiteBridage,iCompteurHallTotal,iCompteurHallPartiel);
algrs 1:fbf189951c5e 161 pc.printf(" SUCCES !\n\r");
algrs 1:fbf189951c5e 162 pc.printf("_____________________________________________________________________________\n\r");
algrs 1:fbf189951c5e 163 pc.printf("PoigneeMin\tPoigneeMax\tLimiteBridage\tCompteursTot\tCompteurPart\n\r");
algrs 1:fbf189951c5e 164 pc.printf("%g\t\t%g\t\t%g\t\t%d\t\t%d\n\r",fPoigneeMin,fPoigneeMax,fLimiteBridage,iCompteurHallTotal,iCompteurHallPartiel);
algrs 1:fbf189951c5e 165 pc.printf("_____________________________________________________________________________\n\r");
algrs 1:fbf189951c5e 166 fclose(fichier);
algrs 1:fbf189951c5e 167 }
algrs 1:fbf189951c5e 168
algrs 1:fbf189951c5e 169 fclose(fichier);
algrs 1:fbf189951c5e 170 }
superphil06 0:e30c9ba95bd4 171
superphil06 0:e30c9ba95bd4 172
superphil06 0:e30c9ba95bd4 173
superphil06 0:e30c9ba95bd4 174 /**************** Read persistent data from text file located on local file system ****************/
superphil06 0:e30c9ba95bd4 175
superphil06 0:e30c9ba95bd4 176
superphil06 0:e30c9ba95bd4 177
superphil06 0:e30c9ba95bd4 178 /**************** write persitant data to text file located on local file system ****************/
superphil06 0:e30c9ba95bd4 179
superphil06 0:e30c9ba95bd4 180
superphil06 0:e30c9ba95bd4 181 //************** calibation gaz function needed to record min_gaz and max_gaz value to persistent text file ******************
superphil06 0:e30c9ba95bd4 182
superphil06 0:e30c9ba95bd4 183
superphil06 0:e30c9ba95bd4 184 // ************top hall counting interrupt needed for speed measurement
superphil06 0:e30c9ba95bd4 185
superphil06 0:e30c9ba95bd4 186
superphil06 0:e30c9ba95bd4 187 //********************** timer interrupt for speed measurement each 100ms *************************
superphil06 0:e30c9ba95bd4 188
algrs 1:fbf189951c5e 189
algrs 1:fbf189951c5e 190
algrs 1:fbf189951c5e 191
superphil06 0:e30c9ba95bd4 192
superphil06 0:e30c9ba95bd4 193
superphil06 0:e30c9ba95bd4 194 //********************* Timer Interrupt for gaz ref management each 10ms ********************
superphil06 0:e30c9ba95bd4 195
superphil06 0:e30c9ba95bd4 196
superphil06 0:e30c9ba95bd4 197
superphil06 0:e30c9ba95bd4 198 /********* main cgi function used to patch data to the web server thread **********************************/
superphil06 0:e30c9ba95bd4 199 void CGI_Function(void) // cgi function that patch web data to empty web page
algrs 1:fbf189951c5e 200 {
algrs 1:fbf189951c5e 201 char ma_chaine4[20]= {}; // needed to form html response
superphil06 0:e30c9ba95bd4 202
superphil06 0:e30c9ba95bd4 203 }
algrs 1:fbf189951c5e 204
algrs 1:fbf189951c5e 205
algrs 1:fbf189951c5e 206 /*********************** CAN BUS SECTION **********************/
algrs 1:fbf189951c5e 207
superphil06 0:e30c9ba95bd4 208
superphil06 0:e30c9ba95bd4 209
superphil06 0:e30c9ba95bd4 210 void CAN_REC_THREAD(void const *args)
algrs 1:fbf189951c5e 211 {
algrs 1:fbf189951c5e 212 int iCount,iError;
superphil06 0:e30c9ba95bd4 213
algrs 1:fbf189951c5e 214 while (bCan_Active) {
algrs 1:fbf189951c5e 215 Thread::wait(100);// wait 100ms
algrs 1:fbf189951c5e 216 // code todo
algrs 1:fbf189951c5e 217
superphil06 0:e30c9ba95bd4 218 }
algrs 1:fbf189951c5e 219
superphil06 0:e30c9ba95bd4 220 }
algrs 1:fbf189951c5e 221 //*************************** main function *****************************************
algrs 1:fbf189951c5e 222 int main()
algrs 1:fbf189951c5e 223 {
algrs 1:fbf189951c5e 224 TopHallSku.mode(PullUp);
algrs 1:fbf189951c5e 225 char cChoix=0;
algrs 1:fbf189951c5e 226
algrs 1:fbf189951c5e 227 TickVitesse.attach(&VitesseTopHall,TickVitessePeriode);
algrs 1:fbf189951c5e 228
algrs 1:fbf189951c5e 229
algrs 1:fbf189951c5e 230 TickPLD.attach(&LecturePLD,0.1);
superphil06 0:e30c9ba95bd4 231
algrs 1:fbf189951c5e 232 TopHallSku.rise(&Incrementation);
algrs 1:fbf189951c5e 233 MyPLD.write(iConsignePWM);
algrs 1:fbf189951c5e 234 pc.printf("\n\r************************************");
algrs 1:fbf189951c5e 235 pc.printf("\n\r** **");
algrs 1:fbf189951c5e 236 pc.printf("\n\r** PROGRAMME SCOOTER MBED **");
algrs 1:fbf189951c5e 237 pc.printf("\n\r** **");
algrs 1:fbf189951c5e 238 pc.printf("\n\r************************************\n\r");
algrs 1:fbf189951c5e 239
algrs 1:fbf189951c5e 240 LireFichier();
algrs 1:fbf189951c5e 241
superphil06 0:e30c9ba95bd4 242
superphil06 0:e30c9ba95bd4 243
superphil06 0:e30c9ba95bd4 244 //***************************************** web section ********************************************/
superphil06 0:e30c9ba95bd4 245 //Init_Web_Server(&CGI_Function); // create and initialize tcp server socket and pass function pointer to local CGI function
superphil06 0:e30c9ba95bd4 246 //Thread WebThread(Web_Server_Thread);// create and launch web server thread
algrs 1:fbf189951c5e 247 /********* main cgi function used to patch data to the web server thread **********************************/
superphil06 0:e30c9ba95bd4 248
algrs 1:fbf189951c5e 249 //******************************************* end web section ************************************* /
superphil06 0:e30c9ba95bd4 250
algrs 1:fbf189951c5e 251
superphil06 0:e30c9ba95bd4 252
superphil06 0:e30c9ba95bd4 253 //********************* can bus section initialisation *******************************************
superphil06 0:e30c9ba95bd4 254 //bCan_Active=true;// needed to lauchn CAN thread
superphil06 0:e30c9ba95bd4 255 //Thread CanThread(CAN_REC_THREAD);// create and launch can receiver thread
superphil06 0:e30c9ba95bd4 256 //********************* end can bus section *****************************************************
superphil06 0:e30c9ba95bd4 257
superphil06 0:e30c9ba95bd4 258
algrs 1:fbf189951c5e 259 while(cChoix!='q' and cChoix!='Q')
algrs 1:fbf189951c5e 260 {
algrs 1:fbf189951c5e 261 if(iMode==1)
algrs 1:fbf189951c5e 262 {
algrs 1:fbf189951c5e 263 pc.printf(" \n\r\n\r\t*** MODE AUTOMATIQUE ***\n\r");
algrs 1:fbf189951c5e 264 iAllow=1;
algrs 1:fbf189951c5e 265 Ticky.attach(&ModeAutoPWM,0.05);
algrs 1:fbf189951c5e 266 }
algrs 1:fbf189951c5e 267 else
algrs 1:fbf189951c5e 268 {
algrs 1:fbf189951c5e 269 pc.printf(" \n\r\n\r\t*** MODE MANUEL ***\n\r");
algrs 1:fbf189951c5e 270 iAllow=0;
algrs 1:fbf189951c5e 271 Ticky.detach();
algrs 1:fbf189951c5e 272 MyPLD.write(iConsignePWM);
algrs 1:fbf189951c5e 273 }
algrs 1:fbf189951c5e 274 pc.printf(" \t Veuillez selectionner une action : \n\r");
algrs 1:fbf189951c5e 275 pc.printf(" a: Changer de mode \n\r");
algrs 1:fbf189951c5e 276 pc.printf(" b: Calibrer \n\r");
algrs 1:fbf189951c5e 277 pc.printf(" c: Afficher dernieres valeurs de calibration\n\r");
algrs 1:fbf189951c5e 278 if(iMode==0) { pc.printf(" d: Saisir une consigne pwm \n\r"); }
algrs 1:fbf189951c5e 279 pc.printf(" e: Afficher Vitesse\n\r");
algrs 1:fbf189951c5e 280 pc.printf(" f: Lire PLD\n\r");
algrs 1:fbf189951c5e 281 pc.printf(" g: Changer limite bridage\n\r");
algrs 1:fbf189951c5e 282 pc.printf(" h: Remettre a 0 le kilometrage partiel\n\r");
algrs 1:fbf189951c5e 283 pc.printf(" q: Quitter \n\r");
algrs 1:fbf189951c5e 284
algrs 1:fbf189951c5e 285 /************* multithreading : main thread need to sleep in order to allow web response */
algrs 1:fbf189951c5e 286 while (pc.readable()==0) { // determine if char availabler
algrs 1:fbf189951c5e 287 Thread::wait(10); // wait 10 until char available on serial input
algrs 1:fbf189951c5e 288 }
algrs 1:fbf189951c5e 289 /************* end of main thread sleep ****************/
algrs 1:fbf189951c5e 290
algrs 1:fbf189951c5e 291
algrs 1:fbf189951c5e 292 pc.scanf("%c",&cChoix);
algrs 1:fbf189951c5e 293 printf("\n\r");
algrs 1:fbf189951c5e 294 switch (cChoix)
algrs 1:fbf189951c5e 295 {
algrs 1:fbf189951c5e 296 case 'a':
algrs 1:fbf189951c5e 297 iMode=!iMode;
algrs 1:fbf189951c5e 298 Ticky.detach();
algrs 1:fbf189951c5e 299 iConsignePWM=0;
algrs 1:fbf189951c5e 300 MyPLD.write(iConsignePWM);
algrs 1:fbf189951c5e 301 break;
algrs 1:fbf189951c5e 302 case 'b':
algrs 1:fbf189951c5e 303 iConsignePWM=0;
algrs 1:fbf189951c5e 304 MyPLD.write(iConsignePWM);
algrs 1:fbf189951c5e 305 Ticky.detach();
algrs 1:fbf189951c5e 306
algrs 1:fbf189951c5e 307 pc.printf("\n\r MODE DE CALIBRATION ! \n\r");
algrs 1:fbf189951c5e 308 pc.printf("MAINTENEZ LA POIGNEE AU MAX PENDANT 3 SECONDES : \n\r");
algrs 1:fbf189951c5e 309 pc.printf(" 1.. "); wait(1);pc.printf(" 2.. ");wait(1);pc.printf(" 3.. ");wait(1);
algrs 1:fbf189951c5e 310 fPoigneeMax=AINPOIGNEE.read()*100;fPoigneeMax=(int)fPoigneeMax;fPoigneeMax=fPoigneeMax/100;pc.printf("\t %g \n\r",fPoigneeMax);
algrs 1:fbf189951c5e 311 pc.printf("MAINTENEZ LA POIGNEE AU MIN PENDANT 3 SECONDES : \n\r");
algrs 1:fbf189951c5e 312 pc.printf(" 1.. "); wait(1);pc.printf(" 2.. ");wait(1);pc.printf(" 3.. ");wait(1);
algrs 1:fbf189951c5e 313 fPoigneeMin=AINPOIGNEE.read()*100;fPoigneeMin=(int)fPoigneeMin;fPoigneeMin=fPoigneeMin/100;pc.printf("\t %g \n\r",fPoigneeMin);
algrs 1:fbf189951c5e 314 pc.printf("ECRITURE EN MEMOIRE ... \n\r");
algrs 1:fbf189951c5e 315 //ecriture du fichier
algrs 1:fbf189951c5e 316 SauvegarderFichier();
algrs 1:fbf189951c5e 317 Ticky.attach(&ModeAutoPWM,0.01);
algrs 1:fbf189951c5e 318 //fin de l'ecriture du fichier
algrs 1:fbf189951c5e 319 pc.printf("FIN DU MODE DE CALIBRATION ! \n\r");
algrs 1:fbf189951c5e 320 break;
algrs 1:fbf189951c5e 321 case 'c':
algrs 1:fbf189951c5e 322 pc.printf("\n\r\t Valeurs de calibration : \t MIN=%.2f \tMAX=%.2f \n\r",fPoigneeMin,fPoigneeMax);
algrs 1:fbf189951c5e 323 break;
algrs 1:fbf189951c5e 324 case 'd':
algrs 1:fbf189951c5e 325 if(iMode==0)
algrs 1:fbf189951c5e 326 {
algrs 1:fbf189951c5e 327 iAllow=0;
algrs 1:fbf189951c5e 328 Ticky.detach();
algrs 1:fbf189951c5e 329 iConsignePWM=0;
algrs 1:fbf189951c5e 330 pc.printf("\n\r\t MODE DE SAISIE DE CONSIGNE PWM\n\r");
algrs 1:fbf189951c5e 331 pc.printf("ENTREE DE LA CONSIGNE ...\n\r(valeur entiere entre 0 et 255)\n\r");
algrs 1:fbf189951c5e 332 pc.scanf("%d",&iConsignePWM);
algrs 1:fbf189951c5e 333 MyPLD.write(iConsignePWM);
algrs 1:fbf189951c5e 334 pc.printf("CONSIGNE ENREGISTREE ! : %d\n\r",iConsignePWM);
algrs 1:fbf189951c5e 335 pc.printf("FIN DU MODE SAISIE !\n\r\n\r");
algrs 1:fbf189951c5e 336 Ticky.detach();
algrs 1:fbf189951c5e 337 }
algrs 1:fbf189951c5e 338
algrs 1:fbf189951c5e 339 break;
algrs 1:fbf189951c5e 340 case 'e':
algrs 1:fbf189951c5e 341
algrs 1:fbf189951c5e 342 pc.printf("\n\r\n\r Vitesse = %.2F km/h",fVitesse/1000);
algrs 1:fbf189951c5e 343 pc.printf("\n\r Vitesse = %.2F m/s\n\r",fVitesse/3600);
algrs 1:fbf189951c5e 344 pc.printf("\n\r Bridage : %g km/h\n\r",fLimiteBridage);
algrs 1:fbf189951c5e 345 pc.printf("\n\r Kilometres parcourus (total): %.3f km\n\r",(((iCompteurHallTotal/48)*CirconferenceRoue)/1000));
algrs 1:fbf189951c5e 346 pc.printf("\n\r Kilometres parcourus (partiel): %.3f km\n\r",(((iCompteurHallPartiel/48)*CirconferenceRoue)/1000));
algrs 1:fbf189951c5e 347
algrs 1:fbf189951c5e 348 break;
algrs 1:fbf189951c5e 349 case 'f':
algrs 1:fbf189951c5e 350 LecturePLD();
algrs 1:fbf189951c5e 351 //pc.printf("\n\r\t Valeur de PLD en int : %d \n\r",MyPLD.read());
algrs 1:fbf189951c5e 352
algrs 1:fbf189951c5e 353 if(iBit3==1){pc.printf("\n\r PAS DE SURCHARGE COURRANT ");} else{pc.printf("\n\r SURCHARGE COURRANT ");}
algrs 1:fbf189951c5e 354 if(iBit5==1){pc.printf("\n\r Frein INACTIF ");} else{pc.printf("\n\r Frein ACTIF ");}
algrs 1:fbf189951c5e 355 if(iBit4==1){pc.printf("\n\r PAS D'ERREUR CONVERTISSEUR ");} else{pc.printf("\n\r ERREUR CONVERTISSEUR ");}
algrs 1:fbf189951c5e 356 if(iBit3==1){pc.printf("\n\r Direction AVANT ");} else{pc.printf("\n\r Direction ARRIERE ");}
algrs 1:fbf189951c5e 357 /*
algrs 1:fbf189951c5e 358 pc.printf("\n\r BIT 2 : %d HALL C ",iBit2);
algrs 1:fbf189951c5e 359 pc.printf("\n\r BIT 1 : %d HALL B ",iBit1);
algrs 1:fbf189951c5e 360 pc.printf("\n\r BIT 0 : %d HALL A ",iBit0);
algrs 1:fbf189951c5e 361 */
algrs 1:fbf189951c5e 362 pc.printf("\n\r SECTEUR HALL : %d\n\r",iBit0*1+iBit1*2+iBit2*4);
algrs 1:fbf189951c5e 363 break;
algrs 1:fbf189951c5e 364 case 'g':
algrs 1:fbf189951c5e 365 pc.printf("\n\r Veuillez entrer une nouvelle valeur de limite bridage : \n\r");
algrs 1:fbf189951c5e 366 scanf("%g",&fLimiteBridage);
algrs 1:fbf189951c5e 367
algrs 1:fbf189951c5e 368 SauvegarderFichier();
algrs 1:fbf189951c5e 369 Ticky.attach(&ModeAutoPWM,0.01);
algrs 1:fbf189951c5e 370 //fin de l'ecriture du fichier
algrs 1:fbf189951c5e 371
algrs 1:fbf189951c5e 372 break;
algrs 1:fbf189951c5e 373 case 'h':
algrs 1:fbf189951c5e 374 printf("\n\rRemise a 0 ... ");iCompteurHallPartiel=0;printf("Fait !\n\r");
algrs 1:fbf189951c5e 375 break;
algrs 1:fbf189951c5e 376 case 'q':
algrs 1:fbf189951c5e 377 iConsignePWM=0;
algrs 1:fbf189951c5e 378 MyPLD.write(iConsignePWM);
algrs 1:fbf189951c5e 379 Ticky.detach();
algrs 1:fbf189951c5e 380 SauvegarderFichier();
algrs 1:fbf189951c5e 381
algrs 1:fbf189951c5e 382 break;
algrs 1:fbf189951c5e 383 }
algrs 1:fbf189951c5e 384 } // end while
algrs 1:fbf189951c5e 385
algrs 1:fbf189951c5e 386 //************** thread deinit *********************
algrs 1:fbf189951c5e 387 //DeInit_Web_Server();
algrs 1:fbf189951c5e 388 //bCan_Active=false;
algrs 1:fbf189951c5e 389 //CanThread=false;// close can received thread
algrs 1:fbf189951c5e 390 pc.printf("\n\r=== FIN DU PROGRAMME === \n\r");
superphil06 0:e30c9ba95bd4 391 } // end main