Showing posts with label Simulink. Show all posts
Showing posts with label Simulink. Show all posts

Monday, November 20, 2017

[Simulink] Lithium Battery Model, Simscape Language and Simulink Design Optimization


1. source link
https://www.mathworks.com/matlabcentral/fileexchange/36019-lithium-battery-model--simscape-language-and-simulink-design-optimization

2. battery modeling using Simulink/Simscape
https://www.mathworks.com/discovery/battery-models.html

3. Model-Based Parameter Identification of Healthy and Aged Li-ion Batteries for Electric Vehicle Applications
https://www.mathworks.com/company/newsletters/articles/model-based-parameter-identification-of-healthy-and-aged-li-ion-batteries-for-electric-vehicle-applications.html

4. Webinar: Battery Data Acquisition and Analysis using Matlab
https://www.mathworks.com/videos/battery-data-acquisition-and-analysis-using-matlab-89170.html

5. Webinar: Lithium Battery Model with Thermal Effects for system-level analysis
https://www.mathworks.com/videos/lithium-battery-model-with-thermal-effects-for-system-level-analysis-81886.html

6. IEEE 2012: Lithium Battery Model with Thermal Effect
https://www.mathworks.com/content/dam/mathworks/tag-team/Objects/i/71900_IEEE%202012%20High%20Fidelity%20Lithium%20Battery%20Model%20with%20Thermal%20Effect.pdf

7. SAE 2013: Simplified Extended Kalman Filter Observer for Battery SOC Estimation
https://www.mathworks.com/content/dam/mathworks/tag-team/Objects/s/76108_SAE%202013%20-%20Simplified%20EKF%20Battery%20Model.pdf

8. SAE 2013: Battery Model Parameter Estimation Using a Layered Technique
https://www.mathworks.com/company/newsletters/articles/battery-model-parameter-estimation-using-a-layered-technique-an-example-using-a-lithium-iron-phosphate-cell.html?s_tid=srchtitle

9. SAE 2014: Battery Pack Modeling, simulation, and Deployment on a Multicore Real Time Target
https://www.mathworks.com/company/newsletters/articles/battery-pack-modeling-simulation-and-deployment-on-a-multicore-real-time-target.html?s_tid=srchtitle

10. Webinar: Optimizing Vehicle Electrical Design through System-Level Simulation
https://www.mathworks.com/videos/optimizing-vehicle-electrical-design-through-system-level-simulation-81919.html

11. Video: Real-time Simulation of Battery Packs Using Multicore computers
https://www.mathworks.com/videos/real-time-simulation-of-battery-packs-using-multicore-computers-92061.html

12. Video: Maltab and Simulink Racing Lounge: Battery Modeling with Simulink
https://www.mathworks.com/videos/matlab-simulink-racing-lounge-battery-modeling-with-simulink-96690.html

13. Using Model-Based Design to Build the Tesla Roadster
https://www.mathworks.com/company/newsletters/articles/using-model-based-design-to-build-the-tesla-roadster.html







Friday, March 24, 2017

[Matlab / Simulink] Initialize Simulink parameters

In the model properites of Simulink model, parameters defined in an m script can be loaded using pre-load function shown as below. 
In case paramter file is placed in the different folder where simulink model is not placed, path setting has to be changed.

* Model pre-load fuction
% Get a model path
[pathstr,~,~]=fileparts(get_param(gcs,'filename'));
% Create a parameter file path
path=sprintf('%s%s',pathstr,'\ParameterChanger');
cd(path);
% Load a parameter m script
testp;
cd ..


Sunday, March 12, 2017

[Matlab] Insert values in specified blocks / Extract signal list from a bus select block

1. Extract signal list selected

m script
---------------------------------------------------------------------
% Define parameter to be used
var=get_param(gcb,'OutputSignals');

% Find the comma
com = strfind(var,',');
[~,n] = size(com);
sig = cell(n,1);

% Retrieve each signal from strings
for N=1:1:n+1  
    if N == 1;
        sig{N,1} = var(1:com(1)-1);
    elseif N > 1 && N         sig{N,1} = var(com(N-1)+1:com(N)-1);
    else
        sig{N,1} = var(com(N-1)+1:end);
    end
end
---------------------------------------------------------------------

2. Automatically input values in specified blocks(Constant block)

