# Jump Bot **Repository Path**: seaoftranquility/jumpbot ## Basic Information - **Project Name**: Jump Bot - **Description**: 控制弹跳机器人驱动程序 使用 stm32 c8t6 芯片 n20 舵机 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-06 - **Last Updated**: 2026-08-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # jumpbot (STM32F103C8T6 + IR + TB6612FNG + SG90) Bare-minimum Keil5 firmware for the current jump prototype: - Decode a full **NEC IR** frame on `PA0`. - While a jump is running, ignore IR. - Keep the SG90 at the latch-holding position. - Use TB6612 motor A to wind the string. - Use TB6612 motor B as a short release pulse. - Sleep with `__WFI()` while idle. ## Documentation - Project guide: `docs/README.md` - Architecture, flowcharts, signals, pins, and properties: `docs/architecture.md` - Troubleshooting log and fixes: `docs/troubleshooting.md` ## Where The Main Program Lives - `Src/main.c` is the board startup file: HAL init, clock setup, GPIO setup, timer setup, and interrupt callbacks. - `Src/app.c` is the robot behavior: `APP_Loop()` is called forever from `main()` and contains the jump state machine. - `Inc/app.h` is the tuning panel: wind duty/RPM, release pulse time, and servo hold pulse. - `Inc/tb6612.h` is the TB6612 direction-pin map. ## Current Jump Sequence 1. `IDLE`: wait for a valid NEC frame. 2. `HOLDING`: servo moves/stays at `APP_SERVO_HOLD_US` so the latch can resist torque. 3. `WINDING`: motor A winds the string for an estimated 5 revolutions. 4. `RELEASING`: motor A coasts; motor B pulses forward for `APP_RELEASE_PULSE_MS`. 5. Return to `IDLE`; servo remains at the holding position. ## Pin Map - IR receiver OUT: `PA0` / `TIM2_CH1` - TB6612 motor A winding PWM: `PA6` / `TIM3_CH1` / `PWMA` - TB6612 motor A direction: `PB0` / `PB1` / `AIN1` / `AIN2` - TB6612 motor B release PWM: `PA7` / `TIM3_CH2` / `PWMB` - TB6612 motor B direction: `PB10` / `PB11` / `BIN1` / `BIN2` - TB6612 standby: `PB12` / `STBY` - SG90 servo hold PWM: `PB6` / `TIM4_CH1` ## Changing Pins Keep this simple: update both the peripheral setup and the abstraction that uses it. - Motor direction pins: update `Inc/tb6612.h` and `MX_GPIO_Init()` in `Src/main.c`. - Motor PWM pins: update `MX_GPIO_Init()`, `MX_TIM3_Init()`, and channel usage in `Src/app.c`. - IR pin: update `MX_GPIO_Init()`, `MX_TIM2_Init()`, and `IR_NEC_Init(...)` in `Src/app.c`. - Servo pin: update `MX_GPIO_Init()`, `MX_TIM4_Init()`, and the timer channel passed to `SERVO_SG90_SetPulseUs(...)`. ## Power Reality Check Your 10g battery/boost supply is tight: - Rated output: 5V at 200mA - Short max: 1A for 60s - Cell capacity: 3.7V at 250mAh That is likely enough for STM32 + IR, but marginal for SG90 holding torque plus loaded N20 motors. A stalled motor or loaded servo can pull several hundred mA each. For first tests: - Start with low duty: `APP_WIND_DUTY_PERMILLE = 350`, `APP_RELEASE_DUTY_PERMILLE = 350`. - Test motor A and motor B separately before the full jump. - Add a bulk capacitor near TB6612/servo power, e.g. 470uF to 1000uF. - Common ground is required between battery/boost, STM32, TB6612, IR, and servo. ## Calibration Tune these in `Inc/app.h`: - `APP_WIND_DUTY_PERMILLE`: default `350` = 35%. - `APP_WIND_RPM_AT_DUTY`: estimated winding motor RPM under load at that duty. - `APP_WIND_REVOLUTIONS`: default `5`. - `APP_RELEASE_DUTY_PERMILLE`: default `350` = 35%. - `APP_RELEASE_PULSE_MS`: default `300`. - `APP_SERVO_HOLD_US`: default `2000`. Wind run time is computed as: ```text time_ms = APP_WIND_REVOLUTIONS * 60000 / APP_WIND_RPM_AT_DUTY ``` ## Build Open `Projects/MDK-ARM/jumpbot.uvprojx` in Keil and build. The generated CubeMX code did not include timer init, so this project has manual `MX_TIM2_Init`, `MX_TIM3_Init`, `MX_TIM4_Init`, GPIO setup, and HAL callbacks in `Src/main.c`. Avoid regenerating from CubeMX unless you first configure those peripherals in the `.ioc`, or CubeMX may overwrite the manual integration. ## Bring-Up Checklist - Verify IR receiver output idles high and pulses low when receiving IR. - With motors disconnected, confirm one NEC press enters the sequence and extra presses are ignored while active. - Confirm `PA6` PWM appears during winding and motor A winds in the correct direction. - Confirm `PA7` PWM appears for about 300ms during release and motor B trips the latch. - Confirm servo holds the latch at `APP_SERVO_HOLD_US` and current draw is acceptable. - If the board resets during winding/release, the battery/boost rail is sagging.