What is lowest cost micro to micropy with? (control looping A2D, timers)

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Sometimes you want to go back to the low level way...

Post by jgriessen » Thu Mar 10, 2016 3:52 pm

HLLs like python are marvelous for development. The chips are cheap enough you can ship an easy development
platform right in the product. $5 MCUs and what not.

But as I shop for parts for a system I am designing, a "switching power supply for ultra low power designers experimental coding playground", I see 50 cent MCUs and what not that are 32 bit ARM also. It makes one wonder, "What if I could develop with micropython, then offer a tweakable product as usual plus a non-tweakable product for $3 less costs, $3 less price, way higher sales volume?

IOW, what would it take to have micropython emit c code for everything, the developed code and all the linked micropython library code used to make a compilation? Then, if I made code for one of the constrained platforms like the F401, where all the program is "baked in" with the firmware, and no SD cards, the C code for that might apply to a cortex M0 with few modifications. That code might use very small amounts of RAM and fit on a ATSAMD09C13A-SSUT with 12 IO's 14 pins total and a price tag of $0.50!

John Griessen
John Griessen blog.kitmatic.com

Damien
Site Admin
Posts: 634
Joined: Mon Dec 09, 2013 5:02 pm

Re: Sometimes you want to go back to the low level way...

Post by Damien » Thu Mar 10, 2016 10:04 pm

jgriessen wrote: IOW, what would it take to have micropython emit c code for everything, the developed code and all the linked micropython library code used to make a compilation? Then, if I made code for one of the constrained platforms like the F401, where all the program is "baked in" with the firmware, and no SD cards, the C code for that might apply to a cortex M0 with few modifications. That code might use very small amounts of RAM and fit on a ATSAMD09C13A-SSUT with 12 IO's 14 pins total and a price tag of $0.50!
The pieces of the puzzle to do this are starting to fall into place, but are not fully there just yet. You want frozen bytecode, maybe even frozen native code, since that would emit machine code for everything. With frozen code you can remove the compiler, reducing binary size and maximum required heap. In fact, if your entire code is frozen then you can run with almost zero heap (might need a few hundred bytes to initialise the global dictionaries). You don't even need the GC, you can replace it with an "immortal heap" allocator (I've done some work in this direction with the ESA project) which again saves flash and RAM.

The minimal port with frozen bytecode and the compiler removed takes up about 55k of flash. So I'd say you could actually have a working MicroPython VM+runtime (but no compiler), and frozen scripts, all within 64k. If you found a chip that had 64k flash and 4k RAM (8k would be better) then I dare say that would be enough for "production code".

55k includes a lot of bloated string processing functions which you probably don't need, maybe could get it down another 10k by removing them. And then if you went further to remove all unnecessary object methods, you could get the code size even smaller. But I really doubt you could get it under 32k. Might be fun to try though :)

The SAMD09C13 has only 8k of flash, and 4k of RAM. That's probably enough RAM but definitely not enough flash. Try something with 64k flash and you are getting realistic :)

QuaakHaak
Posts: 8
Joined: Wed May 18, 2016 4:14 am

Re: What is lowest cost micro to micropy with? (control looping A2D, timers)

Post by QuaakHaak » Wed May 18, 2016 4:54 am

Hi Dave,

I read your recent commit on the NUCLEO-F411RE, that was good to see as I am trying to decide what STM32F4*-based board to get. Currently I have an STM32F1 & 3 which I have been using (Trying to use) with Mecrisp-Stellaris Forth. However I found the MicroPython project this morning and I am very interested, especially since I want to export data from the STM32F* device into a web service(s) using Python.

Is the NUCLEO-F411RE board a good choice for a ARM Cortex M4 product or should I look at a straight STM32F4-based device like a DISCO? The other issue that I thought was interesting with the Nucleo, was the able to interact with Arduino Unos, of which I have several.

Just after your thoughts (Or anyone elses) based on your experiences with MicroPython so far, and I will not hold you to any comments 8-)

TIA, Quaak.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: What is lowest cost micro to micropy with? (control looping A2D, timers)

Post by pfalcon » Wed May 18, 2016 11:31 am

