Notifications
Q&A

I have to choose: Arduino or Raspberry pi.

+1
−1

Moderator Note

If this site were mature, this question would be closed because it solicits opinions, or is too specific about particular models. In the interest of site activity, answers are being allowed that compare and contrast microprocessors boards to microcontroller development boards in general. Specific models can be used as examples, but should not be the main point of answers.


I've finally decided to enter into the world of micro controllers/microprocessors. I think this may provide me an important tool to realize my projects. I am not an electronic engineer designing products for the market, but I need a tool that allows me to interface with the electronics, while performing complex tasks like analyzing and processing signals, making decisions etc. (nothing well defined for the moment).

After googling and reading several articles, I understood I don't really want to learn micro controllers, but how to use micro controllers boards (or microprocessor boards). In fact, it appears my time and energy are so reduced that I have to make a choice, but a good choice, inside this jungle.

Further readings convinced me that the best options for me are either "Arduino", or "Raspberry pi". I'm aware that Arduino is a micro controller while Raspberry pi is a microprocessor, but I have read that Raspberry pi can perform any micro controller task, and much more. So, my first reaction was: Why Arduino if, for nearly the same price, you can have a full microprocessor.

I need help to choose, because it is unclear for me what is the advantage of using Arduino vs Raspberry pi (well, there should be one considering the number of adepts of Arduino). They says that Arduino is a very stable environment, but I don't understand in what sense it is more stable than Raspberry pi.

Other details that can help:

  • It is somewhat improbable that I will ever need something performing at very high speed

  • I can program in C or C++, but I really prefer programming in Python

  • I'm basically a mathematician, algorithmic engineer and programmer, so, I don't want to choose something too childish for me, designed for educational purpose only. If I spend time to learn, I just want this be worth the time and energy.

Why should this post be closed?

3 comments

In the opening paragraph, you mention that you have projects which you want to realize. What are your projects? ‭Nick Alexeev‭ 21 days ago

I am currently doing research about biological effects involving high voltage, magnetic fields and microwaves. My aim is to demonstrate the effect with a prototype and then to create a startup. So, I develop my projects dynamically, and I just anticipated that micro controllers may be a useful tool in the future. ‭coquelicot‭ 19 days ago

Then use what's easy for you right now to use. If you prefer Python, then use the platform which can run Python. Or a DAQ box plugged into a PC which runs Python. ‭Nick Alexeev‭ 18 days ago

2 answers

+2
−0
  • Rasp PI is a PC in disguise - it is a single-board computer. As such it runs Linux and like any Linux PC, it doesn't allow real-time execution, direct access to physical addresses, deterministic single-process execution etc etc.

    Writing drivers yourself is a complex process where you must follow the kernel's preferred way of doing so, so that your drivers co-exists with a whole lot of things that you may or may not have any use for. Overall, it comes with a whole lot of bloat and complexity.

    So it's a pretty useless tool for leaning embedded systems programming in general and microcontroller programming in particular.

  • Arduino is a hobbyist microcontroller board suitable for those who want to learn how to use specific drivers and libraries written by others, instead of learning how to make those themselves. It's suitable for quick & dirty low quality applications when you want to get something cheap and questionable up and running quick, without caring about how you got there. It's not suitable for the purpose of learning microcontroller programming.

    Arduino is using an outdated 8-bit architecture called AVR, developed some decades ago. Like any 8-bitter, it is very slow and inefficient, poor code efficiency, can't handle 32 bit integers well, not to mention floating point.

    As such, 8-bittes comes with high average current consumption per line of C code, since they must chew through hundreds of instructions where a modern CPU would handle the same code in a single instruction.

    Writing C code for 8-bit microcontrollers is actually quite intrictate, because of all subtle crap that goes on between the lines in the C language: integer promotion, implicit signedness changes, numerous cases of poorly-defined behavior when doing various arithmetic etc etc. 32-bitters are far more C friendly because then you can use 32 bit types consistently without having to worry so much about all the above mentioned issues.

    Arduino is per default using C++. Writing C++ for 8-bit microcontrollers is pure madness. The language isn't suitable for such low end systems. Things like vtables, RTTI, exceptions, implicit heap allocation, C++11 auto keyword, static storage object constructors etc etc will create complete havoc. It is arguable if C++ is at all suitable for any embedded system, but that's another story...


So my advise is to not pick either of these hyped, dangerous and harmful hobbyist platforms. Instead, get an evaluation board for a "bare metal" microcontroller of whatever flavour you prefer, then learn how to actually write microcontroller programs from scratch.

Generally, older 8 or 16 bitters are more simplistic in themselves, easy to learn assembler on, but harder to code C for. Learning the basics of assembler is great for understanding how computers actually work, and how C code gets translated to machine code. So while nobody writes whole programs in assembler any longer, it is still useful to learn.

