Challenge

Project 1- Traffic Jam Assistant Feature

AIM: Develop a Traffic Jam Feature model as per the MBD guidelines, create SLDD, model advisory report and code generation using embedded coder

Steps Involved:

1. SLDD is created and linked to the model

Goto-->model properties-->external data-->new-->TrafficJamFeature_modeldd.sldd

2.Solver configuration settings:

Goto model settings-->configuration parameters-->solver type 'Fixed'-->solver 'discrete(no continuous states)'-->step size to 0.01

3. MATLAB Simulink model is developed as per the requiremnts

4. All input and output signals are resolved at their origin point and propagated at their inner stage

Here screen shots are shared for one input and output

5. Code Generation settings

Goto model settings-->configuration parameters-->code genaration-->system target file 'ert.tlc'

6. Model Advisor Report Generation:

Model Advisor Check completed with 10 warnings and 134 checks passed and report is attached

7. Code generation:

Goto APPS-->Embedded coder--> C Code-->Build

/*
* File: TrafficJamFeature_model.c
*
* Code generated for Simulink model 'TrafficJamFeature_model'.
*
* Model version : 1.21
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Fri Dec 2 19:12:24 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "TrafficJamFeature_model.h"
#include "TrafficJamFeature_model_private.h"
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
uint8_T Output_Display; /* '<S2>/Switch' */
/* ConstVolatile memory section */
/* Definition for custom storage class: ConstVolatile */
const volatile boolean_T INTERRUPT_1 = 1;/* Referenced by: '<S2>/Constant5' */
const volatile boolean_T INTERRUPT_2 = 1;/* Referenced by: '<S2>/Constant4' */
const volatile uint8_T NO_DISPLAY = 0U;/* Referenced by: '<S2>/Constant3' */
const volatile uint8_T OFF_MODE = 2U; /* Referenced by:
* '<S2>/Constant1'
* '<S2>/Constant7'
*/
const volatile uint8_T ON_MODE = 1U; /* Referenced by:
* '<S2>/Constant'
* '<S2>/Constant6'
*/
const volatile uint8_T STANDBY_MODE = 3U;/* Referenced by: '<S2>/Constant2' */
const volatile uint8_T VOLTAGE_MAXIMUM_RANGE = 50U;/* Referenced by: '<S1>/Constant1' */
const volatile uint8_T VOLTAGE_MINIMUM_RANGE = 30U;/* Referenced by: '<S1>/Constant' */
/* Real-time model */
static RT_MODEL_TrafficJamFeature_mo_T TrafficJamFeature_model_M_;
RT_MODEL_TrafficJamFeature_mo_T *const TrafficJamFeature_model_M =
&TrafficJamFeature_model_M_;
/* Model step function */
void TrafficJamFeature_model_step(void)
{
/* local block i/o variables */
boolean_T Optimum_Voltage;
uint8_T tmp;
/* Logic: '<S1>/AND' incorporates:
* Constant: '<S1>/Constant'
* Constant: '<S1>/Constant1'
* Inport: '<Root>/Input_Voltage'
* RelationalOperator: '<S1>/Relational Operator'
* RelationalOperator: '<S1>/Relational Operator1'
*/
Optimum_Voltage = ((Input_Voltage > VOLTAGE_MINIMUM_RANGE) && (Input_Voltage <
VOLTAGE_MAXIMUM_RANGE));
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant4'
* Constant: '<S2>/Constant5'
* Inport: '<Root>/Input_Switch'
* Logic: '<S2>/AND'
* Logic: '<S2>/NOT'
* RelationalOperator: '<S2>/Relational Operator1'
*/
if ((!Input_Switch) && Optimum_Voltage && (INTERRUPT_1 == INTERRUPT_2)) {
/* Saturate: '<S2>/Saturation' incorporates:
* Inport: '<Root>/Enable_Display'
*/
if (Enable_Display < 7) {
tmp = Enable_Display;
} else {
tmp = 7U;
}
/* End of Saturate: '<S2>/Saturation' */
/* MultiPortSwitch: '<S2>/Multiport Switch' */
switch (tmp) {
case 1:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant'
*/
Output_Display = ON_MODE;
break;
case 2:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant6'
*/
Output_Display = ON_MODE;
break;
case 3:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant1'
*/
Output_Display = OFF_MODE;
break;
case 4:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant7'
*/
Output_Display = OFF_MODE;
break;
default:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant2'
*/
Output_Display = STANDBY_MODE;
break;
}
/* End of MultiPortSwitch: '<S2>/Multiport Switch' */
} else {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant3'
*/
Output_Display = NO_DISPLAY;
}
/* End of Switch: '<S2>/Switch' */
}
/* Model initialize function */
void TrafficJamFeature_model_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void TrafficJamFeature_model_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/

