在无人机设置中,经常涉及到使用AUX辅助通道来控制附属设备,或者直接把主控输出通道放到AUX。但是CUAV系列飞控按照常规设置并不能正常启用AUX输出,通过查看飞控源码找到 原因
一些机型例如24001使用了12个电机,常规主通道只有8个,所以按照主通道6个电机,辅助通道6个电机安排
在代码中明显可以看出AUX通道被注释没有启用。
constexpr io_timers_t io_timers[MAX_IO_TIMERS] = {initIOTimer(Timer::Timer5, DMA{DMA::Index1}),initIOTimer(Timer::Timer4, DMA{DMA::Index1}),// initIOTimer(Timer::Timer1, DMA{DMA::Index1}),// initIOTimer(Timer::Timer12, DMA{DMA::Index1}),
};constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = {// MAINinitIOTimerChannel(io_timers, {Timer::Timer5, Timer::Channel1}, {GPIO::PortH, GPIO::Pin10}),initIOTimerChannel(io_timers, {Timer::Timer5, Timer::Channel2}, {GPIO::PortH, GPIO::Pin11}),initIOTimerChannel(io_timers, {Timer::Timer5, Timer::Channel3}, {GPIO::PortH, GPIO::Pin12}),initIOTimerChannel(io_timers, {Timer::Timer5, Timer::Channel4}, {GPIO::PortI, GPIO::Pin0}),initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel1}, {GPIO::PortD, GPIO::Pin12}),initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel2}, {GPIO::PortD, GPIO::Pin13}),initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel3}, {GPIO::PortD, GPIO::Pin14}),initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel4}, {GPIO::PortD, GPIO::Pin15}),// AUX// initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel1}, {GPIO::PortE, GPIO::Pin9}),// initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel2}, {GPIO::PortE, GPIO::Pin11}),// initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel3}, {GPIO::PortA, GPIO::Pin10}),// initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel4}, {GPIO::PortE, GPIO::Pin14}),// initIOTimerChannel(io_timers, {Timer::Timer12, Timer::Channel1}, {GPIO::PortH, GPIO::Pin6}),// initIOTimerChannel(io_timers, {Timer::Timer12, Timer::Channel2}, {GPIO::PortH, GPIO::Pin9}),
};
/* PWM */
#define DIRECT_PWM_OUTPUT_CHANNELS 8
输出控制也被控制在了8个
/* configuration limits */
#ifdef BOARD_NUM_IO_TIMERS
#define MAX_IO_TIMERS BOARD_NUM_IO_TIMERS
#else
#define MAX_IO_TIMERS 2
#endif
IO通道计时器启用数量也只是被限制了2个,计时器启用数量依靠DIRECT_PWM_OUTPUT_CHANNELS 决定
cuav的boards配置文件board_config.h中没有
#define BOARD_NUM_IO_TIMERS 6
所以计时器直接使用了
#define MAX_IO_TIMERS 2
启用4个计时器需要对应的修改dma的映射
启用所有的FMU输出
#define DIRECT_PWM_OUTPUT_CHANNELS 14