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.
Diff: brakes.cpp
- Revision:
- 30:c65bf90e8f47
- Parent:
- 28:1086791972d0
diff -r 2ed4d9c309fc -r c65bf90e8f47 brakes.cpp
--- a/brakes.cpp Wed Jun 15 13:38:05 2022 +0000
+++ b/brakes.cpp Wed Jun 15 15:27:54 2022 +0000
@@ -1,28 +1,33 @@
#include "brakes.h"
#include <mbed.h>
#include "definitions.h"
-void Brakes::FrontBrakeOn()
+Brakes::Brakes()
+{
+
+}
+void Brakes::FrontBrakeOn() //turns on front mechanical brake
{
brakeValve22=0;
brakeValve32=1;
}
-void Brakes::RearBrakeOn()
+void Brakes::RearBrakeOn() //turns on rear mechanical brake
{
brakeValve22=1;
brakeValve32=0;
}
-void Brakes::BrakesOn()
+void Brakes::BrakesOn() //turns on both mechanical brakes
{
brakeValve22=0;
brakeValve32=0;
}
-void Brakes::ParkMode()
+void Brakes::ParkMode(Motor motor) //Disengage motor and apply friction brakes
{
+ motor.setPark();
BrakesOn();
}
-void Brakes::MechanicalBraking(int brakeRate, Motor motor)
+void Brakes::MechanicalBraking(int brakeRate, Motor motor) //friction braking cases
{
switch (brakeRate) {
case 0: // NO BRAKING
@@ -47,7 +52,7 @@
}
}
-void Brakes::RegenControl(int ratecontrol,Motor motor)
+void Brakes::RegenControl(int ratecontrol,Motor motor) //graduated braking control
{
switch (ratecontrol)
{
@@ -75,3 +80,24 @@
break;
}
}
+void Brakes::EmergencyStop(Motor motor,RoundTrainCircuit rtc, bool emergencyStopActive)
+{
+ if (emergencyStopActive == false) {
+
+ emergencyStopActive = true;
+
+ //Set brake throttle to zero before disconnected, think is why we had the runaway train imo
+ motor.throttle(0.0f);
+
+ //Disengage motor
+ motor.disengage();
+
+ //Setting brakes to high
+ brakeValve22=0;
+ brakeValve32=0;
+
+ if (rtc_output.read() == 1) { //Check RTC pin out
+ rtc.getTriggerCause(); // Get RTC input status
+ }
+ }
+}
\ No newline at end of file