国产久操视频-国产久草视频-国产久热精品-国产久热香蕉在线观看-青青青青娱乐-青青青青在线成人视99

  • 方案介紹
  • 推薦器件
  • 相關(guān)推薦
申請(qǐng)入駐 產(chǎn)業(yè)圖譜

基于CAN總線設(shè)計(jì)的HMI車(chē)載外設(shè)控制器

2024/05/15
3537
加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點(diǎn)資訊討論

該項(xiàng)目為2023DigiKey汽車(chē)應(yīng)用創(chuàng)意挑戰(zhàn)賽 開(kāi)發(fā)的電源管理模塊 該模塊具有上電自檢-過(guò)流保護(hù)-過(guò)功率保護(hù)等功能,還可以與主控通信

當(dāng)模塊離線時(shí)自動(dòng)報(bào)警

首先附上項(xiàng)目完整全家福

藍(lán)色為本次大賽中使用的STM32顯示器件,用來(lái)顯示多種信息在屏幕上

綠色板子為電源模塊,用來(lái)統(tǒng)計(jì)電源消耗信息

黑色板子為從控,用來(lái)和顯示部分交互數(shù)據(jù)

電源管理模塊:

使用STM32F042作為主控,INA226作為測(cè)量元件

具有1電源輸入3可控電源輸出

同時(shí)一路電源還有功率測(cè)量功能,可以對(duì)該路上的電源負(fù)載做出統(tǒng)計(jì),通過(guò)板載的CAN總線反饋到屏幕終端上,

同時(shí)該路電源還具有上電自檢和超功率保護(hù)的功能

上電自檢時(shí)發(fā)現(xiàn)三個(gè)輸出端口有輸出的情況下將會(huì)觸發(fā)報(bào)警程序

在超過(guò)額定功率輸出的情況下也會(huì)強(qiáng)制斷開(kāi)三路電源 進(jìn)入保護(hù)程序

保護(hù)邏輯并非為超過(guò)功率即保護(hù) 而是有60焦?fàn)柕木彌_能量,當(dāng)60焦耳的緩沖能量使用完之后才會(huì)斷開(kāi)輸出

主控離線檢測(cè)代碼設(shè)計(jì)

void detect_task(void const *pvParameters)
{
static uint32_t system_time;
system_time = xTaskGetTickCount();
//init,初始化
detect_init(system_time);
//wait a time.空閑一段時(shí)間
vTaskDelay(DETECT_TASK_INIT_TIME);

while (1)
{
static uint8_t error_num_display = 0;
system_time = xTaskGetTickCount();

error_num_display = ERROR_LIST_LENGHT;
error_list[ERROR_LIST_LENGHT].is_lost = 0;
error_list[ERROR_LIST_LENGHT].error_exist = 0;

for (int i = 0; i < ERROR_LIST_LENGHT; i++)
{
//disable, continue
//未使能,跳過(guò)
if (error_list[i].enable == 0)
{
continue;
}

//judge offline.判斷掉線
if (system_time - error_list[i].new_time > error_list[i].set_offline_time)
{
if (error_list[i].error_exist == 0)
{
//record error and time
//記錄錯(cuò)誤以及掉線時(shí)間
error_list[i].is_lost = 1;
error_list[i].error_exist = 1;
error_list[i].lost_time = system_time;
}
//judge the priority,save the highest priority ,
//判斷錯(cuò)誤優(yōu)先級(jí), 保存優(yōu)先級(jí)最高的錯(cuò)誤碼
if (error_list[i].priority > error_list[error_num_display].priority)
{
error_num_display = i;
}
error_list[ERROR_LIST_LENGHT].is_lost = 1;
error_list[ERROR_LIST_LENGHT].error_exist = 1;
//if solve_lost_fun != NULL, run it
//如果提供解決函數(shù),運(yùn)行解決函數(shù)
if (error_list[i].solve_lost_fun != NULL)
{
error_list[i].solve_lost_fun();
}
}
else if (system_time - error_list[i].work_time < error_list[i].set_online_time)
{
//just online, maybe unstable, only record
//剛剛上線,可能存在數(shù)據(jù)不穩(wěn)定,只記錄不丟失,
error_list[i].is_lost = 0;
error_list[i].error_exist = 1;
}
else
{
error_list[i].is_lost = 0;
//判斷是否存在數(shù)據(jù)錯(cuò)誤
//judge if exist data error
if (error_list[i].data_is_error != NULL)
{
error_list[i].error_exist = 1;
}
else
{
error_list[i].error_exist = 0;
}
//calc frequency
//計(jì)算頻率
if (error_list[i].new_time > error_list[i].last_time)
{
error_list[i].frequency = configTICK_RATE_HZ / (fp32)(error_list[i].new_time - error_list[i].last_time);
}
}
}

vTaskDelay(DETECT_CONTROL_TIME);
#if INCLUDE_uxTaskGetStackHighWaterMark
detect_task_stack = uxTaskGetStackHighWaterMark(NULL);
#endif
}
}