Modern 32 bit ARM Cortex M is what most professionals use nowadays, but those parts tend to be more complex overall. Still I usually recommend these over obsolete low-end ones, because you'll learn to use something that is actually modern and useful. I wouldn't recommend any particular ARM flavour over another, they all have their own quirks and strengths. It might be worth checking out the tool chain first of all, find one you like and take it from there.

5 comments

Wow, now the situation is even more complicated for me; you killed my hopes (a chance that I was not depressive today, otherwise you would have killed me too :-) ). +1 and thanks for this really good and elaborated answer. ‭coquelicot‭ 22 days ago

What would you suggest as a step up from ATMega328p? I have seen STM32 being in the spotlight, but it seems like a huge jump. ‭Kranulis‭ 22 days ago

@Kranulis‭ Depends what you mean with "step up", as in learning process? If so, then AVR is about as complex as the average 8 or 16 bitter out there. Programming some other more code efficient 16 bitter isn't that much different at all. The problem with 32 bitters isn't the core itself, but that they tend to have more complex peripherals. It's usually a bit of a pain to set up clocks/PLL and GPIO routing etc on upper end MCUs. But other than more complex hardware peripherals, not that different. ‭Lundin‭ 21 days ago

You'll have to learn about wait states, DMA etc but those are things one need to know when doing modern MCU programming. It's all MCU specific though. Again, I wouldn't recommend any particular flavour of ARM. I've worked with ST, NXP/Freescale, Microchip and Silabs ones. What you should be wary of is rather the various horrible Eclipse tool chains and bloat "HAL" libraries provided by these manufacturers. If you can afford it, look into commercial cross-platform ARM tool chains instead. ‭Lundin‭ 21 days ago

+1 As a professional programmer and Arduino hobbyist this is the most helpful thing I've read on the internet in a long while. ‭dustytrash‭ 20 days ago

+1
−0

This site isn't appropriate for telling you what to choose. We can, however, give you information on microprocessors versus microcontrollers.

Microprocessors and microcontrollers are intended to different applications. As a result, they have different capabilities, and different tradeoffs of use.

Microprocessor

Microprocessors (really just "processors", the "micro" part is no longer relevant since any credible processor needs to be on a single die for speed) are intended to support general purpose computing platforms. It is expected that there is a user that can select many different operations arbitrarily, some of them concurrently. Since a user is assumed, user-interface hardware is usually expected to be present. This includes a standard way of driving a screen, keyboard, mouse, etc. It also generally includes connectivity, like ethernet, USB, and the like. Some form of local mass storage is also expected, which is used to implement a file system presented to the user.

Microprocessors are usually chip sets. The main processor and some of its cache may be on a single chip, but that chip generally can't run by itself without significant support circuitry. The main chip implements I/O busses that other chips connect to. These other chips are often integral parts of the overall processor, and are often specific to particular processor families.

All the hardware peripherals, file system, and communications require a lot of software complexity. Such systems were therefore generally used with an operating system that manages these, and provides hardware-independent abstractions. It also handles virtual memory, multiple processes that must be assumed are hostile to each other, standard communications like TCP and USB, and many other things that are easy to take for granted.

Microcontroller

Microcontrollers are intended for dedicated embedded applications. They are therefore optimized for cost, power, and ease of electrically integrating into a circuit. Flexibility is sacrificed to be able to do a single task well, reliably, cheaply, and in a small footprint. The program and data memory is built-in, as are other simplified peripherals. There are no I/O busses for hanging more memory or additional peripherals off of. You get what is built in. If you need more, you use a model with more. That will of course cost more, use more space, and probably more power.

The I/O pins are meant to control or sense external signals directly. Most pins can be driven or sensed individually under firmware control.

Since the complexity and demands of dedicated embedded applications vary widely, there are a wide range of microcontrollers that include just enough to support the many different applications. Microcontrollers range from something like a PIC 10 with as little as a dozen bytes of ram and a few hundred program memory words with a 1 MIPS processor, to chips with Mbytes of RAM/ROM and 100s of MIPS processors.

Products with dedicated embedded microcontrollers can be produced in large quantities. Spending only a few 10s of cents on the minimum microcontroller for the job, versus a few dollars on an unnecessarily capable one can make a real difference. This is why there are so many more microcontrollers than more general purpose microprocessors.

Tradeoffs

