Live data from Hacker News

CircuitPython – The easiest way to program microcontrollers

circuitpython.org

11–20 of 46 posts

Re: CircuitPython – The easiest way to program microcontrollers

#11
post #4

Earlier quoted context omitted.

What was the downside? Why only prototyping? I've not used a pico but other microcontrollers with c++ interfacing tools, and my thoughts are these things don't have interpreters onboard so the language choice is likely not that important. But I'm limited to TI boards.

In general with the the embedded Pythons, they are 2 or 3 orders of magnitude slower than C (big surprise) and they don't support all the hardware features. By necessity, they have a one-size-fits all approach that works fine for hobbyists but might not be sufficient for production. That all said, I love to bang out a prototype or one-off project with CircuitPython or MicroPython. Or Arduino if it makes sense.

See I'm surprised Python is not just a convenience that's ultimately transpiled before making its way to the MCU.

C++ is high level enough that I always assumed much of that work was already happening for microcontroller work.

Re: CircuitPython – The easiest way to program microcontrollers

#12
My suspicion is that this, and MicroPython, which it's based off, are designed for people who know Python, and are hesitant to learn another language, or expand their toolbox. Python is a great language in some domains. For example, numerical computing, web servers, and scripting.

Embedded programming is, unfortunately, only suitable to a handful of languages that can operate with high speed and low memory use. At this time, they're C, C++, Rust, Zig, and ADA.

For example, on my embedded projects, I use Python to handle the webite framework, and to generate filter coefficients using Scipy, and plot data with MPL. I use Rust for the firmware.

Re: CircuitPython – The easiest way to program microcontrollers

#13
post #10

How does it compare with MicroPython? In any case, can be good for PoC or similar things where your microcontroller is largely oversized for the application, but in practice you hardly can exploit your microcontroller's power using such a non-compiled high-level language. For a hobby project you can get a microcontroller that has 10x the actual power you need and use Python on it, but on an industrial scale it's not…

Being able to load extensions at run-time could be a pretty big advantage. Have "apps" you can install on the micro-controller.

>but in practice you hardly can exploit your microcontroller's power using such a non-compiled high-level language

With micropython you can mark a function to be compiled, or even write a function as inline-assembly. Like normal python develop quickly and optimize the expensive parts. Micropython makes it quite easy to optimize the expensive parts with the viper code emitter and inline-assembly options.

Re: CircuitPython – The easiest way to program microcontrollers

#14

My suspicion is that this, and MicroPython, which it's based off, are designed for people who know Python, and are hesitant to learn another language, or expand their toolbox. Python is a great language in some domains. For example, numerical computing, web servers, and scripting. Embedded programming is, unfortunately, only suitable to a handful of languages that can operate with high speed and low memory use. At th…

It's really quite nice to be able to telnet into a running micro-controller (over wifi even!), play around with pins directly, all that.

Being able to run code at runtime with no compile step also opens up the possibility of micro-controllers that can load "apps" or other user code at run time.

Somehow I don't think people would be this snobby about the advantages of an interpreted language if it was running lisp^1 instead of python. Of course to be fair if it was javascript they'd be twice as snobby and I'd agree with them...

[1]: https://thenewstack.io/nasa-programmer-remembers-debugging-l...

Re: CircuitPython – The easiest way to program microcontrollers

#15

My suspicion is that this, and MicroPython, which it's based off, are designed for people who know Python, and are hesitant to learn another language, or expand their toolbox. Python is a great language in some domains. For example, numerical computing, web servers, and scripting. Embedded programming is, unfortunately, only suitable to a handful of languages that can operate with high speed and low memory use. At th…

It's really quite nice to be able to telnet into a running micro-controller (over wifi even!), play around with pins directly, all that. Being able to run code at runtime with no compile step also opens up the possibility of micro-controllers that can load "apps" or other user code at run time. Somehow I don't think people would be this snobby about the advantages of an interpreted language if it was running lisp^1 i…

It's not about being snobby - it's about choosing the right tool for the job.

Challenge: Come up with a set of project requirements for a practical electronics device, and evaluate if Python is the right tool for the job. I'm suspicious you'll run into headaches with interrupts, DMA, concurrent processes interfering with each other due to taking up too much CPU time, onboard peripherals beyond the most popular in the most popular configs won't work etc.

Re: CircuitPython – The easiest way to program microcontrollers

#16

Earlier quoted context omitted.

