mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 02:16:53 +08:00
feat(heater): Add multi-instance support for heaters (#26325)
* heater: add multi-instance support, refactor parameter handling, remove legacy params file
This change introduces multi-instance heater support to allow independent temperature control for multiple IMUs.
Main changes:
- Add support for multiple heater instances
- Refactor parameter handling to use per-instance parameters
- Remove the legacy parameter file and migrate to the updated parameter structure
This improves scalability and makes heater configuration consistent across setups with multiple sensors.
* Refactor heater configuration across multiple boards
- Updated heater GPIO definitions to introduce a new naming convention for better clarity and consistency.
- Replaced `GPIO_HEATER_OUTPUT` with `GPIO_HEATER1_OUTPUT` and adjusted the corresponding output enable macros.
- Changed parameter names from `SENS_TEMP_ID` to `HEATER1_IMU_ID` in various board default configurations to reflect the new heater setup.
- Ensured all affected board configurations are updated to maintain functionality with the new heater definitions.
* heater: fix missing HEATER1_OUTPUT_EN control
* heater: fix more missing HEATER1_OUTPUT_EN control
* heater: tidy config, docs, and instance handling
- Remove unused controller period member and use CONTROLLER_PERIOD_DEFAULT
- Improve HEATER${i}_IMU_ID description and instance-related logging/behavior
- Add a guard when HEATER_NUM exceeds HEATER_MAX_INSTANCES
Note: drop intermediate/reverted change around the 'celsius' spelling.
* heater: refactor constructor to remove unused parameter and add instance name function
- Remove unused ModuleParams argument from Heater constructor
- Add heater_instance_name() helper to provide per-instance work queue task names
- Use instance-specific parameter lookup (HEATER{n}_*) during initialization
Use heater_instance_name() to label each instance (heater_1/2/3) in work queue.
Also drop unused ModuleParams argument from constructor and keep per-instance
parameter handle lookup in initialization.
* format
* board: update GPIO configuration for multiple heater instances, add HEATER_NUM for boards using PX4IO
* heater: update heater control to use HEATER1_OUTPUT_EN when using PX4IO for consistency
* heater: add a TODO for px4io multi-instance
* heater: update missing GPIO_HEATER1_OUTPUT in sky-drones
* heater: fix multiple newlines at EOF (resolve CI check failure)
* heater: switch to PublicationMulti for heater_status and log multi-instance
- Changed _heater_status_pub from Publication to PublicationMulti to support independent per-instance publications without overwriting.
- Updated logged_topics.cpp to use add_optional_topic_multi("heater_status")
This fixes the issue where multiple heater instances were writing to the same heater_status topic, causing data overwriting and incorrect update rates in logs.
---------
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
This commit is contained in:
@@ -10,7 +10,7 @@ param set-default SER_TEL2_BAUD 921600 # 921600
|
||||
|
||||
# Temperature stabilization
|
||||
param set-default SENS_EN_THERMAL 1 # Enable heater
|
||||
param set-default SENS_TEMP_ID 2359314 # Heated IMU ID
|
||||
param set-default HEATER1_IMU_ID 2359314 # Heated IMU ID
|
||||
|
||||
# Battery scaling
|
||||
param set-default BAT1_N_CELLS 4
|
||||
|
||||
@@ -178,8 +178,10 @@
|
||||
/* HEATER
|
||||
* PWM in future
|
||||
*/
|
||||
#define GPIO_HEATER_OUTPUT /* PB10 T2CH3 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN10)
|
||||
#define HEATER_OUTPUT_EN(on_true) px4_arch_gpiowrite(GPIO_HEATER_OUTPUT, (on_true))
|
||||
#define GPIO_HEATER_OUTPUT
|
||||
#define HEATER_NUM 1
|
||||
#define GPIO_HEATER1_OUTPUT /* PB10 T2CH3 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN10)
|
||||
#define HEATER1_OUTPUT_EN(on_true) px4_arch_gpiowrite(GPIO_HEATER1_OUTPUT, (on_true))
|
||||
|
||||
/* PC12 is nARMED
|
||||
* The GPIO will be set as input while not armed HW will have external HW Pull UP.
|
||||
@@ -335,7 +337,7 @@
|
||||
GPIO_CAN1_RX, \
|
||||
GPIO_CAN2_TX, \
|
||||
GPIO_CAN2_RX, \
|
||||
GPIO_HEATER_OUTPUT, \
|
||||
GPIO_HEATER1_OUTPUT, \
|
||||
GPIO_VDD_3V5_LTE_nEN, \
|
||||
GPIO_VDD_3V5_LTE_nOC, \
|
||||
GPIO_VDD_5V_HIPOWER_nEN, \
|
||||
|
||||
@@ -253,8 +253,8 @@ __EXPORT int board_app_initialize(uintptr_t arg)
|
||||
}
|
||||
|
||||
// Power down the heater
|
||||
px4_arch_configgpio(GPIO_HEATER_OUTPUT);
|
||||
px4_arch_gpiowrite(GPIO_HEATER_OUTPUT, 1);
|
||||
px4_arch_configgpio(GPIO_HEATER1_OUTPUT);
|
||||
px4_arch_gpiowrite(GPIO_HEATER1_OUTPUT, 1);
|
||||
|
||||
#ifdef CONFIG_MMCSD
|
||||
int ret = stm32_sdio_initialize();
|
||||
|
||||
Reference in New Issue
Block a user