Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Micro-python

1,538 views

Published on

Micro-python - PythonMadrid - 10 December 2014

Published in: Engineering
  • Be the first to comment

Micro-python

  1. 1. Micro Python Python for microcontrollers Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om
  2. 2. Micro Python Python for microcontrollers About me Works at Carriots.com Sofware Developer Internet Of Things Platform Core platform developer Integration third-party hardware/systems/software Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om
  3. 3. Micro Python Python for microcontrollers “Micro Python was successfully funded via a Kickstarter campaign. The software is available to the public under the MIT open source license. ” micropython.org Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om
  4. 4. Micro Python Python for microcontrollers “Micro Python is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.” micropython.org Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om
  5. 5. Micro Python Python for microcontrollers “The Micro Python board is a small electronic circuit board that runs Micro Python on the bare metal, and gives you a low-level Python operating system that can be used to control all kinds of electronic projects.” micropython.org Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om
  6. 6. Micro Python Python for microcontrollers Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om
  7. 7. Micro Python Python for microcontrollers Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om Micro Python ● Full implementation of Python 3 grammar. Cpython 3.4 (no batteries) ● Implements lexer, parse, compiler, vm and runtime. ● Execute files or REPL. ● Python code is compiled to byte code that run in vm. ● Storing objects in efficient ways. ● Decorator can compiled to native code. 2 time faster than byte code. ● Memory is managed using a simple and fast mark-sweep garbage collector.
  8. 8. Micro Python Python for microcontrollers Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om Micro Python Board ● Based on the STM32F405 microcontroller. ● The microcontroller is clocked at 168MHz. ● 1MiB flash. ● 192KiB RAM. ● The board measures 33x40 mm. ● USB interface. ● Micro SD slot. ● 2 LEDs, a switch, a real-time clock, an accelerometer, and 30 general purpose I/O pins.
  9. 9. Micro Python Python for microcontrollers Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om Micro Python as a "mini Python operating system" ● Checks for a local filesystem on the flash. ● Checks for /boot.py. ● Runs /boot.py to configure USB and other low-level parameters that can't be changed without a reset. ● The main Python script is run if it exists. Default is /src/main.py. ● If the main script doesn't exist, or exits, REPL (read- evaluate-print-loop) mode is entered.
  10. 10. Micro Python Python for microcontrollers Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om Python standard libraries ● cmath – mathematical functions for complex numbers ● gc – control the garbage collector ● math – mathematical functions ● os – basic “operating system” services ● select – wait for events on a set of streams ● struct – pack and unpack primitive data types ● sys – system specific functions ● time – time related functions additional libs in https://github.com/micropython/micropython-lib
  11. 11. Micro Python Python for microcontrollers Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om Python standard libraries “micro-ified” ● ubinascii – binary/ASCII conversions ● uhashlib – hashing algorithm ● uheapq – heap queue algorithm ● ujson – JSON encoding and decoding ● ure – regular expressions ● usocket – socket module ● uzlib – zlib decompression
  12. 12. Micro Python Python for microcontrollers Samuel de Ancos Martín @sdeancos sdeancos@gmail.com http://deancos.om Libraries specific to the pyboard ● pyb ● Network: CC3K (wifi), WIZNET5K (ethernet)

×