User Tools

Site Tools


en:pymlab

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
en:pymlab [2015/03/06 22:25] – created kakliken:pymlab [2017/12/14 23:43] – [ARM STM32 Python interpreter] ondra6ak
Line 34: Line 34:
   git checkout dev   git checkout dev
   sudo python setup.py develop   sudo python setup.py develop
- 
-===== Interactive Python shell  iPython ===== 
-  
-In Ubuntu we should install iPython by running   
-  sudo apt-get install ipython-notebook python-scipy python-numpy 
- 
-After that we should run iPython shell by 
-  ipython notebook --pylab inline 
- 
-This command execute iPython server an ussually opens the default internet browser window, which points to the server URL. 
  
 User usualy needs permissions to access the I²C and USB bus. Therefore user must be added to i2c group by: User usualy needs permissions to access the I²C and USB bus. Therefore user must be added to i2c group by:
Line 56: Line 46:
 {{ :cs:sw:flowchart.png?direct&500 |}} {{ :cs:sw:flowchart.png?direct&500 |}}
  
-===== ARM STM32 Python interpreter ===== +===== ARM STM32 Python interpreter ==== 
-  + 
-Pyhthon interpreter should be useful if pymlab would be used at [[cs:stm32f10xrxt|ARM]] microcontrolers.  +The latest version of Pymlab is compatible with the [[https://micropython.org/|MicroPython]] interpretation of Python. Testing has been performed on the [[http://docs.micropython.org/en/latest/pyboard/pyboard/quickref.html|Pyboard v1.0]] ([[http://www.st.com/en/microcontrollers/stm32f405rg.html|STM32F405RG]] processor) and [[https://github.com/micropython/micropython/tree/v1.9.3|version 1.9.3 of MicroPython]]. 
-One example of possible interpreter is [[http://code.google.com/p/python-on-a-chip/|Python on a chip]].+ 
 +=== Example === 
 + 
 +<file python main.py> 
 +import pymlab.config 
 + 
 +cfg = pymlab.config.Config(i2c={"device": "machine", "port": 1, "freq": 100000}, 
 +                           bus=[{"name": "altimet", "type": "altimet01"}, 
 +                                {"name": "light", "type": "isl03"}, 
 +                                {"name": "sht", "type": "sht31"}]) 
 +cfg.initialize() 
 + 
 +altimet = cfg.get_device("altimet"
 +altimet.route() 
 +light = cfg.get_device("light"
 +light.config(0x0000) 
 +sht = cfg.get_device("sht"
 +sht.soft_reset() 
 + 
 +t1, p = altimet.get_tp() 
 +l = light.get_lux() 
 +t2, h = sht.get_TempHum() 
 +</file> 
 + 
 +=== Tips & Tricks === 
 + 
 +Resources (Flash and RAM) embedded systems are typically quite limited, the whole pymlab module does not fit to the flash memory available on the [[http://docs.micropython.org/en/latest/pyboard/pyboard/quickref.html|Pyboard]] for example
 + 
 +Fortunately MicroPython provides cross compiler that allows us to compile the source code to bytecode and therefore reduce the RAM and flash usage. 
 + 
 +Version of the cross compiler must match the version of MicroPython running on your board. If in doubt just compile and flash your board with firmware compiled from the same branch of the [[https://github.com/micropython/micropython#the-stm32-version|MicroPython repository]] as the cross compiler, instruction can be found at [[https://github.com/micropython/micropython#the-stm32-version|https://github.com/micropython/micropython#the-stm32-version]]. 
 + 
 +<code sh> 
 +$ git clone https://github.com/micropython/micropython 
 +$ cd micropython 
 +$ git checkout UPY_VERSION # This is very important! 
 +$ # Optional compiling and flashing of the firmware 
 +$ cd mpy-cross 
 +$ make 
 +</code> 
 + 
 +In  Makefile at [[https://github.com/MLAB-project/pymlab/blob/master/src/pymlab/Makefile|pymlab/src/pymlab/Makefile]] edit the path to the cross compiler, mountpoint of the flash memory and devices you wish to use as all drivers are still to much for the limited space on the PyboardThe just type 
 + 
 +  make deploy
  
 +and you are good to go.
en/pymlab.txt · Last modified: 2017/12/14 23:43 (external edit)