1.INCA介紹
INCA是常用的汽車ECU測試和標定的,廣泛應用於動力總成等領域。INCA提供了豐富的接口,供用戶自動化、定制化。本公眾號通過幾篇文章,介紹下一些二次開發的方法,本篇介紹MIP。
2.MIP
MIP(MATLAB Integration Package))是INCA提供的MATLAB接口。如下圖所示:INCA是服務器端,MATLAB是客戶端。
1)安裝
需要專用安裝包和license,建議安裝到MATLAB路徑下。安裝完成后,需要“更新工具路徑緩存”。
2)文檔
INCA的安裝目下ETAS\INCA7.2\Manuals有MIP手冊《INCA_MIP_R16_EN.pdf》。
(回復“MIP文檔”獲取)
3)Ring Buffer(循環緩沖區)
INCA提供了一個緩沖區,可以存儲30s的變量值,保證了數據的連續性和實時性。
3.常用MIP函數
接下來按照執行的先后順序介紹
1)打開
%% Open
% Establish the connection from MATLAB to INCA
IncaOpen;
% Connects to the currently opened experiment
IncaOpenExperiment;
MATLAB先連接INCA,再連接到當前已打開的實驗環境,輸出結果:
2)變量操作
%% Measure element
% Add measure element in current group
IncaAddMeasureElement('WorkbaseDevice1',[],'B_GREEN');
IncaAddMeasureElement('WorkbaseDevice1',[],'B_RED');
IncaAddMeasureElement('WorkbaseDevice1',[],'B_YELLOW');
% Start measure
data=[];
time=[];
IncaShowMessages(0);
IncaSetMeasureReadMode(0)
IncaStartMeasurement;
deltaT=0;
% Measure for 20 seconds
while(deltaT<20)
pause(0.1)
[t,d]=IncaGetRecords( 'WorkbaseDevice1','TimeC',500);
data = [data; d];
time = [time; t];
if( length(time))
% Calculate time measured
deltaT = time( length(time)) - time(1);
end
end
IncaStopMeasurement;
IncaShowMessages(1);
% Plot the results
plot(time, data);
此段代碼參考了MIP手冊中的示例代碼,首先添加3個變量,然后采集20s的數據,繪制曲線,輸出結果:
3)標定量操作
%% Calibration element
% Add calibration element
IncaAddCalibrationElement('WorkbaseDevice1','DEMO_CONSTANT_1');
% Get calibration value
value=IncaGetCalibrationValue('WorkbaseDevice1','DEMO_CONSTANT_1');
% Set calibration value
DEMO_CONSTANT_1=10;
result=IncaSetCalibrationValue('WorkbaseDevice1','DEMO_CONSTANT_1',DEMO_CONSTANT_1);
首先添加標定量,其次獲取值,修改值,輸出結果:
4)關閉
%% Close
IncaClose;
退出INCA,輸出結果:
(回復“MIP例子”獲取示例代碼)
4.INCA-COM vs MIP
本公眾號介紹了INCA的2種二次開發方式,對比如下:
方案 |
優點 |
缺點 |
INCA-COM |
免license,可以完全控制INCA; |
數據實時性和完整性差,無ring buffer; |
MIP |
數據實時性和完整性好,有ring buffer; |
需要單獨license; |