Skip to content

Commit

Permalink
fix hardpoint TTL logic and update default values for TTL and PWM fre…
Browse files Browse the repository at this point in the history
…quency
  • Loading branch information
PonomarevDA committed May 18, 2024
1 parent f2f1322 commit 35b6d80
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Src/dronecan_application/modules/pwm/PWMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "PWMModule.hpp"
#include <limits>
#include "uavcan/equipment/hardpoint/Command.h"
#include "uavcan/equipment/hardpoint/Status.h"
#include "uavcan/equipment/indication/LightsCommand.h"
Expand All @@ -25,8 +26,8 @@ static constexpr uint16_t CMD_HOLD_OR_MAX = 1;

Logger PWMModule::logger = Logger("PWMModule");

uint16_t PWMModule::ttl_cmd = 0;
uint16_t PWMModule::pwm_freq = 1000;
uint16_t PWMModule::ttl_cmd = 500;
uint16_t PWMModule::pwm_freq = 50;
CommandType PWMModule::pwm_cmd_type = CommandType::RAW_COMMAND;

ModuleStatus PWMModule::module_status = ModuleStatus::MODULE_OK;
Expand Down Expand Up @@ -288,7 +289,8 @@ void PWMModule::hardpoint_callback(CanardRxTransfer* transfer) {
continue;
}

pwm.cmd_end_time_ms = HAL_GetTick() + ttl_cmd;
// TTL has no effect on Hardpoint
pwm.cmd_end_time_ms = std::numeric_limits<decltype(pwm.cmd_end_time_ms)>::max();
pwm.command_val = (cmd.command == CMD_HOLD_OR_MAX) ? pwm.max : pwm.min;
}
}

0 comments on commit 35b6d80

Please sign in to comment.