It's really quite nice to be able to telnet into a running micro-controller (over wifi even!), play around with pins directly, all that. Being able to run code at runtime with no compile step also opens up the possibility of micro-controllers that can load "apps" or other user code at run time. Somehow I don't think people would be this snobby about the advantages of an interpreted language if it was running lisp^1 i…

It's not about being snobby - it's about choosing the right tool for the job. Challenge: Come up with a set of project requirements for a practical electronics device, and evaluate if Python is the right tool for the job. I'm suspicious you'll run into headaches with interrupts, DMA, concurrent processes interfering with each other due to taking up too much CPU time, onboard peripherals beyond the most popular in the…

A user-interface for 3D printers.

* Must be able to communicate with arbitrary 3D printers over USB, should be able to act as a USB host.

* Must be able to load user programs/extensions.

* Must be able to connect to wifi and host a rudimentary web interface.

* Must have a color display and user interface including graphs.

* Must have a BoM cost of less than 40 US dollars.

---

I'd argue micropython would be the best choice for that set of requirements, as opposed to something like a raspberry pi. Not sure you can get an RPI with a display in that price range, but you can definitely get microcontrollers that support USB host and have a screen in that price range, in bulk and able to be incorporated into an actual product.

For the user plugin loader, you might be better off using a lua interpreter? I think micropython would still be a good choice for it though. Any thoughts on how you'd want to put something like that together?

Re: CircuitPython – The easiest way to program microcontrollers

#17
post #3

I used Circuit python in a Raspberry PI Pico. It's ok for prototyping, I would not use it on production. Still recommend using C++, and Platformio for most things. But it helped me with quick hacks and proofs of concept. For example, my company build a laser warning system that would be triggered when someone cut through the laser. I build a quick remote control to trigger the system without having to get on a ladder…

On the website: "CircuitPython is a programming language designed to simplify experimenting and learning to code on low-cost microcontroller boards."

That is it in a nutshell. Its a Adafruit fork to conjoin the best of both worlds - adafruits simple boards and python as a easy language with which to get started. or to PoC something quickly.

Re: CircuitPython – The easiest way to program microcontrollers

#18
post #10

How does it compare with MicroPython? In any case, can be good for PoC or similar things where your microcontroller is largely oversized for the application, but in practice you hardly can exploit your microcontroller's power using such a non-compiled high-level language. For a hobby project you can get a microcontroller that has 10x the actual power you need and use Python on it, but on an industrial scale it's not…

It can "work" on smaller microcontrollers (where "work" means you have to constantly restart the microcontroller because you run out of RAM...)

Re: CircuitPython – The easiest way to program microcontrollers

#19
post #10

How does it compare with MicroPython? In any case, can be good for PoC or similar things where your microcontroller is largely oversized for the application, but in practice you hardly can exploit your microcontroller's power using such a non-compiled high-level language. For a hobby project you can get a microcontroller that has 10x the actual power you need and use Python on it, but on an industrial scale it's not…

From the top of the webpage, "CircuitPython is a programming language designed to simplify experimenting and learning to code on low-cost microcontroller boards." It targets beginner hobbyists and the lower grade education market. The changes from MicroPython are designed to make getting code on to the board and executing easier for those users.

When a microcontroller board with CircuitPython is connected to a computer it appears as a USB drive. To install your code and any supporting files on the board you just drag and drop them on the drive vs having to upload them using something like Thonny with MicroPython. Also when you drop your code on the drive the board automatically resets and begins executing the code. It also has some changes to make code more portable across the different microcontroller boards it supports.

Re: CircuitPython – The easiest way to program microcontrollers

#20

My suspicion is that this, and MicroPython, which it's based off, are designed for people who know Python, and are hesitant to learn another language, or expand their toolbox. Python is a great language in some domains. For example, numerical computing, web servers, and scripting. Embedded programming is, unfortunately, only suitable to a handful of languages that can operate with high speed and low memory use. At th…

I remember the "Handy Board" [1], a 68HC11-based micro-board (that came out of MIT?) that had an amazing "Interactive-C" language. C code was compiled to a byte-code that was interpreted in real-time on the Handy Board.

So cool to type code on the C/L and have it execute on the microcontroller and return a result back to your terminal.

I suspect Python on a microcontroller gives a similar experience/thrill.

[1] So chunky: https://en.wikipedia.org/wiki/Handy_Board

Post reply on HN