Picking an MCU
Picking an MCU#
I like projects where I learn something new. If I know everything, it becomes a task, not a project to me. And tasks are boring. I also like to share what I learn, because someone else might benefit. Also, sometimes someone points out a more interesting way to do the same thing. Or they have a lot more knowledge than me and can shed new light on it. (But this is the internet, so your mileage on that may vary).
I have this project I’m working on which is an atmospheric lighting system. By atmosphere I mean mood and not something more grand. But it does require a few things. First, I have to drive higher power LEDs for lighting. Next, I have to make it rugged enough to deal with being outdoors. Third, I want tight control over the lighting. The are kind of my high-level wants.
The Project#
The lighting system should allow me to flood an area with colored light. I should be able to change colors, and smoothly transition from one color to another color. I would like to be able to do sudden effects, like suddenly blinking everything white for lightening. I would also like to have “helper” lights to shine UV for designs that have luminescent paint. What this means is I need to be able to control one or more RGB LEDs. In addition, I should have a few ultra-bright UV LEDs. (Note that this is not meant to be pointed at people).
Because things like lightening require coordination over multiple lights, control must be fast. There should be low (less than 10 ms) of latency for commands. The system should be reasonably secure. It should illuminate large areas, with most of the light falling into a specific area. For example, the area might be a couple of fake tombstones for Halloween. I should be able to control it from something like a Raspberry Pi. This might be important so I can play sounds or music to add to the atmospherics.
Hardware#
For the lights I’m trying out some 3-Watt LEDs. They require 200-300 milliamps of current per color channel. No micro-controller can drive that much current, so I’ll use transistors to actually power the LEDs. The system should run off one power supply. I will need 3-5 volts for the LEDs. Depending ont the MCU, I’ll need to use either a 5 volt or up to 12 volt supply. I have a 5 volt power supply that can deliver a stupid 200 amps. (I’d probably buy a smaller one). Or a 12 volt wall-wart should do it.
The Contenders#
There are too many micro-controllers out there to try them “all.” But a lot of them a slightly different re-hash for an existing chip. For example, there are a number based on the RP2040 chip, which is based on an Cortex-M0. The RP2040 board from Adafruit vs. Raspberry PI, or Sparkfun should be fairly similar. And companies like https//www.st.com produce several iterations of their baords. But the differences can be hard to spot, because they’re based on a few small variations. More than individual chips, it’s worth looking at ecosystems. Here’s the list I’m going to consider for now.
The various Adafruit/Sparkfun/Microbit boards are not on there. First, they re-hash many of the same processors. Picking the Pico, for example, likely means my code will work on an RP 2040 variant they produce. Also, like STM, finding the part may become an issue over time. Adafruit and Sparkfun both retire products. Which is not a problem, unless you have something in production for 5 years. If I design for a board, I’d like to keep using it for years.
And some boards are super-focused on experimentation and education. They contain peripherals that I wouldn’t want to pay for, if I wanted to sell a buch of products. For example, the Micro-bit is a great MCU for experiments and learning. Variations come with everything from built in OLED displays to LED matricies. These jack up the cost, if you wanted to sell a few of your devices.
Criteria#
- Ease of programming.
- Cost.
- Ease of use.
- RTOS choices.
- Choice of languages.
Let’s start with my ideal board. I can take it out of the box, install the ide, and plug it in, going from zero to blinky-light in a few minutes. Build my device with a minimum of fuss. When I need to, set a breakpoint in the IDE and walk through the code. For example, drive small servos directly from the MCU. Decide my program is complex enough for a couple of RTOS features and add in an RTOS like FreeRTOS. Or maybe be able to quickly iterate by writing the code in Python. Or maybe decide I need high integrity code and rewrite in Ada.
Conclusion#
I think I’ve talked myself into the Arduino. None of the platforms really supports that level of ease of use. However, the Arduino platform is probably the most accessible. It is not the the cheapest. That is the Pico series. Which also has better debugging support and bettere multi-language support. And ESP32 requires the use of Espressif’s tooling (especially for ‘S’ series). And some of the modern Arduinos, like the R4 series, have notable limitations. But over-all, it is the closest to the above scenario.
But if someone wants to explore embedded programming, it’s hard to go wrong with Arduino. The tools are easy to use. The tools are relatively reliable. There are libraries for almost every device. It would allow me to focus more on the full product development. The ATMega328 Arduino Uno will probably be on a store shelf until the heat death of the universe. Chances are, 10 years from now, someone who comes across the how-to video will be able to follow it.