Arduino or micropython? And which board?

Okey, I know this is a big question. And I’m asking you for your advice.

The case:
For my bachelor end project I need to make a model boat foiling. A big whish is to add an automated system which stabilizes the boat by changing the angle of attack (and thus lift) of the foils.

What it needs to do:
Stabilize the boat by adapting pitch angles (servo or linear drive controlled) with input from a 9dof.
Output g-forces and model orientation to a computer (best if it can be done wireless).
Easy and quick changes for pid settings (also best if wireless).

The options:
Arduino (c++) or circuitpython

I’m curious on what you would suggest. For now circuitpython looks promising. But I’m not sure if it’s worth the time. For the board I’m leaning towards a high speed board like the adafruit metro m4.

One reason to go circuitpython is that the model is to be used in the future for further testing at the tu delft. And since they switched to python it seems a logical choice.

You may wish to follow this other recent Thread on MicroPython

This is the Arduino Forum - folk here may not be 100% impartial :slight_smile:

...R

Python is a more modern, higher-level language. It will probably be quicker to write the code, debug and test it, and require less depth of coding experience compared to C++.

The Metro M4 is 32 bit and 120MHz, compared to 8-bit and 16MHz of a standard Arduino like Nano. The same C++ code will probably run 10~20 times faster on the M4 compared to, for example, Nano.

Python code runs probably 10~20 times slower than the nearest "equivalent" C++ code. So Python code on M4 will probably run at a similar speed to equivalent C++ code on Nano.

So if you are paying a coder £50/hour, to write code for a a few tens/hundreds of devices, choose Python and Metro M4. The extra cost of hardware will be dwarfed by the time saved in the code development.

If you are paying a coder £50/hour to write code for millions of devices, choose Nano and C++. The money saved in hardware will dwarf the extra time needed in code development.

Folks being not so impartial is fine. As long as you’re honest.

I also read it somewhere else that python code runs slower. But I didn’t find why. My gut would say that a more modern language would run quicker. Or is it because of the compiling that c++ runs faster?

Python is an interpreted language. C++ is compiled. That is the reason for the speed difference. Whether that matters for your project is a question for you to figure out, but if you're moving foils with hydraulics or some other kind of actuators, your mechanicals are going to be the limiting factor, not your code.

In general, the more modern the language, the slower it runs on the same hardware. But hardware gets faster and cheaper every year, and paying coders to develop code gets more expensive every year. So it's generally cheaper to use more modern languages which make software development easier & faster, even though the result is relatively slower running, because faster hardware is almost the same cost and getting cheaper.

For the traditional Arduinos such as the Uno, Mega or Leonardo Python is not an option - they don't have enough speed or enough memory.

If you have a microprocessor or PC that allows the choice between Python or C++ NOBODY would program in C++ unless the extra runtime speed is essential. And that primarily depends on the project you want to implement.

...R

fabiandelete:
I also read it somewhere else that python code runs slower. But I didn’t find why. My gut would say that a more modern language would run quicker. Or is it because of the compiling that c++ runs faster?

Google searches can save a lot of time, try this as a search item;

Arduino c++ versus micropython

A coder familiar with the controller will be able to write code in assembler or C. A coder capable of python will be lost without a library or firmware for every specific controller.

If you have some experience with python, my inclination would be to start developing the project in micropython (circuitpython) until you run into a reason not to, that is, the code has excessive latency or you need library support for something that isn't available in python.

For non-trivial development the naturally interactive nature of python makes for quicker prototyping and debugging. Another advantage is that I think it's harder to write undecipherable code in python. I say this as someone who does a lot of data analysis and visualization in python on the PC and has done a few IOT sorts of projects on ESP8266 and ESP32 boards in micropython.

The clear advantage of the c++/Arduino environment is that the code will run very much faster on any given board and with much smaller memory requirements. It will also be easier to do low level I/O processes in c++.

I don't think either choice is inherently "wrong".

Compatible with Arduino and MicroPython, Wio Terminal is an ATSAMD51-based microcontroller with wireless connectivity supported by Realtek RTL8720DN. noticed new release from Seeed. https://www.seeedstudio.com/Wio-Terminal-p-4509.html