---
title: NMPC on Microcontrollers
url: https://www.emergentmind.com/topics/nmpc-on-microcontrollers-nmpcm
type: topic
---

# NMPC on Microcontrollers

Searching arXiv for recent papers on NMPC on microcontrollers and embedded implementations to ground the encyclopedia entry.
In current arXiv usage, “NMPCM” denotes “Nonlinear Model Predictive Control on Resource-Constrained Microcontrollers,” exemplified by direct deployment of full nonlinear MPC for quadrotor UAVs on a Teensy 4.1 microcontroller [2507.21259]. The broader embedded-control literature shows that the topic also includes adjacent strategies for obtaining NMPC-grade behavior under strict RAM, flash, arithmetic, and sampling-time constraints: real-time iteration schemes with specialized QP cores, matrix-free first-order methods, time-certified box-constrained formulations, multirate discretizations, and neural surrogates trained to imitate an NMPC feedback law [2407.08681].

## 1. Scope and technical landscape

NMPC on microcontrollers addresses the tension between the algorithmic structure of receding-horizon nonlinear optimal control and the resource envelope of MCU-class hardware. The defining constraints in the cited literature are limited RAM and flash, fixed sampling deadlines, modest clock rates, static memory allocation, and a preference for simple arithmetic kernels such as box projections, dense matrix-vector products, or fixed-point multilayer perceptrons.

The contemporary literature separates the field into several recurring implementation patterns.

| Mode | Representative papers | Embedded mechanism |
|---|---|---|
| Full online NMPC | [2507.21259] | ACADO code generation, RTI, qpOASES, RK4, MCU deployment |
| Matrix-free embedded NMPC | [1709.06487], [1812.04755], [1506.02583] | PANOC or continuation/Krylov updates, no generic QP solve |
| Time-certified approximations | [2401.04653], [2402.16186] | Box-QP structure, exact iteration count, explicit flop bounds |
| Learned controller or model | [2407.08681], [2310.08392], [2201.02044] | Offline NMPC supervision, compact DNN/MLP inference online |
| Convex MPC kernels for RTI subproblems | [2310.16985], [2601.14414] | ADMM, Riccati structure, construction-free or low-memory QP updates |

This suggests a wider operational meaning of NMPCM in current research: not only solving the original nonlinear program online, but redesigning the model, discretization, solver, or control law representation so that receding-horizon control remains compatible with microcontroller-class execution.

## 2. Full nonlinear optimization directly on microcontrollers

The most literal form of NMPCM is the direct execution of full nonlinear MPC on an MCU. The paper “NMPCM: Nonlinear Model Predictive Control on Resource-Constrained Microcontrollers” [2507.21259] formulates a quadrotor OCP with a 12-state rigid-body model,
\[
\mathbf{x}(t)=
\begin{bmatrix}
p & q & r & \phi & \theta & \psi & \dot p & \dot q & \dot r & \dot\phi & \dot\theta & \dot\psi
\end{bmatrix}^T,
\]
control inputs
\[
\mathbf{u}(t)=
\begin{bmatrix}
U_1 & U_2 & U_3 & U_4
\end{bmatrix}^T,
\]
and box constraints
\[
U_1 \in [17.5,25.0]\ \text{N},\qquad
U_2,U_3,U_4 \in [-0.1,0.1]\ \text{Nm}.
\]
The continuous-time cost is the standard tracking form
\[
\big\|\mathbf{x}(t+T)-\mathbf{x}^{\mathrm r}(t+T)\big\|_R^2
+\int_t^{t+T}
\left(
\big\|\mathbf{x}(\tau)-\mathbf{x}^{\mathrm r}(\tau)\big\|_P^2
+
\big\|\mathbf{u}(\tau)-\mathbf{u}^{\mathrm r}(\tau)\big\|_Q^2
\right)d\tau,
\]
with explicit state and input bounds in the generic formulation.

