The team at LeafLabs was looking for something cool to do with their new ARM development board. [AJ] asked if anyone had ever played around with Python, so [Dave] cooked up an implementation of PyMite and put it on a Maple board. While the writeup is only about blinking a LED with a microcontroller, they’re doing it with Python, interactively, and at runtime.
The build uses the Maple Native board the team is developing. The board has a 32-bit ARM chip with 1 Meg of RAM – more than enough horsepower to run PyMite. The tutorial for putting PyMite on a Maple is up on the LeafLabs wiki.
PyMite is theoretically able to control every pin on the Maple Native and do just about everything a regular Python distro can do. The LeafLabs team is still working on the necessary libraries for their board (although we don’t see anything on the Google code page), so right now only blinking the LED is supported. Still, it’s pretty cool to have Python in your pocket.
Hi Brian,
Marti from LeafLabs here. Just a quick correction — while the Maple Native has 64 KB of on-chip RAM, it also has a 1 MB external SRAM chip built-in. The libraries are configured to work with it seamlessly, and the heap lives on it by default.
The libmaple code is being updated on their GitHub repository with Google Code only being used for bug tracking.
Just last week I thought to myself “Wow. How cool would it be if LeafLabs had PyMite running on one of their boards.”
And now the do! Awesome!
The Maple Native actually has 1MB of RAM — not 64kb. It’s a very impressive board. I’ve been playing with mine for a week or so now.
The article is correct, the board’s ARM processor does have 64kB of SRAM, but you are also correct that the Native has 1MB of external RAM as well.
Right, but usually when you say how much RAM something has, you mean to say “How much RAM does this board allow me to use?” and the answer to that question is over 1MB. :) People might be more interested in the Native if they knew it had so much headroom.
I’ve never been a big fan of Python. the IDLE interpreter was terrible, (or at least was when I was using it in 2008/9) and the code just seems sloppy and disjointed.
Obviously, however, I am in the minority, as people seem as obsessed with putting Python in places where it wasn’t as they do with Linux.
So, congrats to the team at LeafLabs.
Well written python usually seems pretty elegant to me.
Well written perl regex looks elegant to me.
But then I’ve been known to be completely batty.
No one uses IDLE (use Eclipse/PyDev instead) and it’s easy enough not to write sloppy code if you dono’t want to…
Sidebar: The new Raspberry Pi PC’s OS is currently planned to boot into a full Python shell. The current specs will include 128-256 megs of memory.
http://elinux.org/RaspberryPiBoard#Provisional_specification
classes work too. everything except exceptions.
I don’t see all this “python on a microcontroller” thing.
For one, I tend to think of python as a high level language designed to ease software development at the expense of resources needed to run it, while microcontrollers are rather those “not really cpu” things that let you -and require- to optimize resource utilization.
I mean, even C is quite the overkill for microcontrollers, if it wasn’t for the fact that coding in asm is such a PITA.
Uh, assembly being a pain is literally the reason higher level* programming languages exist. You basically just said “I don’t understand why people use python” then explained the reason people use python. Why waste time doing low level bit wrangling when your project doesn’t require it?
*Relative to assembly–I’m including both C and Python under this umbrella.
Todays micro-controller was yesterdays processor (minus a bunch of OS related hw support) in terms of raw MIPS – and a 32bit 72MHz machine is plenty to run a thin python repl adapted for the purpose.
But of course you’re right, the purpose of MCU’s is more than being cheap. They can meet real time constraints and interface with the real world in a way big OS-running systems cant.
But the fact is that you only need that 72MHz, or meet that 1us deadline some of the time. Why not hand the rest of the nonsense over to something like python?
You could develop you entire application as entirely event driven interrupt routines, in assembler, and give the main loop over to python for user i/o (always slow), debugging, config, system monitoring, etc. etc. etc.
String manipulation is a particularly good example of something I almost never need to do quickly, is really painful in C, and trivial in python.
And you if you run out of resources? well, you could nix python and drop back into asm, or you could just wait 6 months for the next chip generation. MCUs are still being made on old process tech, and they have a lot more room to get faster. Just check out the stm32F4s!
Let us put modern computing power in perspective. In the late 70s DEC introduced the VAX 11/780. It was a super mini computer and supported many users at once using timesharing. It ran VMS and sometimes Unix. It was as fast as the IBM 360 mainframe and was a revolution at the time.
It ran at 5mhz and supported up to 8 mb of ram.
In other words we have more computing power than we know what do with so you might as well use some of that power to cut development time.
Heck that Maple board is more powerful than the first computer I ran CAD on. It blows away the IBM AT and PDP-11. Their is no reason why you couldn’t run lisp on it if you wanted.
Hi, nice work.
But it would be really nice to make a script than send it to the module and run it.
The module Telit gm-862 as a inside python script interpreter, all u have to do is write the script, compile than upload to the module. It can do lots of functions including IO’s control, serial, i2s, can control inside gsm and gps Module RAM is 1,9Mb and 1,2Mb for python usage.
An ideia like that in this STM32 would be a really nice inovation.
Python is high level and realy easy, so the ideia of running it on a microcontroller is great.
Regards