Challenge

Project 2 Adaptive Cruise Control

Aim-

To develop the Adaptive Cruise Control feature by using the given documents and make the Simulink model as per the requirement.

Objective-

  1. As per the given requirement we have to develop the Simulink model.
  2. Tagging the requirement tagging and set the all MBD compliances.
  3. Create the SLDD file and run the model advisor check.
  4. Generate the CODE by using the Embedded coder.

Blocks Required-

Addition block, Inport, Outport, Signal conversion, Chart

Functions of the Block-

Addition block-

It is used to add the component

Inport-

It is used to showed the input

Outport-

It is used to showed the output

Signal Conversion-

If the incoming signal is not a bus, the 'Signal copy' option creates a contiguous segment of memory to store a copy of an input signal.

Chart-

It is used to create the state flow.

Requirements are as follows-

Simulation model is as follow-

The model is as follow as per the requirements-

Requirement 1-

Requirement 2-

Requirement 3-

For requirement 3 we have to create or develop the state flow logic is as follow.

In state flow there are 3 model of operation

ACC ON mode, ACC OFF mode and ACC standby mode.

In ACC ON mode 6 different modes of operations are conducting are as follow

  1. Lead Vehicle detected
  2. Lead vehicle not detected
  3. Lead vehicle detected resume
  4. Lead vehicle not detected resume
  5. Lead vehicle speed less than set speed.
  6. Lead vehicle speed equal to set speed.

The whole simulation model is look like as follow

SLDD file creation-

As we know how to create the SLDD file in modelling tab we have to select the Link to data dictionary option then input the parameter in the file as given the SLDD is as follow.

Procedure-

  1. In first step we have to make the MBD environment changes means we have set the model as per MBD compliances as follow in modelling tab in model setting set the solver configuration and code generation settings. Select the solver as fixed step solver and sample time should be 0.01s and in code generation select the ert.tlc embedded coder.

  1. Develop the MATLAB model as per the given requirement
  2. In first requirement we have given the condition as we have to add the two inport signals and name the output signal and connect it to third subsystem.
  3. Similar in second requirement as per given model is build by using signal conversion block and addition block and output is given to the third subsystem.
  4. As per the given condition for state flow we have made the state flow.
  5. Then as per the objective we have to do a requirement tagging. Requirement tagging is done as follow
  6. Right click on the subsystem and select the word file where requirement is saved.

8.Now we have to run model advisory for to check the model is as per the MAB guidelines.

9.For that go to the modelling tab and then click on the model advisor. And click on the model advisor.

