From e23216b3a11b9edae9ed375d8974b3e5b77c4720 Mon Sep 17 00:00:00 2001 From: MangaValk Date: Sat, 14 Nov 2026 12:19:16 +0100 Subject: [PATCH] 2026 remote: build for the Teensy 4.0 actually in the remote Board teensy41 -> teensy40. All pins exist on the 4.0; the MPU6050's Wire2 (SDA2 25 / SCL2 24) is on the underside solder pads. Co-Authored-By: Claude Opus 5.5 --- 2026-current/CLAUDE.md | 10 +++++----- 2026-current/README.md | 2 +- 2026-current/hardware/openscad/PLANNING.md | 4 ++-- 2026-current/platformio.ini | 4 ++-- 2026-current/remote/Config.h | 8 +++++--- 2026-current/remote/README.md | 8 ++++---- 2026-current/remote/remote.ino | 2 +- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/2026-current/CLAUDE.md b/2026-current/CLAUDE.md index 61abd47..f63aa2f 100644 --- a/2026-current/CLAUDE.md +++ b/2026-current/CLAUDE.md @@ -10,7 +10,7 @@ before changing anything. ``` robot/ Teensy 3.6 firmware (PlatformIO env robot) -remote/ Teensy 4.1 firmware (PlatformIO env remote) +remote/ Teensy 4.0 firmware (PlatformIO env remote) shared/HexapodProtocol/ wire protocol, used by robot, remote and sim sim/ robot firmware -> hexapod_sim.dll (CMake + g++), headless smoke test Hexapod_Simulation_Unity/ Unity 6000.6 project that loads the DLL (Assets/HexapodSim/) @@ -34,7 +34,7 @@ PlatformIO, one `platformio.ini`, two environments: | Env | Board | Sketch dir | Purpose | |-----|-------|------------|---------| | `robot` | `teensy36` | `robot/` | walking robot | -| `remote` | `teensy41` | `remote/` | handheld transmitter | +| `remote` | `teensy40` | `remote/` | handheld transmitter | - `shared/` is PlatformIO's `lib_dir`. `shared/HexapodProtocol/` is a header-only library both sketches `#include `. @@ -108,7 +108,7 @@ joint-rate clamp → servos. | `Comms` | nRF24 RX, link timeout, `injectPacket()` for the harness | | `ServoDriver` | 18 servos on hardware PWM (50 Hz, 16-bit), per-servo calibration from `Config.h` `SERVOS`, duty 0 = relaxed, skips invalid IK solutions | -## Remote architecture (`remote/`, Teensy 4.1) +## Remote architecture (`remote/`, Teensy 4.0) Loop: drain Nextion + USB serial input every pass. On each `TX_HZ` (100) tick: sticks → IMU → radio link status → RemoteState (smoothers, @@ -366,7 +366,7 @@ Robot (`robot/README.md` has detail): Remote (`remote/README.md` has detail): - Pins in `remote/Config.h`, taken from the old remote sketch: radio CE 9 / CSN 10, sticks A0–A5, Nextion on Serial1 (0/1). The MPU6050 is on - **Wire2 (25/24)**, since A4/A5 = Wire's SDA/SCL are stick pins; that's + **Wire2 (25/24, solder pads under the Teensy 4.0)**, since A4/A5 = Wire's SDA/SCL are stick pins; that's the owner's choice and needs rewiring the MPU. Which stick axis is on which pin is still unknown. - `STICK_INVERT[]`, calibration defaults, deadzones, expo. @@ -393,7 +393,7 @@ Remote (`remote/README.md` has detail): - `b2` → **Nextion upload passthrough**: shows `uploadscreen`, then bridges USB ↔ Serial1 forever, so Nextion Editor can upload a `.tft` through the remote's USB port. The new firmware keeps this. - - Sticks on **A0–A5**, contiguous (`analogInPin + i`). On the Teensy 4.1, + - Sticks on **A0–A5**, contiguous (`analogInPin + i`). On the Teensy 4.0, A4/A5 are pins 18/19 = Wire SDA/SCL, which the MPU6050 needs. The old code had the MPU code disabled (`if (false)`). Owner's decision: keep the sticks, move the MPU to Wire2. diff --git a/2026-current/README.md b/2026-current/README.md index d769ebb..7723071 100644 --- a/2026-current/README.md +++ b/2026-current/README.md @@ -1,7 +1,7 @@ # Hexapod A six-legged walking robot (Teensy 3.6) and its handheld remote -(Teensy 4.1 + Nextion touchscreen), linked over nRF24L01. +(Teensy 4.0 + Nextion touchscreen), linked over nRF24L01. ![The hexapod, OpenSCAD model in its standing pose](hardware/openscad/renders/hexapod.png) ![The remote, OpenSCAD model](hardware/openscad/renders/remote.png) diff --git a/2026-current/hardware/openscad/PLANNING.md b/2026-current/hardware/openscad/PLANNING.md index fa98e19..d3b11dd 100644 --- a/2026-current/hardware/openscad/PLANNING.md +++ b/2026-current/hardware/openscad/PLANNING.md @@ -129,8 +129,8 @@ Also from the owner: the bump on top of the middle post is a lanyard loop (the original's tunnel through it is modelled); the square hole is the on/off slide switch, mounted on top (same switch as the robot). Inside: an IMU on the 21 x 9 mm block (assumed GY-521), a USB-C breakout on the side-port block, and -a Teensy **4.0** (confirmed by the owner, although `platformio.ini` builds -the remote for a 4.1); it has no mounting holes and is placed on the +a Teensy **4.0** (confirmed by the owner; `platformio.ini` now builds +the remote for it); it has no mounting holes and is placed on the hole-less 8 x 24 mm block as a guess. Open: what the 6 mm x 10 mm holes in the bottom bosses hold (magnets?), and whether the upper two bosses are meant to be asymmetric (x -80.387 / +82.73). diff --git a/2026-current/platformio.ini b/2026-current/platformio.ini index a095162..9d09239 100644 --- a/2026-current/platformio.ini +++ b/2026-current/platformio.ini @@ -1,6 +1,6 @@ ; Hexapod: two firmware images in one project. ; pio run -e robot build robot/ (Teensy 3.6) -; pio run -e remote build remote/ (Teensy 4.1) +; pio run -e remote build remote/ (Teensy 4.0) ; pio run -e robot -t upload flash (Teensy Loader / teensy_cli) ; pio device monitor -e robot serial monitor at 115200 ; @@ -25,5 +25,5 @@ board = teensy36 custom_src_dir = robot [env:remote] -board = teensy41 +board = teensy40 custom_src_dir = remote diff --git a/2026-current/remote/Config.h b/2026-current/remote/Config.h index 2400ad8..20b2f4c 100644 --- a/2026-current/remote/Config.h +++ b/2026-current/remote/Config.h @@ -2,7 +2,7 @@ #include // ===================================================================== -// Remote handset config (Teensy 4.1). Everything here is a placeholder +// Remote handset config (Teensy 4.0). Everything here is a placeholder // until checked against your real wiring and parts - see the BENCH notes. // Radio address/channel/rate/PA/payload size are NOT here: they live in // shared/HexapodProtocol so they can't drift from the robot. @@ -69,8 +69,10 @@ constexpr float STICK_EXPO[NUM_AXES] = { 0.25f, 0.25f, 0.30f, 0.20f, 0.20f, // One-pole low-pass on raw ADC counts (1 = no filtering). Pots are noisy. constexpr float STICK_FILTER_ALPHA = 0.5f; -// ---- Remote IMU: MPU6050 on the second I2C bus (Wire2: SDA2 = 25, SCL2 = 24) ---- -// Not Wire (18/19): those pins are stick axes A4/A5. +// ---- Remote IMU: MPU6050 on the third I2C bus (Wire2: SDA2 = 25, SCL2 = 24) ---- +// On the Teensy 4.0, 24/25 are solder pads on the underside, not edge pins. +// Not Wire (18/19): those pins are stick axes A4/A5. Not Wire1 (17/16) either: +// those are stick axes A3/A2. #define IMU_WIRE Wire2 constexpr uint8_t IMU_ADDR = 0x68; // 0x69 if AD0 is pulled high // Mounting remap: which chip axis (0=X,1=Y,2=Z) and sign gives each handset diff --git a/2026-current/remote/README.md b/2026-current/remote/README.md index 4f0e10a..6777174 100644 --- a/2026-current/remote/README.md +++ b/2026-current/remote/README.md @@ -1,4 +1,4 @@ -# Hexapod remote firmware (Teensy 4.1) +# Hexapod remote firmware (Teensy 4.0) Handheld transmitter for the hexapod. It reads two 3-axis twist-grip joysticks and an MPU6050, takes operator commands from a Nextion @@ -13,17 +13,17 @@ From the `2026-current` folder: `pio run -e remote`, flash with ## Wiring (from the old remote sketch in `../../2019-teensy-nrf24/remote/`; edit `Config.h` if yours differs) -| Part | Signal | Teensy 4.1 pin | +| Part | Signal | Teensy 4.0 pin | |------|--------|----------------| | nRF24L01 | MOSI / MISO / SCK | 11 / 12 / 13 (SPI0) | | nRF24L01 | CE / CSN | 9 / 10 | | nRF24L01 | VCC | 3.3 V, with a 10–100 µF cap right at the module | -| MPU6050 | SDA / SCL | **25 / 24 (Wire2)**: not 18/19, those are stick pins A4/A5 | +| MPU6050 | SDA / SCL | **25 / 24 (Wire2)**, solder pads on the underside of the 4.0: not 18/19, those are stick pins A4/A5 | | Nextion | TX → RX1, RX ← TX1 | 0 / 1 (Serial1), 5 V supply | | Sticks | 6 axes | A0–A5. Which axis is on which pin isn't known yet: reorder `STICK_PINS` until the `p` dump reads right | **MPU6050 rewiring:** the old remote had its MPU code switched off, probably -because A4/A5 double as Wire's pins. Move the MPU's SDA/SCL to pins 25/24. +because A4/A5 double as Wire's pins. Move the MPU's SDA/SCL to pins 25/24 (the pads under the board). Stick pots are wired 3.3 V – wiper – GND. **Never feed 5 V into a Teensy 4.x analog pin.** diff --git a/2026-current/remote/remote.ino b/2026-current/remote/remote.ino index 683c670..a1ff648 100644 --- a/2026-current/remote/remote.ino +++ b/2026-current/remote/remote.ino @@ -7,7 +7,7 @@ #include "NextionUI.h" #include "SerialConsole.h" -// Hexapod remote (Teensy 4.1): reads two 3-axis sticks and the handset +// Hexapod remote (Teensy 4.0): reads two 3-axis sticks and the handset // MPU6050, takes operator commands from the Nextion touchscreen (and the USB // serial console), and transmits a CmdPacket to the robot at TX_HZ. // See README.md for wiring, calibration and the serial key map.