%% Use On-Board Diagnostics to Detect Misfire
% This example shows how to introduce, detect, mature, and report misfire
% events from the SI Core Engine. The model demonstrates misfire on-board
% diagnostics (OBD) warnings.

% Copyright 2020 The MathWorks, Inc.

%% Model
helpersetupobdmisfire;
mdl='autoblkSICoreOBDMisfire';
%% Run Simulation
% On the Simulation tab, click *Run*. As the simulation runs, diagnostic
% trouble codes appear on the MIL Light display. P0300 is a general warning
% for a misfire issue in one or more cylinders. P0303 indicates a specific
% misfire issue with Cylinder 3.
%
% <<../OBD_MIL.png>>
%
%% ECU With TPU and Diagnostics
% This subsystem detects misfire events, using crankshaft acceleration as
% an indicator. Navigate to |autoblkSICoreOBDMisfire| > |ECU With TPU and
% Diagnostics| > |TPU Level Misfire Detection|. Open the Diagnosis
% Parameters block. You can modify the OBD threshold calibrations for
% detection and maturation.
%
% <<../OBD_Diagnosis_Parameters.png>>
%
%% OBD Breakout Box
% This subsystem defines misfire events to inject into the simulation.
% Navigate to |autoblkSICoreOBDMisfire| > |OBD Breakout Box| > |Injector
% Pulsewidth Fault Injection|. Open the Misfire Events block. You can
% modify the misfire fault injection timing.
%
% <<../OBD_Misfire_Events.png>>
%
%% Engine Plant With Sensors and Actuators
% The <docid:autoblks_ref#bvab8xm SI Core Engine> computes cylinder
% pressure as a function of crank angle. The Crank VRS Sensor and
% Measurement Circuit simulates the 58-tooth wheel that tracks the
% progression of the 4-stroke engine cycle.
open_system('autoblkSICoreOBDMisfire/Engine Plant With Sensors and Actuators')
%% Cranktrain block
% Open the Cranktrain block to modify the engine cranktrain geometry and
% dynamics.
%
% <<../OBD_Cranktrain.png>>
%