The implementation uses ACADO code generation, multiple shooting, Gauss–Newton SQP, real-time iteration, qpOASES, and RK4 integration, together with a cascaded PID controller that provides warm-start references for both \(\mathbf{x}^{\mathrm r}\) and \(\mathbf{u}^{\mathrm r}\) [2507.21259]. This warm start is not peripheral: it supplies a physically meaningful nonzero equilibrium thrust and improves active-set reuse on the embedded target.

The target MCU is the Teensy 4.1, with an ARM Cortex-M7 at 600 MHz, 7.75 MB flash, 512 kB RAM1 plus 512 kB RAM2, and 32-bit floating-point support; the implementation constrains itself to 512 kB RAM1 for NMPC variables and code [2507.21259]. For integrator step \(=5\), the horizon length can be increased up to \(N=18\); beyond that, the MCU runs out of memory or fails to solve the optimization problem reliably. With \(N=10\), memory consumption is almost constant as integrator step increases, whereas solution time grows with the number of RK4 substeps.

The same paper reports that, in desktop simulation, ACADO-based NMPCM can run at up to 1 kHz, while the compared CasADi-based NMPC reaches only about 30 Hz for similar settings and fails to track properly when the horizon length exceeds 16 [2507.21259]. In point-to-point quadrotor simulation, the reported quantitative benchmark gives for NMPCM: settling time \(8.612\) s, overshoot \(23.46\%\), \(U_{\max}=[25, 0.0295, 0.0359, 0.0023]\), ITAE \(14.6793\), IAE \(9.4495\), ISE \(29.6286\), and ITSE \(26.3615\), with better overall metrics than the compared NMPC (ACADO), NMPC (CasADi), cascaded PID, and MPCC configurations [2507.21259].

Real-world experiments on several quadrotor frames show the same architectural point: full nonlinear MPC can be colocated with sensing, estimation, and actuation on the same MCU. For roll \(\phi\), the reported experimental error measures improve from PID values ISE \(1.673\), ITSE \(35.784\), IAE \(6.051\), ITAE \(128.815\) to NMPCM values ISE \(0.061\), ITSE \(1.317\), IAE \(1.091\), ITAE \(24.291\) [2507.21259]. In the context of NMPCM, this is the canonical “full online solve” reference point.

## 3. Embedded solver architectures and computational kernels

A second major strand of the literature does not begin from a particular plant, but from solver structure. “A Simple and Efficient Algorithm for Nonlinear Model Predictive Control” [1709.06487] introduces PANOC as a line-search method on the forward-backward envelope for problems of the form
\[
\min_u \ \varphi(u)=\ell(u)+g(u),
\]
where \(\ell\) is a smooth single-shooting cost and \(g\) is a prox-friendly nonsmooth term encoding input constraints. PANOC uses the fixed-point residual
\[
R_\gamma(u)=u-\operatorname{prox}_{\gamma g}(u-\gamma\nabla \ell(u)),
\]
L-BFGS directions, no Hessian evaluation, and no inner QP iterations. The paper explicitly positions PANOC as having low memory requirements and a simple implementation particularly suited for embedded NMPC [1709.06487].

That algorithmic claim is instantiated in “Aerial navigation in obstructed environments with embedded nonlinear model predictive control” [1812.04755], where a C89 implementation of PANOC solves a single-shooting NMPC problem for a quadrotor MAV at 20 Hz onboard a lab-scale platform. The model is a high-level position controller with state
\[
x(t)=\big(p(t),v(t),\theta_r(t),\theta_p(t)\big)
\]
and inputs
\[
u(t)=\big(T_d(t),\theta_{r,d}(t),\theta_{p,d}(t)\big),
\]
with obstacle avoidance handled by smooth penalties
\[
\psi_{\Theta_j(t)}(p)=\frac{1}{2}\prod_{i=1}^{m_j(t)} [h_j^i(p,t)]_+^2.
\]
The implementation uses a 50 ms sampling time, horizon \(N=40\), a maximum of 200 PANOC iterations, and static memory. Reported performance includes average per-iteration time of \(80\)–\(350\,\mu\text{s}\) and \(8\)–\(15\%\) CPU usage of a single Intel Atom core while running at 20 Hz [1812.04755]. The paper also notes that the operations required are evaluations of \(\Phi(\bar u)\), \(\nabla\Phi(\bar u)\), projections onto box constraints, and small-memory L-BFGS recursions, which directly matches MCU-friendly arithmetic.

