添加超电管理
This commit is contained in:
parent
143decc739
commit
e41d2d9b88
@ -324,6 +324,11 @@
|
||||
<pMon>BIN\CMSIS_AGDI.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||
<Name>-U-O206 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMRTXEVENTFLAGS</Key>
|
||||
@ -347,7 +352,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>CMSIS_AGDI</Key>
|
||||
<Name>-X"Any" -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
||||
<Name>-X"Any" -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
@ -390,7 +395,17 @@
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>cfg_qs</ItemText>
|
||||
<ItemText>cap_out,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>7</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>pm01_od,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>8</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>cap,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow4>
|
||||
|
@ -16,8 +16,8 @@
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F407IGHx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.15.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.17.1</PackID>
|
||||
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x2001FFFF) IRAM2(0x10000000-0x1000FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
@ -1732,8 +1732,8 @@
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F407IGHx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.15.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.17.1</PackID>
|
||||
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x2001FFFF) IRAM2(0x10000000-0x1000FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
|
Binary file not shown.
18008
MDK-ARM/DevC/DevC.hex
18008
MDK-ARM/DevC/DevC.hex
File diff suppressed because it is too large
Load Diff
@ -66,6 +66,8 @@ static osThreadId_t thread_alert;
|
||||
static CAN_t *gcan;
|
||||
static bool inited = false;
|
||||
|
||||
volatile pm01_od_t pm01_od;
|
||||
|
||||
/* Private function -------------------------------------------------------- */
|
||||
static void CAN_Motor_Decode(CAN_MotorFeedback_t *feedback,
|
||||
const uint8_t *raw)
|
||||
@ -260,6 +262,9 @@ int8_t CAN_Motor_Control(CAN_MotorGroup_t group, CAN_Output_t *output,
|
||||
&raw_tx.tx_header, raw_tx.tx_data,
|
||||
&(can->mailbox.shoot));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return DEVICE_OK;
|
||||
}
|
||||
@ -304,7 +309,61 @@ int8_t CAN_StoreMsg(CAN_t *can, CAN_RawRx_t *can_rx)
|
||||
case CAN_TOF_ID_BASE:
|
||||
can->recive_flag |= 1 << 10;
|
||||
CAN_Tof_Decode(&(can->tof), can_rx->rx_data);
|
||||
break;
|
||||
break;
|
||||
//超电
|
||||
case 0x600:
|
||||
pm01_od.ccr = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
||||
can->cap.cap_od.ccr = pm01_od.ccr;
|
||||
break;
|
||||
case 0x601:
|
||||
pm01_od.p_set = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
||||
can->cap.cap_od.p_set = pm01_od.p_set;
|
||||
break;
|
||||
case 0x602:
|
||||
pm01_od.v_set = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
||||
can->cap.cap_od.v_set = pm01_od.v_set;
|
||||
break;
|
||||
|
||||
case 0x603:
|
||||
pm01_od.i_set = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
||||
can->cap.cap_od.i_set = pm01_od.i_set;
|
||||
break;
|
||||
|
||||
case 0x610:
|
||||
pm01_od.sta_code.all = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
||||
can->cap.cap_od.sta_code.all = pm01_od.sta_code.all;
|
||||
pm01_od.err_code = (uint16_t)can_rx->rx_data[2] << 8 | can_rx->rx_data[3];
|
||||
can->cap.cap_od.err_code = pm01_od.err_code;
|
||||
break;
|
||||
|
||||
case 0x611:
|
||||
pm01_od.p_in = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
||||
can->cap.cap_od.p_in = pm01_od.p_in;
|
||||
pm01_od.v_in = (uint16_t)can_rx->rx_data[2] << 8 | can_rx->rx_data[3];
|
||||
can->cap.cap_od.v_in = pm01_od.v_in;
|
||||
pm01_od.i_in = (uint16_t)can_rx->rx_data[4] << 8 | can_rx->rx_data[5];
|
||||
can->cap.cap_od.i_in = pm01_od.i_in;
|
||||
break;
|
||||
|
||||
case 0x612:
|
||||
pm01_od.p_out = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
||||
can->cap.cap_od.p_out = pm01_od.p_out;
|
||||
pm01_od.v_out = (uint16_t)can_rx->rx_data[2] << 8 | can_rx->rx_data[3];
|
||||
can->cap.cap_od.v_out = pm01_od.v_out;
|
||||
pm01_od.i_out = (uint16_t)can_rx->rx_data[4] << 8 | can_rx->rx_data[5];
|
||||
can->cap.cap_od.i_out = pm01_od.i_out;
|
||||
break;
|
||||
|
||||
case 0x613:
|
||||
pm01_od.temp = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
||||
can->cap.cap_od.temp = pm01_od.temp;
|
||||
pm01_od.total_time = (uint16_t)can_rx->rx_data[2] << 8 | can_rx->rx_data[3];
|
||||
can->cap.cap_od.total_time = pm01_od.total_time;
|
||||
pm01_od.run_time = (uint16_t)can_rx->rx_data[4] << 8 | can_rx->rx_data[5];
|
||||
can->cap.cap_od.run_time = pm01_od.run_time;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -326,6 +385,7 @@ int8_t CAN_ClearFlag(CAN_t *can, uint32_t flag)
|
||||
return DEVICE_OK;
|
||||
}
|
||||
|
||||
//不用这里
|
||||
int8_t CAN_Cap_Control(CAN_CapOutput_t *output, CAN_t *can)
|
||||
{
|
||||
float power_limit = output->power_limit;
|
||||
@ -345,6 +405,200 @@ int8_t CAN_Cap_Control(CAN_CapOutput_t *output, CAN_t *can)
|
||||
return DEVICE_OK;
|
||||
}
|
||||
|
||||
//添加的电容控制 int型函数
|
||||
//超电控制
|
||||
/**
|
||||
* @brief 控制命令发送
|
||||
* @param[in] new_cmd 0x00: 停机
|
||||
0x01: 运行,不打开输出负载开关(只给超级电容充电)
|
||||
0x02: 运行,打开输出负载开关(正常运行使用该指令)
|
||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
||||
* @retval none
|
||||
*/
|
||||
int8_t CAN_Cap_cmd_send(CAN_CapOutput_t *output, CAN_t *can)
|
||||
{
|
||||
|
||||
uint16_t cmd = output->new_cmd;
|
||||
// uint16_t cmd = 2;
|
||||
|
||||
raw_tx.tx_header.StdId = 0x600;
|
||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
||||
raw_tx.tx_header.RTR = CAN_RTR_DATA;
|
||||
raw_tx.tx_header.DLC = 0x04;
|
||||
raw_tx.tx_data[0] = (uint8_t)(cmd >> 8 );
|
||||
raw_tx.tx_data[1] = (uint8_t)(cmd & 0xFF);
|
||||
raw_tx.tx_data[2] = 0x00;
|
||||
raw_tx.tx_data[3] = (0x00 == 0x01); //反正demo里设置的是0x00,不管了
|
||||
|
||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
||||
raw_tx.tx_data, &(can->mailbox.cap));
|
||||
return DEVICE_OK;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置功率
|
||||
* @param[in] new_power:新的功率值
|
||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
||||
* @retval none
|
||||
*/
|
||||
int8_t CAN_Cap_power_send(CAN_CapOutput_t *output, CAN_t *can)
|
||||
{
|
||||
uint16_t cmd = output->new_power;
|
||||
//uint16_t cmd = 5000;
|
||||
|
||||
raw_tx.tx_header.StdId = 0x601;
|
||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
||||
raw_tx.tx_header.RTR = CAN_RTR_DATA;
|
||||
raw_tx.tx_header.DLC = 0x04;
|
||||
raw_tx.tx_data[0] = (uint8_t)(cmd >> 8 );
|
||||
raw_tx.tx_data[1] = (uint8_t)(cmd & 0xFF);
|
||||
raw_tx.tx_data[2] = 0x00;
|
||||
raw_tx.tx_data[3] = (0x00 == 0x01); //save_flg
|
||||
|
||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
||||
raw_tx.tx_data, &(can->mailbox.cap));
|
||||
return DEVICE_OK;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置输出电压
|
||||
* @param[in] new_volt:新的电压值
|
||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
||||
* @retval none
|
||||
*/
|
||||
int8_t CAN_Cap_voltage_send(CAN_CapOutput_t *output, CAN_t *can)
|
||||
{
|
||||
uint16_t cmd = output->new_voltage;
|
||||
// uint16_t cmd = 2400;
|
||||
|
||||
raw_tx.tx_header.StdId = 0x602;
|
||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
||||
raw_tx.tx_header.RTR = CAN_RTR_DATA;
|
||||
raw_tx.tx_header.DLC = 0x04;
|
||||
raw_tx.tx_data[0] = (uint8_t)(cmd >> 8 );
|
||||
raw_tx.tx_data[1] = (uint8_t)(cmd & 0xFF);
|
||||
raw_tx.tx_data[2] = 0x00;
|
||||
raw_tx.tx_data[3] = (0x00 == 0x01); //save_flg
|
||||
|
||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
||||
raw_tx.tx_data, &(can->mailbox.cap));
|
||||
return DEVICE_OK;
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief 设置输出电流
|
||||
* @param[in] new_volt:新的电流值
|
||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
||||
* @retval none
|
||||
*/
|
||||
int8_t CAN_Cap_current_send(CAN_CapOutput_t *output, CAN_t *can)
|
||||
{
|
||||
uint16_t cmd = output->new_current;
|
||||
// uint16_t cmd = 500;
|
||||
|
||||
raw_tx.tx_header.StdId = 0x603;
|
||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
||||
raw_tx.tx_header.RTR = CAN_RTR_DATA;
|
||||
raw_tx.tx_header.DLC = 0x04;
|
||||
raw_tx.tx_data[0] = (uint8_t)(cmd >> 8 );
|
||||
raw_tx.tx_data[1] = (uint8_t)(cmd & 0xFF);
|
||||
raw_tx.tx_data[2] = 0x00;
|
||||
raw_tx.tx_data[3] = (0x00 == 0x01); //save_flg
|
||||
|
||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
||||
raw_tx.tx_data, &(can->mailbox.cap));
|
||||
return DEVICE_OK;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取输入信息
|
||||
* @param[in] new_volt:新的电流值
|
||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
||||
* @retval none
|
||||
*/
|
||||
int8_t CAN_Cap_input_send(CAN_t *can)
|
||||
{
|
||||
|
||||
raw_tx.tx_header.StdId = 0x611;
|
||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
||||
raw_tx.tx_header.RTR = CAN_RTR_REMOTE;
|
||||
raw_tx.tx_header.DLC = 0x00;
|
||||
|
||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
||||
raw_tx.tx_data, &(can->mailbox.cap));
|
||||
return DEVICE_OK;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取输出信息
|
||||
* @param[in] new_volt:新的电流值
|
||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
||||
* @retval none
|
||||
*/
|
||||
int8_t CAN_Cap_output_send(CAN_t *can)
|
||||
{
|
||||
|
||||
raw_tx.tx_header.StdId = 0x612;
|
||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
||||
raw_tx.tx_header.RTR = CAN_RTR_REMOTE;
|
||||
raw_tx.tx_header.DLC = 0x00;
|
||||
|
||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
||||
raw_tx.tx_data, &(can->mailbox.cap));
|
||||
return DEVICE_OK;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取其他信息
|
||||
* @param[in] new_volt:新的电流值
|
||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
||||
* @retval none
|
||||
*/
|
||||
int8_t CAN_Cap_other_send(CAN_t *can)
|
||||
{
|
||||
raw_tx.tx_header.StdId = 0x613;
|
||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
||||
raw_tx.tx_header.RTR = CAN_RTR_REMOTE;
|
||||
raw_tx.tx_header.DLC = 0x00;
|
||||
|
||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
||||
raw_tx.tx_data, &(can->mailbox.cap));
|
||||
return DEVICE_OK;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 超电容器参数设置
|
||||
* @param cap_out 电容输出结构体
|
||||
* @param can can总线
|
||||
* @retval none
|
||||
*/
|
||||
void Can_Set_send(CAN_CapOutput_t *output, CAN_t *can)
|
||||
{
|
||||
|
||||
CAN_Cap_input_send(can);//获取输入信息
|
||||
osDelay(1);
|
||||
CAN_Cap_output_send(can);//获取输出信息
|
||||
osDelay(1);
|
||||
//// CAN_Cap_other_send(can);//获取其他信息
|
||||
//// osDelay(1);
|
||||
CAN_Cap_cmd_send(output, can);//控制命令发送
|
||||
osDelay(1);
|
||||
CAN_Cap_power_send(output, can);//设置功率
|
||||
osDelay(1);
|
||||
CAN_Cap_voltage_send(output, can);//设置输出电压
|
||||
osDelay(1);
|
||||
CAN_Cap_current_send(output, can);//设置输出电流
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CAN_CAP_HandleOffline(CAN_Capacitor_t *cap, CAN_CapOutput_t *cap_out,
|
||||
float power_chassis)
|
||||
{
|
||||
|
@ -163,6 +163,10 @@ typedef union {
|
||||
|
||||
typedef struct {
|
||||
float power_limit;
|
||||
uint16_t new_cmd;//can的超电控制设置数值
|
||||
uint16_t new_power;
|
||||
uint16_t new_voltage;
|
||||
uint16_t new_current;
|
||||
} CAN_CapOutput_t;
|
||||
|
||||
typedef struct {
|
||||
@ -232,11 +236,61 @@ typedef struct {
|
||||
uint8_t tx_data[CAN_TX_BUF_SIZE_MAX];
|
||||
} CAN_RawTx_t;
|
||||
|
||||
//超电
|
||||
typedef union
|
||||
{
|
||||
|
||||
uint16_t all;
|
||||
struct {
|
||||
uint16_t rdy: 1; /*!< bit0 就绪 */
|
||||
uint16_t run: 1; /*!< bit1 运行 */
|
||||
uint16_t alm: 1; /*!< bit2 报警 */
|
||||
uint16_t pwr: 1; /*!< bit3 电源开关 */
|
||||
uint16_t load: 1; /*!< bit4 负载开关 */
|
||||
uint16_t cc: 1; /*!< bit5 恒流 */
|
||||
uint16_t cv: 1; /*!< bit6 恒压 */
|
||||
uint16_t cw: 1; /*!< bit7 恒功率 */
|
||||
uint16_t revd: 7; /*!< bit8-14 保留 */
|
||||
uint16_t flt: 1; /*!< bit15 故障 */
|
||||
}bit;
|
||||
|
||||
}csr_t;
|
||||
|
||||
typedef struct mb_reg_type{
|
||||
|
||||
uint16_t ccr; /*!< 8000H 控制寄存器 */
|
||||
uint16_t p_set; /*!< 8001H 输入功率限制 */
|
||||
uint16_t v_set; /*!< 8002H 输出电压设置 */
|
||||
uint16_t i_set; /*!< 8003H 输出电流限制 */
|
||||
csr_t sta_code; /*!< 8100H 状态标志位 */
|
||||
uint16_t err_code; /*!< 8101H 故障代码 */
|
||||
int16_t v_in; /*!< 8102H 输入电压 */
|
||||
int16_t i_in; /*!< 8103H 输入电流 */
|
||||
int16_t p_in; /*!< 8104H 输入功率 */
|
||||
int16_t v_out; /*!< 8105H 输出电压 */
|
||||
int16_t i_out; /*!< 8106H 输出电流 */
|
||||
int16_t p_out; /*!< 8107H 输出功率 */
|
||||
int16_t temp; /*!< 8108H 温度 */
|
||||
uint16_t total_time; /*!< 8109H 累计时间 */
|
||||
uint16_t run_time; /*!< 810AH 运行时间 */
|
||||
|
||||
volatile uint16_t pm01_access_id; /* 正在访问的标识符 */
|
||||
volatile uint16_t pm01_response_flg; /* 控制器响应成功标志位 */
|
||||
|
||||
uint16_t g_cmd_set ;
|
||||
uint16_t g_power_set ;
|
||||
uint16_t g_vout_set ;
|
||||
uint16_t g_iout_set ;
|
||||
|
||||
}pm01_od_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
float percentage;
|
||||
float percentage;// 电容器的百分比状态
|
||||
CAN_CapStatus_t cap_status;
|
||||
CAN_CapFeedback_t cap_feedback;
|
||||
} CAN_Capacitor_t;
|
||||
volatile pm01_od_t cap_od;
|
||||
} CAN_Capacitor_t;//
|
||||
|
||||
typedef struct {
|
||||
CAN_ChassisMotor_t chassis;
|
||||
@ -283,6 +337,16 @@ void CAN_CAP_HandleOffline(CAN_Capacitor_t *cap, CAN_CapOutput_t *cap_out,
|
||||
|
||||
void CAN_Tof_Decode(CAN_Tof_t *tof, const uint8_t *raw);
|
||||
|
||||
//添加send函数
|
||||
int8_t CAN_Cap_cmd_send(CAN_CapOutput_t *output, CAN_t *can);
|
||||
int8_t CAN_Cap_power_send(CAN_CapOutput_t *output, CAN_t *can);
|
||||
int8_t CAN_Cap_voltage_send(CAN_CapOutput_t *output, CAN_t *can);
|
||||
int8_t CAN_Cap_current_send(CAN_CapOutput_t *output, CAN_t *can);
|
||||
int8_t CAN_Cap_output_send(CAN_t *can);
|
||||
int8_t CAN_Cap_input_send(CAN_t *can);
|
||||
int8_t CAN_Cap_other_send(CAN_t *can);
|
||||
void Can_Set_send(CAN_CapOutput_t *output, CAN_t *can);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -26,21 +26,42 @@
|
||||
* @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);
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,6 +35,14 @@ void Cap_Control(CAN_Capacitor_t *cap, const Referee_ForCap_t *referee,
|
||||
*/
|
||||
void Cap_DumpUI(const CAN_Capacitor_t *cap, Referee_CapUI_t *ui);
|
||||
|
||||
/**
|
||||
* @brief 运行设置电容参数
|
||||
*
|
||||
* @param cap_out 电容输出结构体
|
||||
* @param can can总线
|
||||
*/
|
||||
void Cap_Can_Send(CAN_CapOutput_t *cap_out) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -53,13 +53,17 @@ void Task_Can(void *argument) {
|
||||
osMessageQueueReset(task_runtime.msgq.can.feedback.shoot);
|
||||
osMessageQueuePut(task_runtime.msgq.can.feedback.shoot, &can, 0, 0);
|
||||
|
||||
if (CAN_CheckFlag(&can, CAN_REC_CAP_FINISHED)) {
|
||||
osMessageQueueReset(task_runtime.msgq.can.feedback.cap);
|
||||
osMessageQueuePut(task_runtime.msgq.can.feedback.cap, &can, 0, 0);
|
||||
CAN_ClearFlag(&can, CAN_REC_CAP_FINISHED);
|
||||
} else {
|
||||
// Error Handle
|
||||
}
|
||||
//不注释掉不能用
|
||||
// if (CAN_CheckFlag(&can, CAN_REC_CAP_FINISHED)) {
|
||||
// osMessageQueueReset(task_runtime.msgq.can.feedback.cap);
|
||||
// osMessageQueuePut(task_runtime.msgq.can.feedback.cap, &can, 0, 0);
|
||||
// CAN_ClearFlag(&can, CAN_REC_CAP_FINISHED);
|
||||
// } else {
|
||||
// // Error Handle
|
||||
// }
|
||||
|
||||
osMessageQueueReset(task_runtime.msgq.can.feedback.cap);
|
||||
osMessageQueuePut(task_runtime.msgq.can.feedback.cap, &can, 0, 0);
|
||||
|
||||
if (CAN_CheckFlag(&can, CAN_REC_TOF_FINISHED)) {
|
||||
osMessageQueueReset(task_runtime.msgq.can.feedback.tof);
|
||||
@ -84,10 +88,19 @@ void Task_Can(void *argument) {
|
||||
CAN_Motor_Control(CAN_MOTOR_GROUT_SHOOT1, &can_out, &can);
|
||||
}
|
||||
|
||||
if (osMessageQueueGet(task_runtime.msgq.can.output.cap, &(can_out.cap), 0,
|
||||
0) == osOK) {
|
||||
CAN_Cap_Control(&(can_out.cap), &can);
|
||||
}
|
||||
// if (osMessageQueueGet(task_runtime.msgq.can.output.cap, &(can_out.cap), 0,
|
||||
// 0) == osOK) {
|
||||
// CAN_Cap_Control(&(can_out.cap), &can);
|
||||
// }
|
||||
|
||||
//在cap的task里计算电容的输出功率消息队列
|
||||
if (osMessageQueueGet(task_runtime.msgq.can.output.cap, &(can_out.cap), 0,
|
||||
0) == osOK) {
|
||||
// CAN_Cap_Control(&(can_out.cap), &can);
|
||||
Can_Set_send(&(can_out.cap), &can);
|
||||
|
||||
|
||||
}
|
||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,9 @@ void Task_Cap(void *argument) {
|
||||
osKernelLock(); /* 锁住RTOS内核防止控制过程中断,造成错误 */
|
||||
/* 根据裁判系统数据计算输出功率 */
|
||||
Cap_Control(&can.cap, &referee_cap, &cap_out);
|
||||
/* 超电参数设置 */
|
||||
Cap_Can_Send(&cap_out);
|
||||
|
||||
osKernelUnlock();
|
||||
/* 将电容输出值发送到CAN */
|
||||
osMessageQueueReset(task_runtime.msgq.can.output.cap);
|
||||
|
Loading…
Reference in New Issue
Block a user