QuaakHaak, please keep in mind that MicroPython has the best support for features of, has the best capabilities and ease of use on, and overall works best with - the original PyBoard, which was specifically made to enable and use the full power of MicroPython.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

QuaakHaak
Posts: 8
Joined: Wed May 18, 2016 4:14 am

Re: What is lowest cost micro to micropy with? (control looping A2D, timers)

Post by QuaakHaak » Wed May 18, 2016 9:54 pm

Hi Pfalcon,

I totally agree however cost becomes a significant factor in you live in Australia or New Zealand, as I do.

The "Pyboard" can be sourced from Australia (the closest seller) to New Zealand with current prices being AUD $58.13 & $87.23 (Yes, you read that correctly). Add on AUD $10.00 for Shipping then do the currency conversion, and what was a GDP $23.33 device in the UK becomes at least an NZD $73.10 or $104.32 device way out here.

That is my point, but I certainly get yours, Quaak.

User avatar
dhylands
Posts: 3415
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: What is lowest cost micro to micropy with? (control looping A2D, timers)

Post by dhylands » Thu May 19, 2016 2:15 am

QuaakHaak wrote:Hi Dave,

I read your recent commit on the NUCLEO-F411RE, that was good to see as I am trying to decide what STM32F4*-based board to get. Currently I have an STM32F1 & 3 which I have been using (Trying to use) with Mecrisp-Stellaris Forth. However I found the MicroPython project this morning and I am very interested, especially since I want to export data from the STM32F* device into a web service(s) using Python.

Is the NUCLEO-F411RE board a good choice for a ARM Cortex M4 product or should I look at a straight STM32F4-based device like a DISCO? The other issue that I thought was interesting with the Nucleo, was the able to interact with Arduino Unos, of which I have several.

Just after your thoughts (Or anyone elses) based on your experiences with MicroPython so far, and I will not hold you to any comments 8-)

TIA, Quaak.
Whether you consider the 411 nucleo to be a good choice really depends on what you're trying to do with it. The nucleo board are inexpensive, so if size isn't a factor then they're definitely good value for the money if they meet your needs.

User avatar
pythoncoder
Posts: 4347
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: What is lowest cost micro to micropy with? (control looping A2D, timers)

Post by pythoncoder » Thu May 19, 2016 4:17 am

QuaakHaak wrote:The "Pyboard" can be sourced from Australia (the closest seller) to New Zealand with current prices being AUD $58.13 & $87.23 (Yes, you read that correctly). Add on AUD $10.00 for Shipping then do the currency conversion, and what was a GDP $23.33 device in the UK becomes at least an NZD $73.10 or $104.32 device way out here.
A quick look on the web suggests that one of the official distributors Little Bird electronics in Australia has the Pyboard V1 at AUD $45 which is £22 (plus shipping). Perhaps I should move to Australia... ;)
Peter Hinch

User avatar
deshipu
Posts: 1364
Joined: Thu May 28, 2015 5:54 pm

Re: What is lowest cost micro to micropy with? (control looping A2D, timers)

Post by deshipu » Thu May 19, 2016 8:36 am

There is always the option of using ESP8266 and an external ADC, for instance, over I2C. There are cheap and easy to use i2c ADC modules out there, with built-in op amps and 12 bit precision.

QuaakHaak
Posts: 8
Joined: Wed May 18, 2016 4:14 am

Re: What is lowest cost micro to micropy with? (control looping A2D, timers)

Post by QuaakHaak » Sat May 21, 2016 7:03 am

A quick look on the web suggests that one of the official distributors Little Bird electronics in Australia has the Pyboard V1 at AUD $45 which is £22 (plus shipping). Perhaps I should move to Australia... ;)
... yeah but do not move to New Zealand if you think the prices are better. I bit the bullet, and purchased a Pyboard V1.1 (good idea from "pfalcon") from the UK store, total is NZD $69.44 including tracked shipping. It'd be likely more if I purchased it from the "cheaper" AU store.

Sorry but AUD $87.23 for the Pyboard V1.1 is daylight robbery, nothing more.

Post Reply