10Then select the modelling standard for the MAB and then click run selected checks. The report will generate automatically.

  1. By viewing the report, we can check the warning fault and pass checks on the model. The report is attached for the reference.

  1. In this project we have to also develop the coverage report is as follow
  2. In modelling tab select the model parameters and select the coverage parameters is as follow

  1. For reference coverage report is attached.
  2. For the code generation click on the code generation tab and select the generate code option is as follow.

  1. The code is as follows
  2. File: ert_main.c
  3. * Code generated for Simulink model 'Adaptivecruisecontrol'.
  4. *
  5. * Model version : 1.9
  6. * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
  7. * C/C++ source code generated on : Mon Oct 10 08:47:50 2022
  8. *
  9. * Target selection: ert.tlc
  10. * Embedded hardware selection: Intel->x86-64 (Windows64)
  11. * Code generation objectives: Unspecified
  12. * Validation result: Not run
  13. */

  14. #include <stddef.h>
  15. #include <stdio.h> /* This ert_main.c example uses printf/fflush */
  16. #include "Adaptivecruisecontrol.h" /* Model's header file */
  17. #include "rtwtypes.h"

  18. /*
  19. * Associating rt_OneStep with a real-time clock or interrupt service routine
  20. * is what makes the generated code "real-time". The function rt_OneStep is
  21. * always associated with the base rate of the model. Subrates are managed
  22. * by the base rate from inside the generated code. Enabling/disabling
  23. * interrupts and floating point context switches are target specific. This
  24. * example code indicates where these should take place relative to executing
  25. * the generated code step function. Overrun behavior should be tailored to
  26. * your application needs. This example simply sets an error status in the
  27. * real-time model and returns from rt_OneStep.
  28. */
  29. void rt_OneStep(void);
  30. void rt_OneStep(void)
  31. {
  32. static boolean_T OverrunFlag = false;

  33. /* Disable interrupts here */

  34. /* Check for overrun */
  35. if (OverrunFlag) {
  36. rtmSetErrorStatus(Adaptivecruisecontrol_M, "Overrun");
  37. return;
  38. }

  39. OverrunFlag = true;

  40. /* Save FPU context here (if necessary) */
  41. /* Re-enable timer or interrupt here */
  42. /* Set model inputs here */

  43. /* Step the model */
  44. Adaptivecruisecontrol_step();

  45. /* Get model outputs here */

  46. /* Indicate task complete */
  47. OverrunFlag = false;

  48. /* Disable interrupts here */
  49. /* Restore FPU context here (if necessary) */
  50. /* Enable interrupts here */
  51. }

  52. /*
  53. * The example "main" function illustrates what is required by your
  54. * application code to initialize, execute, and terminate the generated code.
  55. * Attaching rt_OneStep to a real-time clock is target specific. This example
  56. * illustrates how you do this relative to initializing the model.
  57. */
  58. int_T main(int_T argc, const char *argv[])
  59. {
  60. /* Unused arguments */
  61. (void)(argc);
  62. (void)(argv);

  63. /* Initialize model */
  64. Adaptivecruisecontrol_initialize();

  65. /* Attach rt_OneStep to a timer or interrupt service routine with
  66. * period 0.01 seconds (the model's base sample time) here. The
  67. * call syntax for rt_OneStep is
  68. *
  69. * rt_OneStep();
  70. */
  71. printf("Warning: The simulation will run forever. "
  72. "Generated ERT main won't simulate model step behavior. "
  73. "To change this behavior select the 'MAT-file logging' option.\n");
  74. fflush((NULL));
  75. while (rtmGetErrorStatus(Adaptivecruisecontrol_M) == (NULL)) {
  76. /* Perform other application tasks here */
  77. }

  78. /* Disable rt_OneStep() here */

  79. /* Terminate model */
  80. Adaptivecruisecontrol_terminate();
  81. return 0;
  82. }

  83. /*
  84. * File trailer for generated code.
  85. *
  86. * [EOF]
  87. */

  88. File: Adaptivecruisecontrol.c

Code generated for Simulink model 'Adaptivecruisecontrol'.

*

* Model version : 1.9

* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020

* C/C++ source code generated on : Mon Oct 10 08:47:50 2022

*

* Target selection: ert.tlc

* Embedded hardware selection: Intel->x86-64 (Windows64)

* Code generation objectives: Unspecified

* Validation result: Not run

*/

#include "Adaptivecruisecontrol.h"

#include "Adaptivecruisecontrol_private.h"

/* Named constants for Chart: '<S1>/Chart' */

#define Ada_IN_LeadVehicle_Not_Detected ((uint8_T)3U)

#define Adaptiv_IN_LeadVehicle_Detected ((uint8_T)1U)

#define Adaptivecrui_IN_NO_ACTIVE_CHILD ((uint8_T)0U)

#define Adaptivecruiseco_IN_Acc_Standby ((uint8_T)1U)

#define Adaptivecruisecontro_IN_Acc_off ((uint8_T)2U)

#define Adaptivecruisecontro_IN_ON_mode ((uint8_T)3U)

#define IN_LeadVehicle_Detected_Resume ((uint8_T)2U)

#define IN_LeadVehicle_Not_Detected_Res ((uint8_T)4U)

#define IN_LeadVehicle_Speed_equal_Set_ ((uint8_T)5U)

#define IN_LeadVehicle_Speed_lessthan_S ((uint8_T)6U)