A related matrix-free line derives from continuation NMPC. “Preconditioned Continuation Model Predictive Control” [1506.02583] formulates the online step as the solution of a Jacobian-free linear system \(A\Delta U=b\), where each Krylov iteration requires one evaluation of the nonlinear KKT residual \(F(U,x,t)\), i.e. one forward sweep and one backward sweep over the prediction horizon. The paper’s central embedded point is not the continuation formulation alone, but the preconditioning and Krylov choices: preconditioning reduces required GMRES iterations from about 10 to about 1–2 in the reported setup, and MINRES requires \(7m\) vectors whereas unrestarted GMRES requires \((k_{\max}+2)m\) vectors [1506.02583]. That memory statement is directly relevant on MCU targets where Krylov basis storage is a first-order constraint.

Not all relevant computational kernels solve a nonlinear program directly. “TinyMPC: Model-Predictive Control on Resource-Constrained Microcontrollers” [2310.16985] solves convex linear MPC QPs rather than full NMPC, but its role in NMPCM is explicit: any SQP or RTI NMPC scheme relies on solving a QP at each iteration, and TinyMPC provides a low-memory ADMM core exploiting LQR/Riccati structure. On a Teensy 4.1 it is reported to be roughly \(3\)–\(8.8\times\) faster per iteration than OSQP; on a Crazyflie 2.1 with Cortex-M4F at 168 MHz, 192 kB SRAM, and 1 MB flash, TinyMPC fits where OSQP does not, and runs onboard at 500 Hz with \(N=15\) and at 100 Hz with \(N=20\) for obstacle-constrained flight, typically converging in at most 7 ADMM iterations [2310.16985].

The same “linearized-subproblem kernel” viewpoint motivates “\(\pi\)MPC: A Parallel-in-horizon and Construction-free NMPC Solver” [2601.14414]. That paper targets the linear time-varying MPC problems arising from RTI or online-linearized NMPC, but eliminates explicit MPC-to-QP construction. Using a velocity-based augmented state and ADMM, it achieves per-stage closed-form updates and horizon-wise parallel execution. For embedded use, the main consequence is that the algorithm works directly with \(\{A_{t,k},B_{t,k},e_{t,k}\}\) and convex projections, rather than assembling large condensed matrices [2601.14414]. The paper therefore treats construction-free ADMM as a code-simplicity and memory-footprint strategy for embedded NMPC pipelines.

## 4. Time-certified and execution-predictable formulations

A distinct line of work makes worst-case execution time a primary design variable. The common mechanism is to replace general nonlinear-program timing by a fixed-dimension box-QP or lifted linear MPC problem whose iteration count is known a priori.

“Time-certified Input-constrained NMPC via Koopman Operator” [2401.04653] considers an input-constrained NMPC problem, lifts the nonlinear dynamics to a linear predictor
\[
\psi_{k+1}=A\psi_k + Bu_k,\qquad y_k=C\psi_k,
\]
and condenses the resulting Koopman-based MPC problem into
\[
z^\ast=\arg\min_z \ \frac{1}{2}z^\top H z + z^\top h
\quad \text{s.t.}\quad -e\le z\le e.
\]
The solver is a feasible path-following full-Newton IPM with exact iteration count
\[
\mathcal{N}=
\left\lceil
\frac{\log\!\left(\frac{2n}{\epsilon}\right)}
{-2\log\!\left(\frac{\sqrt{2n}}{\sqrt{2n}+\sqrt{2}-1}\right)}
\right\rceil+1,
\]
depending only on \(n=Nn_u\) and the target duality-gap tolerance \(\epsilon\) [2401.04653]. In the Korteweg–de Vries example, the lifted dimension is \(n_\psi=385\), the condensed box-QP dimension is \(n=40\), \(\epsilon=10^{-6}\), and the exact iteration count is \(202\). The paper reports approximately \(8.8\times 10^6\) FLOPs per MPC step, an observed maximum solving time of about \(0.0075\) s, and satisfaction of the sampling time \(T_s=0.01\) s [2401.04653]. The same paper is explicit that this certificate holds for input constraints only; there are no state constraints in the certified formulation.

