Embedded · 1 min read

Hello: a blog about Embedded, AI and Robotics

The first post: introducing the blog and testing features like code, math and diagrams.

🌐 Đọc bằng tiếng Việt

Hi there! This is where I document my projects and notes on embedded systems, AI and robotics.

C code highlighting

#include "stm32f4xx_hal.h"

int main(void) {
    HAL_Init();
    __HAL_RCC_GPIOA_CLK_ENABLE();
    GPIO_InitTypeDef gpio = { .Pin = GPIO_PIN_5, .Mode = GPIO_MODE_OUTPUT_PP };
    HAL_GPIO_Init(GPIOA, &gpio);
    while (1) {
        HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
        HAL_Delay(500);
    }
}

Math

A discrete PID controller:

u[k]=Kp e[k]+Ki∑j=0ke[j] Δt+Kd e[k]−e[k−1]Δtu[k] = K_p\,e[k] + K_i \sum_{j=0}^{k} e[j]\,\Delta t + K_d\,\frac{e[k]-e[k-1]}{\Delta t}

Inline math: fs≥2fmaxf_s \ge 2 f_{max} (Nyquist theorem).

Diagram

flowchart LR
  S[IMU sensor] -->|I2C| M[MCU]
  M -->|UART| P[Raspberry Pi]
  P --> AI[AI model]
  AI -->|commands| M
  M --> D[Motors]

Python

import numpy as np

def moving_average(x: np.ndarray, n: int = 5) -> np.ndarray:
    return np.convolve(x, np.ones(n) / n, mode="valid")