/* Exported data definition */

/* Definition for custom storage class: ExportToFile */

uint8_T Acceleration_Mode; /* '<S1>/Chart' */

uint8_T DriveVehicle_Speed; /* '<S3>/Add1' */

uint8_T LeadVehicle_Detected; /* '<S3>/SignalConversion' */

uint8_T LeadVehicle_Speed; /* '<S4>/Add' */

/* Block states (default storage) */

DW_Adaptivecruisecontrol_T Adaptivecruisecontrol_DW;

/* Real-time model */

static RT_MODEL_Adaptivecruisecontro_T Adaptivecruisecontrol_M_;

RT_MODEL_Adaptivecruisecontro_T *const Adaptivecruisecontrol_M =

&Adaptivecruisecontrol_M_;

real_T rt_roundd_snf(real_T u)

{

real_T y;

if (fabs(u) < 4.503599627370496E+15) {

if (u >= 0.5) {

y = floor(u + 0.5);

} else if (u > -0.5) {

y = u * 0.0;

} else {

y = ceil(u - 0.5);

}

} else {

y = u;

}

return y;

}

/* Model step function */

void Adaptivecruisecontrol_step(void)

{

int32_T tmp;

int32_T tmp_0;

uint8_T tmp_1;

uint8_T tmp_2;

/* Outputs for Atomic SubSystem: '<Root>/Sunsystem' */

/* Sum: '<S3>/Add1' incorporates:

* Inport: '<Root>/ CameraInputDriveVehicle'

* Inport: '<Root>/ RadarInputDriveVehicle '

* UnitDelay: '<S1>/UnitDelay'

*/

DriveVehicle_Speed = (uint8_T)((uint32_T)(uint8_T)((uint32_T)

CameraInput_DriveVehicle + RadarInput_DriveVehicle) + Acceleration_Mode);

/* SignalConversion: '<S3>/SignalConversion' incorporates:

* Inport: '<Root>/ RadarInputDriveVehicle '

*/

LeadVehicle_Detected = RadarInput_DriveVehicle;

/* Sum: '<S4>/Add' incorporates:

* Inport: '<Root>/ CameraInputLeadVehicle'

* Inport: '<Root>/ RadarInputLeadVehicle'

*/

LeadVehicle_Speed = (uint8_T)((uint32_T)CameraInput_LeadVehicle +

RadarInput_LeadVehicle);

/* Chart: '<S1>/Chart' incorporates:

* Inport: '<Root>/ CruiseSwitch'

* Inport: '<Root>/ SetGap'

* Inport: '<Root>/ SetSpeed'

* Inport: '<Root>/ SetSwitch'

* Inport: '<Root>/ TimeGap'

*/

if (Adaptivecruisecontrol_DW.is_active_c1_Adaptivecruisecont == 0U) {

Adaptivecruisecontrol_DW.is_active_c1_Adaptivecruisecont = 1U;

Adaptivecruisecontrol_DW.is_c1_Adaptivecruisecontrol =

Adaptivecruisecontro_IN_Acc_off;

Acceleration_Mode = 0U;

} else {

switch (Adaptivecruisecontrol_DW.is_c1_Adaptivecruisecontrol) {

case Adaptivecruiseco_IN_Acc_Standby:

Acceleration_Mode = 1U;

if (!CruiseSwitch) {

Adaptivecruisecontrol_DW.is_c1_Adaptivecruisecontrol =

Adaptivecruisecontro_IN_Acc_off;

Acceleration_Mode = 0U;

} else if (SetSwitch) {

Adaptivecruisecontrol_DW.is_c1_Adaptivecruisecontrol =

Adaptivecruisecontro_IN_ON_mode;

Adaptivecruisecontrol_DW.is_ON_mode = Adaptiv_IN_LeadVehicle_Detected;

Acceleration_Mode = 2U;

}

break;

case Adaptivecruisecontro_IN_Acc_off:

Acceleration_Mode = 0U;

if (CruiseSwitch) {

Adaptivecruisecontrol_DW.is_c1_Adaptivecruisecontrol =

Adaptivecruiseco_IN_Acc_Standby;

Acceleration_Mode = 1U;

}

break;

default:

/* case IN_ON_mode: */

if (!SetSwitch) {

Adaptivecruisecontrol_DW.is_ON_mode = Adaptivecrui_IN_NO_ACTIVE_CHILD;

Adaptivecruisecontrol_DW.is_c1_Adaptivecruisecontrol =

Adaptivecruiseco_IN_Acc_Standby;

Acceleration_Mode = 1U;

} else {

switch (Adaptivecruisecontrol_DW.is_ON_mode) {

case Adaptiv_IN_LeadVehicle_Detected:

Acceleration_Mode = 2U;

if ((LeadVehicle_Detected == 1) && (LeadVehicle_Speed < Set_Speed) &&

(Time_Gap < Set_Gap)) {

Adaptivecruisecontrol_DW.is_ON_mode =

IN_LeadVehicle_Speed_lessthan_S;

Acceleration_Mode = 4U;

} else if (LeadVehicle_Detected == 0) {

Adaptivecruisecontrol_DW.is_ON_mode =

Ada_IN_LeadVehicle_Not_Detected;

Acceleration_Mode = 1U;

}

break;

case IN_LeadVehicle_Detected_Resume:

Acceleration_Mode = 3U;

if ((DriveVehicle_Speed == Set_Speed) && (LeadVehicle_Speed >=

Set_Speed) && (Time_Gap >= Set_Gap)) {

Adaptivecruisecontrol_DW.is_ON_mode =

Adaptiv_IN_LeadVehicle_Detected;

Acceleration_Mode = 2U;

} else if (LeadVehicle_Detected == 0) {

Adaptivecruisecontrol_DW.is_ON_mode =

IN_LeadVehicle_Not_Detected_Res;

Acceleration_Mode = 1U;

} else if ((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >

DriveVehicle_Speed) && (Time_Gap >= Set_Gap)) {

Adaptivecruisecontrol_DW.is_ON_mode =

IN_LeadVehicle_Speed_equal_Set_;

Acceleration_Mode = 5U;

}

break;

case Ada_IN_LeadVehicle_Not_Detected:

Acceleration_Mode = 1U;

if ((LeadVehicle_Detected == 1) && (DriveVehicle_Speed == Set_Speed) &&

(LeadVehicle_Speed >= Set_Speed) && (Time_Gap >= Set_Gap)) {

Adaptivecruisecontrol_DW.is_ON_mode =

Adaptiv_IN_LeadVehicle_Detected;

Acceleration_Mode = 2U;

} else if ((LeadVehicle_Detected == 1) && (LeadVehicle_Speed <

Set_Speed) && (Time_Gap < Set_Gap)) {

Adaptivecruisecontrol_DW.is_ON_mode =

IN_LeadVehicle_Speed_lessthan_S;

Acceleration_Mode = 4U;

}

break;

case IN_LeadVehicle_Not_Detected_Res:

Acceleration_Mode = 1U;

break;

case IN_LeadVehicle_Speed_equal_Set_:

Acceleration_Mode = 5U;

if ((LeadVehicle_Detected == 0) && (DriveVehicle_Speed <= Set_Speed))

{

Adaptivecruisecontrol_DW.is_ON_mode =

IN_LeadVehicle_Not_Detected_Res;

Acceleration_Mode = 1U;

} else if ((DriveVehicle_Speed < Set_Speed) && (LeadVehicle_Speed >

DriveVehicle_Speed) && (Time_Gap >= Set_Gap)) {

Adaptivecruisecontrol_DW.is_ON_mode = IN_LeadVehicle_Detected_Resume;

Acceleration_Mode = 3U;

} else if ((LeadVehicle_Speed < Set_Speed) && (LeadVehicle_Speed <

DriveVehicle_Speed) && ((int32_T)rt_roundd_snf(0.75 *

(real_T)Set_Gap) == Time_Gap)) {

Adaptivecruisecontrol_DW.is_ON_mode =

IN_LeadVehicle_Speed_lessthan_S;

Acceleration_Mode = 4U;

}

break;

default:

/* case IN_LeadVehicle_Speed_lessthan_Set_Speed: */

Acceleration_Mode = 4U;

if ((LeadVehicle_Detected == 0) && (DriveVehicle_Speed == Set_Speed))

{

Adaptivecruisecontrol_DW.is_ON_mode =

Adaptiv_IN_LeadVehicle_Detected;

Acceleration_Mode = 2U;

} else {

tmp = (int32_T)rt_roundd_snf((real_T)LeadVehicle_Speed * 1.25);

tmp_0 = (int32_T)rt_roundd_snf(1.25 * (real_T)Set_Gap);

if (tmp < 256) {

tmp_1 = (uint8_T)tmp;

} else {

tmp_1 = MAX_uint8_T;

}

if (tmp_0 < 256) {

tmp_2 = (uint8_T)tmp_0;

} else {

tmp_2 = MAX_uint8_T;

}

if ((tmp_1 >= DriveVehicle_Speed) && ((int32_T)rt_roundd_snf((real_T)

LeadVehicle_Speed * 0.75) <= DriveVehicle_Speed) &&

(DriveVehicle_Speed < Set_Speed) && (Time_Gap <= tmp_2) &&

(Time_Gap >= (int32_T)rt_roundd_snf(0.75 * (real_T)Set_Gap))) {

Adaptivecruisecontrol_DW.is_ON_mode =

IN_LeadVehicle_Speed_equal_Set_;

Acceleration_Mode = 5U;

}

}

break;

}

}

break;

}

}

/* End of Chart: '<S1>/Chart' */

/* End of Outputs for SubSystem: '<Root>/Sunsystem' */

}

