Hacker News new | ask | show | jobs
by RantyDave 720 days ago
I see these $miniscule microcontrollers are being more or less the end of the road for ASIC's, apart from those that have high performance requirements.

Like you say - with 1kb "rom" and 48 whole bytes of ram you can make a TV remote, or the thing that debounces a switch, maybe something that decodes SP/DIF, control a battery charger, drive a vape ... all sorts of edge 'tasks' can become just one SKU and a couple of hundred bytes of code. Wild.

1 comments

Yes but...

You consolidate support for different systems... much like how this chip has a dedicated 38kHz generator, other chips can have more flexible timers that support other frequencies, dedicated UARTs, USARTs, I2C, SPI that leads to better communication to other devices.

For example:

> control a battery charger

Okay, to make a battery charger requires:

1. Current measurement. Current measurement requires a shut-resistor (ex: 0.1Ohms) and an ADC. But the ADC needs to be able to measure micro-volts if you want any level of accuracy (1mA across 0.1 Ohms == 0.1mA aka 100uV of change) This is possible with either 16+ bit ADCs, or alternatively an ADC with x16 or more gain (effectively gaining "4-bits of zoom").

2. Alternatively, you can have Chopper/Instrumentation OpAmps that voltage-multiply the current shunt up to a level that your ADCs can see it. (Instrumentation OpAmps and Chopper OpAmps have low Bandwidth-Gain but very accurate zeros aka Voltage Offset statistics).

3. You'll need a high-speed dual-timer and XOR to implement PWM with dead-zones to control two MOSFETs to make your buck (or boost) converter. You can turn on the "low side" MOSFET at the same time as the high-side MOSFET otherwise you literally just short power to ground, a few microseconds of dead-time is all you need to keep things safe (and utilizing flywheel diodes for those brief microseconds is fine). Higher-speed Buck/boost converters (ex: 2MHz) are possible but a fundemental timer much higher than that. Ex: if you want 5-bits of control over the 2MHz PWM, you'll need a 64MHz timer.

4. 64MHz timers are possible with Phase-locked-loops that multiply your fundamental frequency (ex: an 8MHz base clock) to the much faster speeds.

------------

So if we're talking about the cheapest equipment that controls a battery charger effectively, in a flexible way that other people can use the tidbits, we'll need:

* 64MHz timers / PWM at the 64MHz speed. (~6-bits of control over 1MHz PWM... to implement a possible PID controller or maybe just PI controller (no-D needed??) )

* Current-measurement circuitry (ADCs at 16-bits and/or a 16x Gain ADC at 12-bits, or OpAmps)

* Complex enough timers to handle "dead time". This is not easy and is a rare feature in my experience.

* Analog Comparators to sense the voltage going into the battery and perform logic. ADCs could work in theory but a dedicated Analog Comparator is cheaper, easier, and more reliable.

* Ideally temperature control on-board, to provide safety.

RP2040 fails because it doesn't have accurate enough ADCs (thus requiring a 2nd or 3rd chip for the Instrumentation-Amp to amplify the current high enough).

There are a large variety of 8-bit chips that have powerful enough timers + powerful enough analog equipment to handle all of this BTW. STM32 cheats by just providing lots of OpAmps, as does TI's MSPM0 line. A lot of this stuff is quite easy with OpAmps actually.

There's a few PIC and AVR chips that have powerful enough timers as well.

----------

Yes, even something as simple as a battery charger has a surprising amount of logic for the buck/boost behavior. Its something you can do from scratch with a uC and Microcontroller though.

But traditionally speaking, you build such circuits out of transistors and OpAmps instead. Today's uCs have all the right stuff in the right places (IE: 3x free OpAmps on the TI MSPM0) that solve large sets of these problems.