Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of AEB by
Diff: AEB0.cpp
- Revision:
- 2:5811e080f41d
- Parent:
- 1:45911e86ffee
- Child:
- 4:f0be0d8a0394
diff -r 45911e86ffee -r 5811e080f41d AEB0.cpp
--- a/AEB0.cpp Tue Jul 26 20:15:23 2016 +0000
+++ b/AEB0.cpp Sat Jul 30 08:23:21 2016 +0000
@@ -7,9 +7,9 @@
*
* Code generated for Simulink model 'AEB0'.
*
- * Model version : 1.56
+ * Model version : 1.77
* Simulink Coder version : 8.10 (R2016a) 10-Feb-2016
- * C/C++ source code generated on : Sun Jul 24 18:06:25 2016
+ * C/C++ source code generated on : Thu Jul 28 19:46:51 2016
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
@@ -51,7 +51,7 @@
{
/* Chart: '<Root>/AEB ' incorporates:
* Inport: '<Root>/distance_m'
- * Inport: '<Root>/speed_ms'
+ * Inport: '<Root>/speed_km_h'
*/
if (AEB0_DW.temporalCounter_i1 < 7U) {
AEB0_DW.temporalCounter_i1++;
@@ -75,6 +75,11 @@
/* Transition: '<S1>:37' */
AEB0_DW.is_AEB_distance_sensor_fault_de = AEB0_IN_ok;
+ /* Outport: '<Root>/fault' */
+ /* Entry 'ok': '<S1>:21' */
+ /* '<S1>:21:1' fault=0 */
+ AEB0_Y.fault = 0.0;
+
/* Entry Internal 'AEB_brake_fault_detection': '<S1>:41' */
/* Transition: '<S1>:44' */
AEB0_DW.is_AEB_brake_fault_detection = AEB0_IN_ok2;
@@ -111,6 +116,11 @@
if (AEB0_U.distance_m > 0.0) {
/* Transition: '<S1>:24' */
AEB0_DW.is_AEB_distance_sensor_fault_de = AEB0_IN_ok;
+
+ /* Outport: '<Root>/fault' */
+ /* Entry 'ok': '<S1>:21' */
+ /* '<S1>:21:1' fault=0 */
+ AEB0_Y.fault = 0.0;
} else {
/* '<S1>:26:1' sf_internal_predicateOutput = ... */
/* '<S1>:26:1' after(500, msec); */
@@ -128,12 +138,6 @@
default:
/* During 'zero_dist_fault': '<S1>:25' */
- /* '<S1>:29:1' sf_internal_predicateOutput = ... */
- /* '<S1>:29:1' distance_m>0; */
- if (AEB0_U.distance_m > 0.0) {
- /* Transition: '<S1>:29' */
- AEB0_DW.is_AEB_distance_sensor_fault_de = AEB0_IN_ok;
- }
break;
}
@@ -146,9 +150,10 @@
case AEB0_IN_brake_on_:
/* During 'brake_on_': '<S1>:32' */
/* '<S1>:35:1' sf_internal_predicateOutput = ... */
- /* '<S1>:35:1' (after(500, msec)) && (speed_ms>=speed_at_brake_start && speed_ms > 0); */
- if ((AEB0_DW.temporalCounter_i2 >= 5U) && (AEB0_U.speed_ms >=
- AEB0_DW.speed_at_brake_start) && (AEB0_U.speed_ms > 0.0)) {
+ /* '<S1>:35:1' (after(500, msec)) && (speed_km_h>=speed_at_brake_start && speed_km_h > 0 && brake>0.1); */
+ if ((AEB0_DW.temporalCounter_i2 >= 5U) && (AEB0_U.speed_km_h >=
+ AEB0_DW.speed_at_brake_start) && (AEB0_U.speed_km_h > 0.0) &&
+ (AEB0_Y.brake > 0.1)) {
/* Transition: '<S1>:35' */
AEB0_DW.is_AEB_brake_fault_detection = AEB0_IN_brake_fault;
@@ -158,16 +163,16 @@
AEB0_Y.fault = 1.0;
} else {
/* '<S1>:46:1' sf_internal_predicateOutput = ... */
- /* '<S1>:46:1' (after(500, msec)) && (speed_ms<speed_at_brake_start); */
- if ((AEB0_DW.temporalCounter_i2 >= 5U) && (AEB0_U.speed_ms <
+ /* '<S1>:46:1' (after(500, msec)) && (speed_km_h<speed_at_brake_start); */
+ if ((AEB0_DW.temporalCounter_i2 >= 5U) && (AEB0_U.speed_km_h <
AEB0_DW.speed_at_brake_start)) {
/* Transition: '<S1>:46' */
AEB0_DW.is_AEB_brake_fault_detection = AEB0_IN_brake_on_;
AEB0_DW.temporalCounter_i2 = 0U;
/* Entry 'brake_on_': '<S1>:32' */
- /* '<S1>:32:1' speed_at_brake_start = speed_ms */
- AEB0_DW.speed_at_brake_start = AEB0_U.speed_ms;
+ /* '<S1>:32:1' speed_at_brake_start = speed_km_h */
+ AEB0_DW.speed_at_brake_start = AEB0_U.speed_km_h;
} else {
/* '<S1>:47:1' sf_internal_predicateOutput = ... */
/* '<S1>:47:1' brake==0; */
@@ -189,8 +194,8 @@
AEB0_DW.temporalCounter_i2 = 0U;
/* Entry 'brake_on_': '<S1>:32' */
- /* '<S1>:32:1' speed_at_brake_start = speed_ms */
- AEB0_DW.speed_at_brake_start = AEB0_U.speed_ms;
+ /* '<S1>:32:1' speed_at_brake_start = speed_km_h */
+ AEB0_DW.speed_at_brake_start = AEB0_U.speed_km_h;
}
break;
}
@@ -213,21 +218,27 @@
} else if (AEB0_DW.is_AEB_ok == AEB0_IN_brake_off_) {
/* During 'brake_off_': '<S1>:3' */
/* '<S1>:5:1' sf_internal_predicateOutput = ... */
- /* '<S1>:5:1' speed_ms^2/div>distance_m; */
- if (AEB0_U.speed_ms * AEB0_U.speed_ms / AEB0_div > AEB0_U.distance_m) {
+ /* '<S1>:5:1' speed_km_h^2/div>distance_m; */
+ if (AEB0_U.speed_km_h * AEB0_U.speed_km_h / AEB0_div > AEB0_U.distance_m)
+ {
/* Transition: '<S1>:5' */
AEB0_DW.is_AEB_ok = AEB0_IN_brake_on_;
/* Outport: '<Root>/brake' */
/* Entry 'brake_on_': '<S1>:1' */
- /* '<S1>:1:1' brake=1 */
+ /* brake is proportional to the inverse of distance */
+ /* and to the speed. This was required */
+ /* since it was requested that the led frequency */
+ /* must be proportional to the brake request */
+ /* '<S1>:1:3' brake=1 */
AEB0_Y.brake = 1.0;
}
} else {
/* During 'brake_on_': '<S1>:1' */
/* '<S1>:6:1' sf_internal_predicateOutput = ... */
- /* '<S1>:6:1' speed_ms^2/div<distance_m; */
- if (AEB0_U.speed_ms * AEB0_U.speed_ms / AEB0_div < AEB0_U.distance_m) {
+ /* '<S1>:6:1' speed_km_h^2/div<distance_m; */
+ if (AEB0_U.speed_km_h * AEB0_U.speed_km_h / AEB0_div < AEB0_U.distance_m)
+ {
/* Transition: '<S1>:6' */
AEB0_DW.is_AEB_ok = AEB0_IN_brake_off_;