/* Model initialize function */

void Adaptivecruisecontrol_initialize(void)

{

/* (no initialization code required) */

}

/* Model terminate function */

void Adaptivecruisecontrol_terminate(void)

{

/* (no terminate code required) */

}

/*

* File trailer for generated code.

*

* [EOF]

*/

  1. File: Adaptivecruisecontrol.h

Code generated for Simulink model 'Adaptivecruisecontrol'.

*

* Model version : 1.9

* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020

* C/C++ source code generated on : Mon Oct 10 08:47:50 2022

*

* Target selection: ert.tlc

* Embedded hardware selection: Intel->x86-64 (Windows64)

* Code generation objectives: Unspecified

* Validation result: Not run

*/

#ifndef RTW_HEADER_Adaptivecruisecontrol_h_

#define RTW_HEADER_Adaptivecruisecontrol_h_

#include <math.h>

#ifndef Adaptivecruisecontrol_COMMON_INCLUDES_

#define Adaptivecruisecontrol_COMMON_INCLUDES_

#include "rtwtypes.h"

#endif /* Adaptivecruisecontrol_COMMON_INCLUDES_ */

#include "Adaptivecruisecontrol_types.h"

/* Macros for accessing real-time model data structure */

#ifndef rtmGetErrorStatus

#define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)