Some microprocessor advantages:

  1. Can run arbitrary programs.
  2. Operating system support to abstract and virtualize hardware resources.
  3. High flexibility. You decide on the fly what to run.
  4. More advanced and wider choice of software development environments.
  5. Can support more resource-heavy execution environments. This includes interpreters like Python, various "byte code" virtual architectures (Java, .Net) and languages that implicitly require heavy run-time support.
  6. Virtual memory, with physical memory expandable over a wide range.
  7. Generally faster, although some of that gets used up in the many layers of abstraction, runtime environments, and the like.
  8. Good math computation capability, wide floating point formats, some transcendental functions like sin, cos, sqrt and the like in hardware.

Some microcontroller advantages:

  1. low cost. There are many under 1 dollar, and just about all are under 10 dollars.
  2. Low power. Meaningful work can be done with 50 mW, and intermittent task many times less than that. 200 mW is "a lot" for a microcontroller.
  3. Small footprint. Some of the smallest have only 6 pins and come in the same package that individual transistors do. 64 pins is already "big", but still nowhere near the 100s of pins of a modern microprocessor.
  4. Direct I/O pins available intended for connection to the real world. Most pins can be directly controlled or sensed by firmware. There are no external I/O interface chips sitting on a bus required.
  5. Fast power up. There is no operating system to boot, drivers to install at run time, registry settings to check, etc. Most system start performing their dedicated function in well under 1 second after power on. When it really matters, it's not too hard to get a system to start running its task in just a few ms.
  6. Meant to be included in ordinary circuits. Usually only a single supply voltage is required, and that can often vary over a significant range. Today's digital circuits mostly run on 3.3 or 5.0 V, which are both well supported by a wide range of microcontrollers. Microprocessors, in contrast, usually require multiple and specific power voltages, and these are often not "convenient" for ordinary circuits not intended for implementing microprocessor systems.
    before ARM became mainstream

    This presents a very narrow view, and is misleading at best. This statement makes it sound like most microcontrollers are ARM-based, but that's very far from the truth. ARM may have a large chunk of the 32 bit microcontroller market, but last I looked, that was still much smaller than the 8 and 16 bit worlds. There are also other 32 bit architectures, like MIPS used in the Microchip PIC32 line.

    Some are apparently unaware of the large world of microcontrollers out there that only run a toaster, take input from a keypad and pass it on via UART, turn on a pump and flash a light when the a tank gets too full, etc. Even low end 8 bit cores have enough computational power to perform these tasks. When you're making 10,000 units, a 50 cent micro compared to a 2 dollar micro to do the same job matters. In fact, I'd say that this world is the large bottom unseen part of the microcontroller iceberg. Don't get fooled by the glitzy little peak that sticks out of the water.

    Some of the comments here by others present a rather biased and narrow view of the microcontroller world. I was content to leave them alone in their own answer, but now that they have spilled over to comments to this answer, they need to be dealt with:

    [Raspberry Pi, Arduino] hyped, dangerous and harmful hobbyist platforms

    The language alone should make you suspicious. Both these platforms have legitimate purposes.

    The RasPi is a very accessible and cheap single-board computer. As was correctly stated, it's basically a PC on a board. When you can get a PC for a few 10s of dollars, you can afford to dedicate it to a specific task. For hobbyists doing this one-off, that can make a lot of sense.

    The Arduino is a microcontroller development board with enough software sugar-coating to allow getting things done relatively easily without having to know what is actually going on underneath. That can be harmful if you want to learn about microcontrollers, but it's very useful if you just want to get something done and NOT have to learn the details.

    Modern 32 bit ARM Cortex M is what most professionals use nowadays

    Just plain wrong.

    Professionals chose the right micro for the job. ARM may be a popular choice for 32 bit micros, but again, that is a small part of the overall microcontroller world.

8 comments

@Olin thx. I am now convinced that I should use micro controllers. The problem is there is no general purpose one (according to the answers here). This makes things even more complicated for me. Regarding the "moderator note", I don't know what to do about that: do you want I edit the question (this may make the answers less understandable)? ‭coquelicot‭ 22 days ago

@coq: No need to edit the question. The note makes it clear enough what is going on. ‭Olin Lathrop‭ 22 days ago

You can have virtual memory on microcontrollers too, on the more high end ones with MMU. But then such high end 32 bitters are about the most complex parts out there, so nothing I would recommend for beginners. ‭Lundin‭ 21 days ago

@coquelicot‭ Rather, most microcontrollers are general-purpose ones. The vast majority of them have the same kind of common hardware peripherals: ADC, timers, PWM, UART, SPI. Traditionally, before ARM became mainstream, there were camps of devs preferring one flavour of MCUs over the other. And before that, everything was divided in "Intel" and "Motorola" camps, with most parts inspired either by 8051 or MC6800. ‭Lundin‭ 21 days ago

@Lundin. Thank you so many for your help and comments. Things are now much clearer for me. ‭coquelicot‭ 21 days ago

Show 3 more comments

Sign up to answer this question »