m script
---------------------------------------------------------------------
% Model path
mpath = '... / ... /...';
% subsystem path
spath =  '... / ... /...';
% Block name
bname = { '...', '...', ... '...'};
% Define values to change
val = [1, 2, ..., n];

% size
[n, ~] = size(val);
% Implementation
try
   for N = 1:1:n
      fpath = sprintf('%s%s%s',spath,bname,val{N,1});
      set_param(fpath,'Value',num2str(val(N,1)));
   end
catch
   disp(fpath); % Display a path and block name failed to enter
end











Friday, February 10, 2017

[Matlab / Simulink] How to input a value to the constant block of Simulink using m script.

1. Syntax
 set_param( 'model name/subsystem name/block name' , 'Value' , 'number' )

2. Simulink Model
- Model name : Notebook
- Subsystem : Blog
- Constant block : speed

3. Command
set_param('Notebook/Blog/speed', 'Value', '3')

With the above command, a value of a specified constant block will be changed to 3.

4. Application
It might be useful when changing or entering hundreds of values of the constant blocks.

% model name
model = 'Notebook/';
% subsystem name
sub = 'Blog/'
% block names
block = { 'spd1'; 'spd2'; 'spd3'};
% values
val = [2; 3; 4];

% size of values
[n,~] = size(val);

% Execution 1
for N = 1:1:n
    path = sprintf('%s%s%s', model,sub,block{N,1});
    set_param(path,'Value', num2str(val(N,1)));
end

Instead of the Execution 1, the following code also is applicable.
%Execution 2
for N = 1:1:n
    path = sprintf('%s%s%s', model,sub,block{N,1});
 
   % Catch errors.
   try
      set_param(path,'Value', num2str(val(N,1)));
   catch
       % If there is an error while doing this command,
       % the path where an error has occured is displayed on the command window.
     disp(path);
   end
end








Saturday, February 4, 2017

[Matlab GUI] Introduction to MATLAB GUIDE

엔지니어로 일을 하다 보면 주어진 시간 내에 반복적인 시뮬레이션이나 수치해석 등을 장시간하고 결과로 생긴 수많은 데이타를 예쁘게 그래프로 그려서 누군가에게 보고해야하거나 발표해야하는 경우가 종종 있다.
필요한 경우 직접 간단한 코드를 작성해서 결과물을 만들어도 되지만, 여러 번 반복해서 작업을 해야하는 경우 매번 코드를 조금씩 수정하면서 일을 하면 시간도 오래 걸리고 실수가 발생할 수도 있다. 이럴 경우 간단하지만 수치 정도라도 간단하게 입력해서 결과물을 낼 수 있는 간단하고 가벼운 GUI를 만들어 놓으면 매우 쓸모있게 활용할 수 있다.
GUI을 개발할 수 있는 소프트웨어나 프로그래밍 언어들이 여러가지 있는데 전문 프로그래머가 아닌 일반 엔지니어들이나 공대생이 접근하기 가장 쉽고 하기 쉬운 소프트웨어 중 하나가 매트랩이다.

매트랩에서는 GUI를 만드는 방법이 두 가지 있다.
하나는 m script에서 처음부터 텍스트 코딩으로 모든 것을 하나 하나씩 만드는 방법이 있고, 다른 하나는 GUIDE라는 매트랩 앱을 이용해서 손쉽게 원하는 GUI를 만들 수 있다.
m script에서 텍스트 코딩으로 만들 수 있는 GUI는 GUIDE로도 대부분 크게 어렵지 않게 만들 수 있지만, GUI 디자인을 자유자재로 하고자 한다면 제한이 아직까지 많이 있다.
Matlab R2014.b 버전부터는 tab 생성 기능도 공식적으로 제공하고 있지만 여전히 부족한 부분이 많다. 답답함에 결국 자바 라이브러리까지 어느 정도 사용해야 하는 경우까지 발생한다.

 우선 간단하게 GUIDE를 실행하는 방법은 아래 그림과 같이 command windows에서 guide를 입력하면 된다.

실행하면 아래와 같은 화면이 나타나고
왼쪽 화면에 보이는 버튼 등을 오른쪽 작업창에 원하는 위치에 나열하면 간단히 GUI를 디자인할 수 있다. 


원하는 디자인을 만든 후 Ctrl + T 또는 화면상의 플레이 버튼을 누르면 m script파일과 함께 디자인한 GUI화면도 나타난다. 

여기까지 했으면 벌써 GUIDE는 반은 끝났음.