#endif

#ifndef rtmSetErrorStatus

#define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))

#endif

/* Block states (default storage) for system '<Root>' */

typedef struct {

uint8_T is_active_c1_Adaptivecruisecont;/* '<S1>/Chart' */

uint8_T is_c1_Adaptivecruisecontrol; /* '<S1>/Chart' */

uint8_T is_ON_mode; /* '<S1>/Chart' */

} DW_Adaptivecruisecontrol_T;

/* Real-time Model Data Structure */

struct tag_RTM_Adaptivecruisecontrol_T {

const char_T * volatile errorStatus;

};

/* Block states (default storage) */

extern DW_Adaptivecruisecontrol_T Adaptivecruisecontrol_DW;

/* Model entry point functions */

extern void Adaptivecruisecontrol_initialize(void);

extern void Adaptivecruisecontrol_step(void);

extern void Adaptivecruisecontrol_terminate(void);

/* Exported data declaration */

/* Declaration for custom storage class: ExportToFile */

extern uint8_T Acceleration_Mode; /* '<S1>/Chart' */

extern uint8_T DriveVehicle_Speed; /* '<S3>/Add1' */

extern uint8_T LeadVehicle_Detected; /* '<S3>/SignalConversion' */

extern uint8_T LeadVehicle_Speed; /* '<S4>/Add' */

