From 8982fe87c403cdfefd59396dbaf0a1c4d609a804 Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Tue, 15 Sep 2026 16:54:21 +0000 Subject: [PATCH] Add README.md --- README.en.md | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 README.en.md create mode 100644 README.md diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..9e207c0 --- /dev/null +++ b/README.en.md @@ -0,0 +1,128 @@ +# Electronic Control System Firmware + +## Project Introduction + +This project is firmware for a robot chassis electronic control system based on the STM32F4 series microcontroller, adopting the FreeRTOS real-time operating system. It implements complete robot motion control, motor driving, sensor data acquisition, and remote control functions. + +## Hardware Platform + +- **Main Controller**: STM32F4 Series +- **Motor Driver**: C620 Brushless DC Motors ×4 (Mecanum Wheel Chassis Configuration: Left Front, Right Front, Left Rear, Right Rear) +- **Sensor**: MPU6600 6-axis Inertial Measurement Unit +- **Communication Interfaces**: CAN1/CAN2 Dual Bus, SPI, UART (including DMA) +- **Remote Control Receiver**: Supports mainstream receivers such as FS-i6X + +## Software Architecture + +### Operating System +- **FreeRTOS** - Real-time Multi-task Operating System + +### Core Tasks +| Task Name | Priority | Function Description | +|--------|--------|----------| +| DefaultTask | Default | System Initialization and Basic Tasks | +| Motor | High | Motor Control and Data Processing | +| MovementCal | Medium | Kinematics Calculation and PID Control | +| MCU6600 | Medium | IMU Sensor Data Acquisition | +| HeartBeat | Low | System Heartbeat Monitoring | +| RCcontrol | High | Remote Control Signal Reception and Processing | + +### System Synchronization Mechanism +- **Semaphores**: SPIDMASem (RCSem) - SPI and RC Communication Synchronization + +## Module Description + +### Low-Level Drivers (User/Low_level_Driver) +- **MySPI.c/h** - SPI Bus Encapsulation Management +- **Mycan.c/h** - CAN Bus Driver, Supports Filtering and Transmission +- **drv_uart.c/h** - UART DMA Communication Driver + +### Middleware (User/Middle_Level) +- **MyMotor.c/h** - C620 Motor Control Interface +- **MovementCalculate.c/h** - Kinematics Calculation and PID Control +- **PID.c/h** - PID Controller Implementation +- **MyMPU.c/h** - MPU6600 Sensor Driver +- **Kalman_filter.c/h** - Kalman Filter +- **PowerControl.c/h** - Power Control +- **drag_compresation.c/h** - Drag Compensation Algorithm + +### RTOS Task Layer (User/RTOS) +- **Motor_RTOS.c/h** - Motor Control Task +- **Calculate_RTOS.c/h** - Calculation Task +- **MPU_RTOS.c/h** - IMU Data Processing Task +- **RC_RTOS.c/h** - Remote Control Task +- **Heart_RTOS.c/h** - Heartbeat Monitoring Task + +### Tools Layer (User/Tools) +- **dvc_serialplot.c/h** - Serial Plotter Tool +- **Vofa.c/h** - VOFA+ Host Computer Communication +- **FS_i6X.c/h** - FS-i6X Remote Control Decoder + +## Functional Features + +- **Mecanum Wheel Chassis Control**: Supports omnidirectional movement, in-place rotation, and other motion modes +- **Multi-Motor Coordination**: 4 C620 motors independent closed-loop control +- **Attitude Estimation**: Kalman Filter Fusion of IMU Data +- **PID Speed Regulation**: Position Loop, Velocity Loop, Current Loop Triple-Layer Control +- **Power Limiting**: Real-time Power Monitoring and Limiting +- **Remote Control/UART Dual Mode**: Supports Remote Control Manual Mode and UART Command Mode +- **Data Visualization**: Supports SerialPlot and VOFA+ Real-time Curve Display + +## Interface Definition + +### CAN Communication +- CAN1: Chassis Right Side Motors (Left Front / Left Rear) +- CAN2: Chassis Right Side Motors (Right Front / Right Rear) +- Motor IDs: 0x1FF, 0x200, 0x2FF + +### Remote Control Channels +| Channel | Function | +|------|------| +| CH1 | Left/Right Steering (X Axis) | +| CH2 | Forward/Backward Movement (Y Axis) | +| CH3 | Rotation Speed (Z Axis) | +| CH4-6 | Auxiliary Functions | + +## Usage Instructions + +### Development Environment +- Keil MDK-ARM or STM32CubeIDE +- STM32F4xx Firmware Library +- FreeRTOS Kernel + +### Compilation Configuration +1. Generate initialization code using STM32CubeMX +2. Replace files under Src and Inc directories +3. Configure FreeRTOS parameters (Stack Size, Task Priority) +4. Compile and download to target board + +### Parameter Tuning Tools +- **SerialPlot**: View Real-time Variable Waveforms +- **VOFA+**: Host Computer Data Visualization +- Connect via UART1 for debugging data output + +## Precautions + +1. CAN Bus Termination Resistors Must Be Correctly Configured +2. Motor Power Supply Must Be Isolated from Control Circuit Power Supply +3. IMU Sensor Calibration Required for First Use +4. PID Parameters Must Be Adjusted Based on Actual Mechanical Structure +5. Motion Testing Recommended in a Safe Environment + +## File Structure + +``` +. +├── Inc/ # HAL Library Header Files +├── Src/ # HAL Library Source Files +├── User/ +│ ├── Low_level_Driver/ # Low-Level Drivers +│ ├── Middle_Level/ # Middleware Algorithms +│ ├── RTOS/ # RTOS Tasks +│ └── Tools/ # Tool Functions +└── README.md +``` + +## Version Information + +The current version supports complete chassis motion control functions and can be secondary developed and parameter adjusted according to specific requirements. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a647b3b --- /dev/null +++ b/README.md @@ -0,0 +1,130 @@ + + +# 电控系统固件 + +## 项目简介 + +本项目是基于STM32F4系列微控制器的机器人底盘电控系统固件,采用FreeRTOS实时操作系统,实现了完整的机器人运动控制、电机驱动、传感器数据采集和远程控制功能。 + +## 硬件平台 + +- **主控芯片**: STM32F4系列 +- **电机驱动**: C620无刷直流电机 ×4(麦轮底盘配置:左前、右前、左后、右后) +- **传感器**: MPU6600六轴惯性测量单元 +- **通信接口**: CAN1/CAN2双总线、SPI、UART(含DMA) +- **遥控接收机**: 支持FS-i6X等主流遥控接收机 + +## 软件架构 + +### 操作系统 +- **FreeRTOS** - 实时多任务操作系统 + +### 核心任务 +| 任务名 | 优先级 | 功能描述 | +|--------|--------|----------| +| DefaultTask | 默认 | 系统初始化和基础任务 | +| Motor | 高 | 电机控制与数据处理 | +| MovementCal | 中 | 运动学计算与PID控制 | +| MCU6600 | 中 | IMU传感器数据采集 | +| HeartBeat | 低 | 系统心跳监测 | +| RCcontrol | 高 | 遥控器信号接收与处理 | + +### 系统同步机制 +- **信号量**: SPIDMASem(RCSem) - SPI和RC通信同步 + +## 模块说明 + +### 底层驱动 (User/Low_level_Driver) +- **MySPI.c/h** - SPI总线封装管理 +- **Mycan.c/h** - CAN总线驱动,支持滤波和发送 +- **drv_uart.c/h** - UART DMA通信驱动 + +### 中间层 (User/Middle_Level) +- **MyMotor.c/h** - C620电机控制接口 +- **MovementCalculate.c/h** - 运动学计算与PID控制 +- **PID.c/h** - PID控制器实现 +- **MyMPU.c/h** - MPU6600传感器驱动 +- **Kalman_filter.c/h** - 卡尔曼滤波 +- **PowerControl.c/h** - 功率控制 +- **drag_compresation.c/h** - 拖曳补偿算法 + +### RTOS任务层 (User/RTOS) +- **Motor_RTOS.c/h** - 电机控制任务 +- **Calculate_RTOS.c/h** - 计算任务 +- **MPU_RTOS.c/h** - IMU数据处理任务 +- **RC_RTOS.c/h** - 遥控控制任务 +- **Heart_RTOS.c/h** - 心跳监测任务 + +### 工具层 (User/Tools) +- **dvc_serialplot.c/h** - 串口绘图工具 +- **Vofa.c/h** - VOFA+上位机通信 +- **FS_i6X.c/h** - FS-i6X遥控器解码 + +## 功能特性 + +- **麦轮底盘控制**: 支持全向移动、原地旋转等运动模式 +- **多电机协同**: 4个C620电机独立闭环控制 +- **姿态解算**: 卡尔曼滤波融合IMU数据 +- **PID调速**: 位置环、速度环、电流环三环控制 +- **功率限制**: 实时功率监控与限制 +- **遥控/串口双模式**: 支持遥控器手动控制和串口指令控制 +- **数据可视化**: 支持SerialPlot和VOFA+实时曲线显示 + +## 接口定义 + +### CAN通信 +- CAN1: 底盘右侧电机(左前/左后) +- CAN2: 底盘右侧电机(右前/右后) +- 电机ID: 0x1FF、0x200、0x2FF + +### 遥控通道 +| 通道 | 功能 | +|------|------| +| CH1 | 左右转向(X轴) | +| CH2 | 前后移动(Y轴) | +| CH3 | 旋转速度(Z轴) | +| CH4-6 | 辅助功能 | + +## 使用说明 + +### 开发环境 +- Keil MDK-ARM 或 STM32CubeIDE +- STM32F4xx固件库 +- FreeRTOS内核 + +### 编译配置 +1. 使用STM32CubeMX生成初始化代码 +2. 替换Src和Inc目录下的文件 +3. 配置FreeRTOS参数(堆栈大小、任务优先级) +4. 编译并下载到目标板 + +### 调参工具 +- **SerialPlot**: 查看实时变量波形 +- **VOFA+**: 上位机数据可视化 +- 通过UART1连接进行调试数据输出 + +## 注意事项 + +1. CAN总线终端电阻需正确配置 +2. 电机电源需与控制电路电源隔离 +3. 首次使用需校准IMU传感器 +4. PID参数需根据实际机械结构调整 +5. 建议在安全环境中进行运动测试 + +## 文件结构 + +``` +. +├── Inc/ # HAL库头文件 +├── Src/ # HAL库源文件 +├── User/ +│ ├── Low_level_Driver/ # 底层驱动 +│ ├── Middle_Level/ # 中间层算法 +│ ├── RTOS/ # RTOS任务 +│ └── Tools/ # 工具函数 +└── README.md +``` + +## 版本信息 + +当前版本支持完整的底盘运动控制功能,可根据具体需求进行二次开发和参数调整。 \ No newline at end of file -- Gitee