“An Execution-time-certified Riccati-based IPM Algorithm for RTI-based Input-constrained NMPC” [2402.16186] keeps the nonlinear model but inserts certification at the RTI-QP level. After one-step linearization and input scaling, the feedback-phase subproblem becomes a box-constrained QP in the stacked control increments. The IPM again uses a fixed number of iterations, but solves each Newton system via a factorized Riccati recursion whose cost scales linearly with horizon length \(N\). The paper provides explicit flop counts for both preparation and feedback phases. In the Lorenz example with \(n_x=3\), \(n_u=3\), \(N=20\), \(\Delta t=0.01\), and \(\epsilon=10^{-6}\), the QP dimension is \(n=60\), the exact number of IPM iterations is \(252\), and the total cost per sample is about \(2.27\times 10^6\) FLOPs, corresponding to approximately \(2.3\) ms on a 1 GFLOP/s processor [2402.16186].

These papers clarify an important boundary condition in the field. Time-certified NMPCM is currently strongest where the online problem can be reduced to fixed-dimension linear algebra with box input constraints. This yields rigorous timing guarantees, but it also narrows the admissible constraint class.

## 5. Learned surrogates and learned prediction models

Neural methods enter the NMPCM literature in two technically distinct ways: as controller surrogates that replace the online optimizer, and as learned models retained inside the NMPC loop.

“Hardware Neural Control of CartPole and F1TENTH Race Car” [2407.08681] is the clearest controller-distillation example. It formulates an NMPC problem offline, generates state–action supervision from the NMPC teacher, trains a small MLP neural controller \(u_\theta(x)\), and deploys that controller in quantized fixed point on a low-cost FPGA SoC. For the cart-pole task, the reported network is an MLP \(7\text{-}32\text{-}32\text{-}1\) with 1,345 parameters and latency \(3.64\,\mu\text{s}\) at 25 MHz; for F1TENTH it is \(64\text{-}64\text{-}64\text{-}2\) with 16,778 parameters, about \(80\%\) pruned to zero, and latency \(3.72\,\mu\text{s}\) [2407.08681]. The same paper explicitly maps these networks to microcontroller-scale budgets: the cart-pole controller uses about \(2.6\) kB of weights at 2 bytes per parameter and fewer than 200 bytes of activations; the F1TENTH controller uses about \(34\) kB of weights and about 1 kB of activations. The reported MAC counts are about \(1.3\)k and \(8.3\)k per inference, respectively, and the paper argues that hundreds of Hz, and in the smaller case kHz, are realistic on MCUs. In experiments, the neural controllers match NMPC in simulation and outperform it in reality because the faster control rate compensates for approximation error [2407.08681]. The same source also states that no formal proofs of stability are provided; robustness and safety are evaluated empirically.

The second route keeps optimization online but replaces the plant model by a learned model. “Introducing a Deep Neural Network-based Model Predictive Control Framework for Rapid Controller Implementation” [2310.08392] develops a DNN-based nonlinear MPC for HCCI combustion control using a compact LSTM-plus-fully-connected model with 2,260 learnable parameters. The DNN is cast into a discrete-time state-space model with LSTM internal state
\[
x(k)=\begin{bmatrix} c(k-1) \\ h(k-1) \end{bmatrix}\in\mathbb{R}^8,
\]
and is embedded into an acados-based NMPC running on an ARM Cortex-A72. The paper reports validation errors under \(5\%\) for all outputs and average optimization time \(1.4\) ms per cycle, comfortably below the available 22 ms budget at 1500 rpm [2310.08392]. It also explicitly notes that the Cortex-A72 platform is more powerful than a typical automotive or MCU-class target, so the result is better interpreted as an embedded-CPU benchmark than a direct microcontroller deployment.