Conclusion:

/*
* File: TrafficJamFeature_model.c
*
* Code generated for Simulink model 'TrafficJamFeature_model'.
*
* Model version : 1.21
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Fri Dec 2 19:12:24 2022
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "TrafficJamFeature_model.h"
#include "TrafficJamFeature_model_private.h"
/* Exported data definition */
/* Definition for custom storage class: ExportToFile */
uint8_T Output_Display; /* '<S2>/Switch' */
/* ConstVolatile memory section */
/* Definition for custom storage class: ConstVolatile */
const volatile boolean_T INTERRUPT_1 = 1;/* Referenced by: '<S2>/Constant5' */
const volatile boolean_T INTERRUPT_2 = 1;/* Referenced by: '<S2>/Constant4' */
const volatile uint8_T NO_DISPLAY = 0U;/* Referenced by: '<S2>/Constant3' */
const volatile uint8_T OFF_MODE = 2U; /* Referenced by:
* '<S2>/Constant1'
* '<S2>/Constant7'
*/
const volatile uint8_T ON_MODE = 1U; /* Referenced by:
* '<S2>/Constant'
* '<S2>/Constant6'
*/
const volatile uint8_T STANDBY_MODE = 3U;/* Referenced by: '<S2>/Constant2' */
const volatile uint8_T VOLTAGE_MAXIMUM_RANGE = 50U;/* Referenced by: '<S1>/Constant1' */
const volatile uint8_T VOLTAGE_MINIMUM_RANGE = 30U;/* Referenced by: '<S1>/Constant' */
/* Real-time model */
static RT_MODEL_TrafficJamFeature_mo_T TrafficJamFeature_model_M_;
RT_MODEL_TrafficJamFeature_mo_T *const TrafficJamFeature_model_M =
&TrafficJamFeature_model_M_;
/* Model step function */
void TrafficJamFeature_model_step(void)
{
/* local block i/o variables */
boolean_T Optimum_Voltage;
uint8_T tmp;
/* Logic: '<S1>/AND' incorporates:
* Constant: '<S1>/Constant'
* Constant: '<S1>/Constant1'
* Inport: '<Root>/Input_Voltage'
* RelationalOperator: '<S1>/Relational Operator'
* RelationalOperator: '<S1>/Relational Operator1'
*/
Optimum_Voltage = ((Input_Voltage > VOLTAGE_MINIMUM_RANGE) && (Input_Voltage <
VOLTAGE_MAXIMUM_RANGE));
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant4'
* Constant: '<S2>/Constant5'
* Inport: '<Root>/Input_Switch'
* Logic: '<S2>/AND'
* Logic: '<S2>/NOT'
* RelationalOperator: '<S2>/Relational Operator1'
*/
if ((!Input_Switch) && Optimum_Voltage && (INTERRUPT_1 == INTERRUPT_2)) {
/* Saturate: '<S2>/Saturation' incorporates:
* Inport: '<Root>/Enable_Display'
*/
if (Enable_Display < 7) {
tmp = Enable_Display;
} else {
tmp = 7U;
}
/* End of Saturate: '<S2>/Saturation' */
/* MultiPortSwitch: '<S2>/Multiport Switch' */
switch (tmp) {
case 1:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant'
*/
Output_Display = ON_MODE;
break;
case 2:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant6'
*/
Output_Display = ON_MODE;
break;
case 3:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant1'
*/
Output_Display = OFF_MODE;
break;
case 4:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant7'
*/
Output_Display = OFF_MODE;
break;
default:
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant2'
*/
Output_Display = STANDBY_MODE;
break;
}
/* End of MultiPortSwitch: '<S2>/Multiport Switch' */
} else {
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S2>/Constant3'
*/
Output_Display = NO_DISPLAY;
}
/* End of Switch: '<S2>/Switch' */
}
/* Model initialize function */
void TrafficJamFeature_model_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void TrafficJamFeature_model_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.