void detect_hook(uint8_t toe)
{
error_list[toe].last_time = error_list[toe].new_time;
error_list[toe].new_time = xTaskGetTickCount();

if (error_list[toe].is_lost)
{
error_list[toe].is_lost = 0;
error_list[toe].work_time = error_list[toe].new_time;
}

if (error_list[toe].data_is_error_fun != NULL)
{
if (error_list[toe].data_is_error_fun())
{
error_list[toe].error_exist = 1;
error_list[toe].data_is_error = 1;

if (error_list[toe].solve_data_error_fun != NULL)
{
error_list[toe].solve_data_error_fun();
}
}
else
{
error_list[toe].data_is_error = 0;
}
}
else
{
error_list[toe].data_is_error = 0;
}
}

從極端運(yùn)行FreeRTOS代碼,編寫(xiě)一個(gè)detect任務(wù),用來(lái)檢測(cè)CAN總線上是否存在離線設(shè)備,通過(guò)建立臨時(shí)表存儲(chǔ)總線上設(shè)備運(yùn)行時(shí),在can回調(diào)函數(shù)中運(yùn)行鉤子函數(shù)來(lái)更新detect任務(wù)中的任務(wù)在線時(shí)間來(lái)檢測(cè)是否有離線設(shè)備的存在,同時(shí)還會(huì)檢測(cè)設(shè)備數(shù)據(jù)是否有異常

代碼部分:

https://gitee.com/duandijun1/2024_-digi-code.git,項(xiàng)目gitee地址

項(xiàng)目演示視頻

【digikey】https://www.bilibili.com/video/BV17N4y1J74L/?share_source=copy_web&vd_source=f30c922e047da4be83d06ba1e7589a36

 

推薦器件

更多器件
器件型號(hào) 數(shù)量 器件廠商 器件描述 數(shù)據(jù)手冊(cè) ECAD模型 風(fēng)險(xiǎn)等級(jí) 參考價(jià)格 更多信息
ADE7880ACPZ-RL 1 Analog Devices Inc Polyphase Multifunction Energy Metering IC with Harmonic Monitoring

ECAD模型

下載ECAD模型
$14.65 查看
NC7SB3157P6X 1 Fairchild Semiconductor Corporation SPDT, 1 Func, 1 Channel, CMOS, PDSO6, 1.25 MM, EIAJ SC-88, SC-70, 6 PIN
$0.32 查看
ADG1211YRUZ 1 Rochester Electronics LLC QUAD 1-CHANNEL, SGL POLE SGL THROW SWITCH, PDSO16, LEAD FREE, MO-153-AB, TSSOP-16
$5.96 查看

相關(guān)推薦

方案定制

去合作
方案開(kāi)發(fā)定制化,2000+方案商即時(shí)響應(yīng)!
沂源县| 诏安县| 贺州市| 绥德县| 盘山县| 长沙市| 虞城县| 渑池县| 长岭县| 莱阳市| 宜丰县| 陵水| 射洪县| 张家界市| 西昌市| 旬邑县| 宜城市| 德化县| 武山县| 临高县| 台南市| 宝山区| 武冈市| 平果县| 泾川县| 东乡| 泸溪县| 武宁县| 独山县| 张家界市| 绍兴市| 尼木县| 镇赉县| 都江堰市| 阿鲁科尔沁旗| 广元市| 五华县| 桃江县| 郓城县| 定边县| 和田市|