Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ em
Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ emos Conclusion Python sur microcontrˆ oleur Un rˆ eve ? Matthieu Falce Inria Lille – Equipe Mjolnir April 22, 2015 Les images appartiennent ` a leurs auteurs respectifs Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ emos Conclusion Plan 1 Projet 2 Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 3 MicroPython Avantages Inconv´ enients 4 D´ emos Flashage Lecture I2C Lecture port analogique Cr´ eation d’une souris 5 Conclusion Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ emos Conclusion Projet Touchit Figure : Stimtac Figure : Stimtac transparent • Cr´ eation d’un dispositif de stimulation tactile • Portage du dispositif sur une autre cat´ egorie de microcontrˆ oleurs • Ajout d’un capteur capacitif pour la d´ etection des doigts Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ emos Conclusion Projet Touchit Figure : Capteur capacitif Figure : STM32F4 discovery Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion Python • langage de programmation haut niveau • syntaxe claire et facile Example : for i in range(10): print(str(i) + " - Python YEAH!") Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion Un microcontrˆ oleur ? ”Un ordinateur en miniature pour int´ eragir avec le monde r´ eel” Figure : Exemples de microcontrˆ oleurs Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion Arduino – AVR Atmel Figure : Arduino Uno Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion Arduino – AVR Atmel Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion Arduino – AVR Atmel Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion Arduino – AVR Atmel // source: blink example arduino int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay(1000); digitalWrite(led, LOW); delay(1000); } Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion STM32 Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion STM32 Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion STM32 • Utilis´ e dans l’industrie • Bien plus puissant que les arduino • Peut utiliser un OS temps r´ eel • Possibilit´ e de d´ ebugage Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion STM32 • Utilis´ e dans l’industrie • Bien plus puissant que les arduino • Peut utiliser un OS temps r´ eel • Possibilit´ e de d´ ebugage Avec de grands pouvoirs viennent de grandes responsabilit´ es... Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion STM32 // source: http://pramode.net/fosstronics/minimal-c-program.txt #define GPIOB_CRH (*((volatile unsigned long*)(0x40010c00 + 0x4))) #define GPIOB_BSRR (*((volatile unsigned long*)(0x40010c00 + 0x10))) #define RCC_APB2ENR (*((volatile unsigned long*)(0x40021000 + 0x018))) __asm__(".word 0x20001000"); __asm__(".word main"); main() { unsigned int c = 0; RCC_APB2ENR = (1 << 3); GPIOB_CRH = 0x44444414; while(1) { GPIOB_BSRR = (1 << 9); // ON for(c = 0; c < 100000; c++); GPIOB_BSRR = (1 << 25); // OFF for(c = 0; c < 100000; c++); } } Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion STM32 // source: http://sigalrm.blogspot.fr/2012/09/stm32f4-discovery-quick-start-guide.html #include "stm32f4xx_rcc.h" #include "stm32f4xx_gpio.h" GPIO_InitTypeDef GPIO_InitStructure; int main(void) { /* GPIOG Periph clock enable */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); /* Configure PD12 in output mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOD, &GPIO_InitStructure); /* Set PD12 high */ GPIO_SetBits(GPIOD, GPIO_Pin_12); /* Do nothing */ while (1) { } } Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion “ Les psychiatres le d´ etestent. Cet homme a d´ ecouvert un secret simple pour ne pas devenir fou en utilisant la STM32. — Pr John Doe Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte Python Un microcontrˆ oleur ? Arduino – AVR Atmel STM32 MicroPython D´ emos Conclusion R´ eduire le ticket d’entr´ ee ? Utilisation de langages haut niveau • STM32F4 • Python (MicroPython) • STM32F1 • Javascript (espruino) • Lua (eLua) Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython Avantages Inconv´ enients D´ emos Conclusion MicroPython • Python 3.4 • La plupart des fonctionnalit´ es support´ ees (asyncio, d´ ecorateurs, POO) • Interpr´ eteur • Code lanc´ e au d´ emarrage • Communaut´ e tr` es active Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython Avantages Inconv´ enients D´ emos Conclusion MicroPython import pyb led1 = pyb.LED(1) while True: led1.toggle() pyb.delay(1000) Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython Avantages Inconv´ enients D´ emos Conclusion MicroPython import pyb led1 = pyb.LED(1) while True: led1.toggle() pyb.delay(1000) Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython Avantages Inconv´ enients D´ emos Conclusion Le projet • Kickstarter lanc´ e par Damien George en 2013 • £97,803 r´ ecolt´ es • Pyboard (STM32F405) • Libres et disponibles sur github Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython Avantages Inconv´ enients D´ emos Conclusion Le projet • plus de 30 cartes vis´ ees • 5 ports fonctionnels actuellement • STMDiscovery, CEB40 Figure : STM32F405 Discovery Figure : CERB40 Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython Avantages Inconv´ enients D´ emos Conclusion MicroPython – Avantages • interpr´ eteur • utilise la syntaxe python 3.4 classique • modulable • possibilit´ e d’utiliser du code natif (optimis´ e) Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython Avantages Inconv´ enients D´ emos Conclusion MicroPython – Inconv´ enients • pas d’allocation de m´ emoire dans les interruptions • instabilit´ e (probl` emes de reboot, I2C instable) • vitesse • pas de threads (MAIS utilisation de select ou asynchrone) Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ emos Flashage Lecture I2C Lecture port analogique Cr´ eation d’une souris Conclusion Glossaire • HID: • Human Interaction Device • Donn´ ees en little endian • Norme USB • Descripteur : comment sont form´ es les messages • Report : les messages Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ emos Flashage Lecture I2C Lecture port analogique Cr´ eation d’une souris Conclusion D´ emos D´ emos sur le CERB40 • Flashage de MicroPython • Lecture d’un port analogique (joystick) • Cr´ eation d’une souris • Cr´ eation d’un joystick Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ emos Conclusion Conclusion Quelle place pour cet outil ? • Pas pour des applications critiques • Prototypage • D´ ecouverte des STM32 Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ emos Conclusion Conclusion Quelle place pour cet outil ? • Pas pour des applications critiques • Prototypage • D´ ecouverte des STM32 Python sur micro- contrˆ oleur Matthieu Falce Projet Contexte MicroPython D´ emos Conclusion uploads/Ingenierie_Lourd/ arduino-et-python-projet.pdf
Documents similaires










-
66
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Attribution requise- Détails
- Publié le Nov 18, 2021
- Catégorie Heavy Engineering/...
- Langue French
- Taille du fichier 4.0328MB