/* Real-time Model object */

extern RT_MODEL_Adaptivecruisecontro_T *const Adaptivecruisecontrol_M;

/*-

* The generated code includes comments that allow you to trace directly

* back to the appropriate location in the model. The basic format

* is <system>/block_name, where system is the system number (uniquely

* assigned by Simulink) and block_name is the name of the block.

*

* Use the MATLAB hilite_system command to trace the generated code back

* to the model. For example,

*

* hilite_system('<S3>') - opens system 3

* hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3

*

* Here is the system hierarchy for this model

*

* '<Root>' : 'Adaptivecruisecontrol'

* '<S1>' : 'Adaptivecruisecontrol/Sunsystem'

* '<S2>' : 'Adaptivecruisecontrol/Sunsystem/Chart'

* '<S3>' : 'Adaptivecruisecontrol/Sunsystem/SubsystemThree'

* '<S4>' : 'Adaptivecruisecontrol/Sunsystem/SubsystemTwo'

*/

#endif /* RTW_HEADER_Adaptivecruisecontrol_h_ */

/*

* File trailer for generated code.

*

* [EOF]

*/

  1. File: Adaptivecruisecontrol_private.h

Code generated for Simulink model 'Adaptivecruisecontrol'.

*

* Model version : 1.9

* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020

* C/C++ source code generated on : Mon Oct 10 08:47:50 2022

*

* Target selection: ert.tlc

* Embedded hardware selection: Intel->x86-64 (Windows64)

* Code generation objectives: Unspecified

* Validation result: Not run

*/

#ifndef RTW_HEADER_Adaptivecruisecontrol_private_h_

#define RTW_HEADER_Adaptivecruisecontrol_private_h_

#include "rtwtypes.h"

/* Imported (extern) block signals */

extern uint8_T CameraInput_LeadVehicle;/* '<Root>/ CameraInputLeadVehicle' */

extern uint8_T RadarInput_LeadVehicle; /* '<Root>/ RadarInputLeadVehicle' */

extern uint8_T CameraInput_DriveVehicle;/* '<Root>/ CameraInputDriveVehicle' */

extern uint8_T RadarInput_DriveVehicle;/* '<Root>/ RadarInputDriveVehicle ' */

extern uint8_T Time_Gap; /* '<Root>/ TimeGap' */

extern uint8_T Set_Speed; /* '<Root>/ SetSpeed' */

extern uint8_T Set_Gap; /* '<Root>/ SetGap' */

extern boolean_T CruiseSwitch; /* '<Root>/ CruiseSwitch' */

extern boolean_T SetSwitch; /* '<Root>/ SetSwitch' */

extern real_T rt_roundd_snf(real_T u);

#endif /* RTW_HEADER_Adaptivecruisecontrol_private_h_ */

/*

* File trailer for generated code.

*

* [EOF]

*/

  1. File: Adaptivecruisecontrol_types.h

Code generated for Simulink model 'Adaptivecruisecontrol'.

*

* Model version : 1.9

* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020

* C/C++ source code generated on : Mon Oct 10 08:47:50 2022

*

* Target selection: ert.tlc

* Embedded hardware selection: Intel->x86-64 (Windows64)

* Code generation objectives: Unspecified

* Validation result: Not run

*/

#ifndef RTW_HEADER_Adaptivecruisecontrol_types_h_

#define RTW_HEADER_Adaptivecruisecontrol_types_h_