A third learned-control pattern appears in “Investigation of fast-NMPC and deep learning approach in fixed-point-based hierarchical control” [2201.02044]. There, a local NMPC problem is first accelerated by a truncated fast-gradient method with fixed iteration budget \(N_{\max}=50\) and restart period \(n_{rstr}=5\), yielding \(\overline{J}=99.81\%\) relative to an Ipopt baseline at maximum computation time \(0.018\) s versus \(0.502\) s [2201.02044]. The most demanding subsystem is then replaced by a small feedforward neural network; this allows the control updating period to be reduced from \(2\) s to \(0.7\) s and improves closed-loop performance in the cryogenic refrigerator study [2201.02044]. In the language of NMPCM, this is a fixed-point and deterministic-runtime answer to the same question addressed by neural controller distillation.

## 6. Design trade-offs, limitations, and current research directions

A recurring misconception is that NMPCM must mean full online solution of the original nonlinear program on a bare-metal MCU. The literature is broader. It includes direct full nonlinear solves on Cortex-M7-class hardware [2507.21259], box-QP reductions with certified timing [2401.04653], RTI-based certified Riccati IPM [2402.16186], matrix-free first-order or Krylov methods [1709.06487; 1506.02583], and offline-learned surrogates that approximate an NMPC policy in fixed point [2407.08681]. That diversity is not merely taxonomic; it reflects genuinely different trade-offs between optimality, certification, implementation complexity, and hardware envelope.

Another persistent trade-off is between fidelity of the prediction model and problem size. “A Multirate Variational Approach to Nonlinear MPC” [2111.04811] addresses this at the discretization level by combining multirate variational integrators with tube-based successive linearization. In the Fermi–Pasta–Ulam example, increasing the multirate factor from \(p=1\) to \(p=5\) reduced total CPU time for the reported Algorithm 1 from about \(96.3\) s to about \(11.14\) s, while preserving the robust tube-based NMPC framework [2111.04811]. The same paper also shows better conservation behavior for the variational discretization than a Forward Euler scheme in the compared mechanical example. This suggests that, for MCU-scale NMPC, reducing the number of optimization nodes by multirate structure can be as consequential as changing the solver.

The limits of current timing guarantees are equally clear. Both certified lines cited above are explicit that the strongest results are obtained for input-constrained problems with box structure; the state-constrained case is not covered by the same exact complexity arguments [2401.04653; 2402.16186]. Conversely, the most flexible embedded formulations—PANOC with soft obstacle penalties, neural surrogates, or continuation methods—typically give up exact iteration or formal closed-loop certificates [1812.04755; 2407.08681; 1506.02583].

A further point of clarification concerns the status of high-speed convex MPC cores. TinyMPC and \(\pi\)MPC are not, by themselves, full NMPC solvers; TinyMPC solves convex linear MPC QPs, and \(\pi\)MPC targets linear time-varying MPC subproblems arising from RTI or online linearization [2310.16985; 2601.14414]. Their relevance to NMPCM is nevertheless direct because RTI, SQP, and many successive-linearization methods reduce online nonlinear control to repeated structured convex subproblems. In that setting, low-memory ADMM, Riccati recursion, and construction-free stage-wise updates become enabling technologies rather than adjacent curiosities.

The field therefore remains defined by a set of coupled design decisions rather than a single canonical algorithm: whether to solve the nonlinear program online or distill it offline; whether to certify time or certify only empirical performance; whether to retain state constraints explicitly or absorb them into soft penalties or tubes; whether to spend resources on model fidelity, multirate structure, or solver acceleration; and whether the target is a Cortex-M-class MCU, a Cortex-A-class embedded CPU, or FPGA-assisted logic. The current literature indicates that all of these choices can produce viable NMPCM systems, but under different assumptions, constraint classes, and guarantees.

Source: https://www.emergentmind.com/topics/nmpc-on-microcontrollers-nmpcm