77 lines
2.4 KiB
C
77 lines
2.4 KiB
C
/*
|
|
* 电容模组
|
|
*/
|
|
|
|
/* Includes ----------------------------------------------------------------- */
|
|
#include "cap.h"
|
|
|
|
#include "component\capacity.h"
|
|
#include "component\limiter.h"
|
|
#include "device\can.h"
|
|
#include "device\referee.h"
|
|
|
|
/* Private typedef ---------------------------------------------------------- */
|
|
/* Private define ----------------------------------------------------------- */
|
|
#define CAP_CUTOFF_VOLT 12.0f
|
|
|
|
/* Private macro ------------------------------------------------------------ */
|
|
/* Private variables -------------------------------------------------------- */
|
|
/* Private function -------------------------------------------------------- */
|
|
|
|
/**
|
|
* @brief 运行电容控制逻辑
|
|
*
|
|
* @param cap 电容数据结构体
|
|
* @param referee 裁判系统数据
|
|
* @param cap_out 电容输出结构体
|
|
*/
|
|
void Cap_Control(CAN_Capacitor_t *cap, const Referee_ForCap_t *referee,
|
|
CAN_CapOutput_t *cap_out) {
|
|
if (referee->ref_status != REF_STATUS_RUNNING) {
|
|
/* 当裁判系统离线时,依然使用裁判系统进程传来的数据 */
|
|
cap_out->power_limit = referee->chassis_power_limit;
|
|
} else {
|
|
/* 当裁判系统在线时,使用算法控制裁判系统输出(即电容输入) */
|
|
cap_out->power_limit =
|
|
PowerLimit_CapInput(referee->chassis_watt, referee->chassis_power_limit,
|
|
referee->chassis_pwr_buff);
|
|
}
|
|
/* 更新电容状态和百分比 */
|
|
cap->cap_status = CAN_CAP_STATUS_RUNNING;
|
|
// cap->percentage = Capacity_GetCapacitorRemain(cap->cap_feedback.cap_volt,
|
|
// cap->cap_feedback.input_volt,
|
|
// CAP_CUTOFF_VOLT);//电容剩余电量比例
|
|
cap->percentage = Capacity_GetCapacitorRemain(cap->cap_od.v_out,
|
|
cap->cap_od.v_in,
|
|
CAP_CUTOFF_VOLT);//电容剩余电量比例
|
|
}
|
|
|
|
/**
|
|
* @brief 运行设置电容参数
|
|
*
|
|
* @param cap_out 电容输出结构体
|
|
* @param can can总线
|
|
*/
|
|
void Cap_Can_Send(CAN_CapOutput_t *cap_out)
|
|
{
|
|
cap_out->new_cmd=2;
|
|
|
|
cap_out->new_power=5000;
|
|
|
|
cap_out->new_voltage=2400;
|
|
|
|
cap_out->new_current=100;
|
|
|
|
}
|
|
|
|
/**
|
|
* @brief 导出电容数据
|
|
*
|
|
* @param cap 电容数据
|
|
* @param ui 结构体
|
|
*/
|
|
void Cap_DumpUI(const CAN_Capacitor_t *cap, Referee_CapUI_t *ui) {
|
|
ui->percentage = cap->percentage;
|
|
ui->status = cap->cap_status;
|
|
}
|