/* Model Code Variants */

/* Forward declaration for rtModel */

typedef struct tag_RTM_Adaptivecruisecontrol_T RT_MODEL_Adaptivecruisecontro_T;

#endif /* RTW_HEADER_Adaptivecruisecontrol_types_h_ */

/*

* File trailer for generated code.

*

* [EOF]

*/

  1. File: rtwtypes.h

Code generated for Simulink model 'Adaptivecruisecontrol'.

*

* Model version : 1.9

* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020

* C/C++ source code generated on : Mon Oct 10 08:47:50 2022

*

* Target selection: ert.tlc

* Embedded hardware selection: Intel->x86-64 (Windows64)

* Code generation objectives: Unspecified

* Validation result: Not run

*/

#ifndef RTWTYPES_H

#define RTWTYPES_H

/* Logical type definitions */

#if (!defined(__cplusplus))

#ifndef false

#define false (0U)

#endif

#ifndef true

#define true (1U)

#endif

#endif

/*=======================================================================*

* Target hardware information

* Device type: Intel->x86-64 (Windows64)

* Number of bits: char: 8 short: 16 int: 32

* long: 32

* native word size: 64

* Byte ordering: LittleEndian

* Signed integer division rounds to: Zero

* Shift right on a signed integer as arithmetic shift: on

*=======================================================================*/

/*=======================================================================*

* Fixed width word size data types: *

* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *

* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *

* real32_T, real64_T - 32 and 64 bit floating point numbers *

*=======================================================================*/

typedef signed char int8_T;

typedef unsigned char uint8_T;

typedef short int16_T;

typedef unsigned short uint16_T;

typedef int int32_T;

typedef unsigned int uint32_T;

typedef float real32_T;

typedef double real64_T;

/*===========================================================================*

* Generic type definitions: boolean_T, char_T, byte_T, int_T, uint_T, *

* real_T, time_T, ulong_T. *

*===========================================================================*/

typedef double real_T;

typedef double time_T;

typedef unsigned char boolean_T;

typedef int int_T;

typedef unsigned int uint_T;

typedef unsigned long ulong_T;

typedef char char_T;

typedef unsigned char uchar_T;

typedef char_T byte_T;

/*===========================================================================*

* Complex number type definitions *

*===========================================================================*/

#define CREAL_T

typedef struct {

real32_T re;

real32_T im;

} creal32_T;

typedef struct {

real64_T re;

real64_T im;

} creal64_T;

typedef struct {

real_T re;

real_T im;

} creal_T;

#define CINT8_T

typedef struct {

int8_T re;

int8_T im;

} cint8_T;

#define CUINT8_T

typedef struct {

uint8_T re;

uint8_T im;

} cuint8_T;

#define CINT16_T

typedef struct {

int16_T re;

int16_T im;

} cint16_T;

#define CUINT16_T

typedef struct {

uint16_T re;

uint16_T im;

} cuint16_T;

#define CINT32_T

typedef struct {

int32_T re;

int32_T im;

} cint32_T;

#define CUINT32_T

typedef struct {

uint32_T re;

uint32_T im;

} cuint32_T;

/*=======================================================================*

* Min and Max: *

* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *

* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *

*=======================================================================*/

#define MAX_int8_T ((int8_T)(127))

#define MIN_int8_T ((int8_T)(-128))

#define MAX_uint8_T ((uint8_T)(255U))

#define MAX_int16_T ((int16_T)(32767))

#define MIN_int16_T ((int16_T)(-32768))

#define MAX_uint16_T ((uint16_T)(65535U))

#define MAX_int32_T ((int32_T)(2147483647))

#define MIN_int32_T ((int32_T)(-2147483647-1))

#define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU))

/* Block D-Work pointer type */

typedef void * pointer_T;

#endif /* RTWTYPES_H */

/*

* File trailer for generated code.

*

* [EOF]

*/

Conclusion-

Thus, we have performed the Adaptive cruise control by using the Simulink and generate the code for the model.

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.