-
Notifications
You must be signed in to change notification settings - Fork 0
Add Pixhawk 6C ↔ Teensy 4.1 UART/MAVLink plan and Teensy example #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,140 @@ | ||||||||||||
| # Pixhawk 6C + Teensy 4.1 (UART/MAVLink, ArduPilot) Plan and Example Code | ||||||||||||
|
|
||||||||||||
| This document provides a concrete plan for connecting a Pixhawk 6C running ArduPilot to a Teensy 4.1 over UART/MAVLink, along with example code for both sides. | ||||||||||||
|
|
||||||||||||
| ## 1) Hardware + Wiring Plan (UART/MAVLink) | ||||||||||||
|
|
||||||||||||
| **Primary link:** Pixhawk 6C TELEM port ↔ Teensy 4.1 UART (Serial). | ||||||||||||
|
|
||||||||||||
| **Key points** | ||||||||||||
| - **Logic levels:** Pixhawk 6C and Teensy 4.1 are 3.3V logic. No level shifting needed. | ||||||||||||
| - **Baud rate:** Start at **57600** or **115200**. | ||||||||||||
| - **Ground:** Always connect grounds (GND ↔ GND). | ||||||||||||
| - **Power:** Power Teensy via its own 5V/USB or regulated 5V; avoid drawing from Pixhawk unless the port is rated for it. | ||||||||||||
|
|
||||||||||||
| **Example wiring (TELEM1):** | ||||||||||||
| - Pixhawk TELEM1 **TX** → Teensy **RX** (e.g., Serial1 RX pin) | ||||||||||||
| - Pixhawk TELEM1 **RX** ← Teensy **TX** (e.g., Serial1 TX pin) | ||||||||||||
| - Pixhawk **GND** ↔ Teensy **GND** | ||||||||||||
|
|
||||||||||||
| ## 2) ArduPilot Firmware Configuration (Pixhawk) | ||||||||||||
|
|
||||||||||||
| Use Mission Planner or MAVProxy to set: | ||||||||||||
| - `SERIAL1_PROTOCOL = 2` (MAVLink2) | ||||||||||||
| - `SERIAL1_BAUD = 57` or `115` (57,600 or 115,200) | ||||||||||||
|
|
||||||||||||
| Confirm telemetry on the selected TELEM port and reboot. | ||||||||||||
|
|
||||||||||||
| ## 3) MAVLink Message Plan | ||||||||||||
|
|
||||||||||||
| Minimal message set for control: | ||||||||||||
| - **HEARTBEAT** (Pixhawk ↔ Teensy) for link status | ||||||||||||
| - **SET_MODE** (Teensy → Pixhawk) to arm and set flight mode | ||||||||||||
| - **COMMAND_LONG** for arming and other commands | ||||||||||||
| - **RC_CHANNELS_OVERRIDE** or **MANUAL_CONTROL** to send control inputs | ||||||||||||
| - **ATTITUDE / LOCAL_POSITION_NED** telemetry for feedback | ||||||||||||
|
|
||||||||||||
| ## 4) Teensy 4.1 Example Code (UART MAVLink) | ||||||||||||
|
|
||||||||||||
| This is a concise example showing how to: | ||||||||||||
| - Receive MAVLink messages from Pixhawk | ||||||||||||
| - Send a HEARTBEAT | ||||||||||||
| - Arm/disarm and send a simple roll/pitch/yaw/throttle command | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+42
to
+43
|
||||||||||||
| - Arm/disarm and send a simple roll/pitch/yaw/throttle command | |
| - Illustrate how you would structure arming/disarming and simple roll/pitch/yaw/throttle commands | |
| > **Important:** A safe arming/control sequence must at minimum: wait for a HEARTBEAT from the Pixhawk, send an arm command (e.g., via `COMMAND_LONG`), wait for a successful `COMMAND_ACK` or confirmed armed state, and only then begin sending control inputs (such as `RC_CHANNELS_OVERRIDE` or `MANUAL_CONTROL`). | |
| > |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The heartbeat identifies this device as MAV_TYPE_GCS, but the document describes a Teensy companion/onboard controller. Using MAV_TYPE_ONBOARD_CONTROLLER (or another appropriate onboard type) better matches the role and can affect how some systems classify the component.
| MAV_TYPE_GCS, | |
| MAV_TYPE_ONBOARD_CONTROLLER, |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example only sends a HEARTBEAT once in setup(). MAVLink peers generally expect heartbeats to be sent periodically (commonly ~1 Hz) to maintain link state and for the autopilot to consider the companion “present”. Consider sending heartbeat on a timer inside loop().
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MANUAL_CONTROL axis ranges are not all -1000..1000: x/y/r are typically -1000..1000, but z (throttle) is generally 0..1000 per MAVLink common definition. Please correct the range note to avoid encouraging invalid throttle values.
| // Example: send manual control (range -1000..1000) | |
| // Example: send manual control (x/y/r: -1000..1000, z (throttle): 0..1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SET_MODEdoes not arm/disarm the vehicle; arming is done viaMAV_CMD_COMPONENT_ARM_DISARM(typicallyCOMMAND_LONG) andSET_MODE/MAV_CMD_DO_SET_MODEis for mode changes. Please update this bullet to avoid implying that arming is performed viaSET_MODE.