Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed bloc_io mbed-rtos html EthernetInterface
Revision 4:08e917c15d87, committed 2019-12-03
- Comitter:
- ragas
- Date:
- Tue Dec 03 08:47:42 2019 +0000
- Parent:
- 3:a659bef8f6a5
- Commit message:
- cefdzcd;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Oct 22 14:46:28 2019 +0000
+++ b/main.cpp Tue Dec 03 08:47:42 2019 +0000
@@ -17,6 +17,7 @@
Serial pc(USBTX, USBRX); // tx, rx
// Top_Hall Pin
int valref=0 ;//rajout
+int val=0;
float min ;
float max;
int tout;
@@ -65,8 +66,22 @@
Ticker guidon;
+//************************************************************
+InterruptIn tphall (p22);
+int lire;
+float vitesse;
+int cpthall=0;
+void cpt(void);
+void vit (void);
+Ticker ragas;
+float ray=0.20;
+float Bride;
+//************************************************************
+
+
void task1(void);
int mode ;
+int kirito;
//************ local function prototypes *******************
@@ -140,12 +155,12 @@
MyPLD.write(0);
valid.write(1);
float gaz;
- mode=0;
+ mode=0;// mode auto
FILE* pfile = fopen ("/local/ragas.txt","r");
if(pfile!=NULL) {
- fscanf(pfile,"min=%f max=%f", &min,&max);
- pc.printf("\n min=%f max=%f", min,max);
+ fscanf(pfile,"min=%f max=%f bride=%f", &min,&max,&Bride);
+ pc.printf("\n min=%f max=%f bride=%f", min,max,Bride);
} else {
pc.printf("erreur");
}
@@ -155,6 +170,15 @@
+ //***************************************************************************************
+ tphall.rise(&cpt);
+ ragas.attach(&vit,0.1);
+ //****************************************************************************************
+
+
+
+
+
//***************************************** web section ********************************************/
//Init_Web_Server(&CGI_Function); // create and initialize tcp server socket and pass function pointer to local CGI function
//Thread WebThread(Web_Server_Thread);// create and launch web server thread
@@ -181,8 +205,9 @@
pc.printf(" a:saisie consigne pwm \r\n");
pc.printf(" c:lecture interne \r\n");
pc.printf(" b:calibration \r\n");
-
+ pc.printf(" v:vitesse\r\n");
pc.printf(" m:mode \r\n");
+ pc.printf(" w:valeur bride \r\n");
pc.printf(" q:quitter \r\n");
/************* multithreading : main thread need to sleep in order to allow web response */
@@ -198,7 +223,7 @@
printf("donne moi une valeur de pwmref entre 0 et 255:");
scanf("%d",&valref);
if(valref<=255) {
- MyPLD.write(valref);
+ //MyPLD.write(valref);
} else {
valref=0;
//MyPLD.write(valref);
@@ -217,13 +242,8 @@
getchar();
max=poignee.read();
printf("max%f\n\r",max);
- FILE* pfile = fopen ("/local/ragas.txt","w");
- if(pfile!=NULL)
- fprintf(pfile,"min=%f max=%f", min,max);
- fclose(pfile); // close file
+
break;
-
-
case 'm':
do {
printf("choisissez un mode :0 pour automatique et 1 pour manuel");
@@ -231,10 +251,27 @@
} while(mode<0 || mode >1);
break ;
case 'q':
+ FILE* pfile = fopen ("/local/ragas.txt","w");
+ if(pfile!=NULL)
+ fprintf(pfile,"min=%f max=%f bride=%f", min,max,Bride);
+ fclose(pfile); // close file
valid.write(0);
MyPLD.write(0);
guidon.detach();
break;
+
+ case 'v':
+ printf ("vitesse :%g m/s \n",vitesse);
+ printf ("vitesse :%g km/h \n",vitesse*3.6);
+ printf ("vitesse :%g tr/min \n",(vitesse*60)/(2*3.14159265359*ray));
+ break ;
+ case 'w':
+ do {
+ printf("choisissez une valeur de bride");
+ scanf("%g",&Bride);
+ } while(Bride<0 || Bride >38.9);
+ break ;
+
/* case 'q':
frein.read();
@@ -301,23 +338,57 @@
FLTA = tout & 16;
frein = tout &32;
overcurrent = tout &64;
-
- int val=0;
+
+
gaz=poignee.read();
float valPoignee=((255/(max-min))*gaz)-(min*(255)/(max-min));
if(mode==0) { //mode auto
if(frein==0) { //frein actif
val=0;
} else { //frein inactif
- if(val<valPoignee) { //incrémentation
- val=val+1;
- } else { //bonne valeur
- val=valPoignee;
- }
+
+ if(val<valPoignee) { //incrémentation
+ val=val+1;
+ } else { //bonne valeur
+ val=valPoignee;
+ }
+ if(Bride<vitesse*3.6){
+ val=val-1;
+ }
+
+ if(val<0) {
+ val=0;
+ }/*
+ if(val>valPoignee) { //décrémentation
+ val=val-1;
+ } else { //bonne valeur
+ val=valPoignee;
+ }
+ if(val>255) {
+ val=255;
+ }
+ if(val<0) {
+ val=0;
+ }
+ kirito=val; //valeur actuel de la pwm dans une variable globale
+ } else {
+ MyPLD.write(kirito);
+ }*/
}
} else { //mode manuel
val=valref; //valeurs dans le case "a"
}
+ //val=127;
MyPLD.write(val);
}
+void cpt (void)
+{
+ cpthall++;
+}
+void vit (void)
+{
+ lire=cpthall;
+ cpthall=0;
+ vitesse=(((2*3.14159265359*ray)/(6*8))*lire)/0.1;
+}