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.
main.cpp
00001 #include "mbed.h" 00002 00003 extern void Sauve_USB(float *,int ) ; 00004 extern Serial pc ; 00005 00006 #define FECH 20000 // Fréquence d'échantillonnage souhaitée 00007 // Maximum 40 kHz 00008 #define TAILLE_TAB (FECH/10) // Pour stocker 1/10 s du signal 00009 // Donc fmin signal = 10 Hz 00010 00011 Ticker acquisition_CAN ; 00012 AnalogIn entree(PC_3); // A2 connecteur Arduino 00013 DigitalIn button(USER_BUTTON); 00014 00015 float tab[TAILLE_TAB] ; 00016 00017 void acquisition() { 00018 static int i = 0 ; 00019 tab[i] = 3.3f*entree.read(); // Conversion en volts 00020 i++; 00021 if (i == TAILLE_TAB) i = 0 ; 00022 } 00023 00024 int main(void) 00025 { 00026 pc.printf("\033[2J"); // Sequence escape qui efface la console 00027 pc.printf("Acquisition d'un signal sur broche PC_3(A2)\n"); 00028 pc.printf("Et enregistrement sur clef USB\n"); 00029 pc.printf("Frequence d'echantillonnage actuelle = %d Hz\n",FECH); 00030 pc.printf("Veuillez connecter un signal sur cette broche \n"); 00031 pc.printf("Appuyez sur le bouton USER de la carte pour demarrer l'acquisition\n"); 00032 while (button.read() == 0) ; 00033 acquisition_CAN.attach_us(&acquisition,1000000/FECH); 00034 wait(0.2) ; // Attendre au moins 1/10 seconde pour remplir le buffer des échantillons prélevés sur PC_3 00035 acquisition_CAN.detach() ; // Stopper l'acquisition des échantillons 00036 Sauve_USB(tab,TAILLE_TAB); 00037 while(1) ; 00038 }
Generated on Fri Feb 17 2023 21:41:46 by
