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.
brakes.cpp
00001 #include "brakes.h" 00002 #include <mbed.h> 00003 #include "definitions.h" 00004 Brakes::Brakes() 00005 { 00006 00007 } 00008 void Brakes::FrontBrakeOn() //turns on front mechanical brake 00009 { 00010 brakeValve22=0; 00011 brakeValve32=1; 00012 } 00013 00014 void Brakes::RearBrakeOn() //turns on rear mechanical brake 00015 { 00016 brakeValve22=1; 00017 brakeValve32=0; 00018 } 00019 void Brakes::BrakesOn() //turns on both mechanical brakes 00020 { 00021 brakeValve22=0; 00022 brakeValve32=0; 00023 } 00024 00025 void Brakes::ParkMode(Motor motor) //Disengage motor and apply friction brakes 00026 { 00027 motor.setPark(); 00028 BrakesOn(); 00029 } 00030 void Brakes::MechanicalBraking(int brakeRate, Motor motor) //friction braking cases 00031 { 00032 switch (brakeRate) { 00033 case 0: // NO BRAKING 00034 brakeValve32 = 1;//(PD_3) 00035 brakeValve22 = 1;//(PC_0) 00036 break; 00037 00038 case 1: //HALF BRAKING 00039 motor.throttle(0.0f); 00040 RearBrakeOn(); 00041 break; 00042 00043 case 2 ... 4 : //FULL BRAKING 00044 motor.throttle(0.0f); 00045 BrakesOn(); 00046 break; 00047 00048 default: // NO BRAKING 00049 brakeValve32 = 1;//(PD_3) 00050 brakeValve22 = 1;//(PC_0) 00051 break; 00052 } 00053 } 00054 00055 void Brakes::RegenControl(int ratecontrol,Motor motor) //graduated braking control 00056 { 00057 switch (ratecontrol) 00058 { 00059 default: 00060 break; 00061 00062 case 0: 00063 motor.brake(0.0f); 00064 break; 00065 00066 case 1: 00067 motor.brake(0.25f); 00068 break; 00069 00070 case 2: 00071 motor.brake(0.5f); 00072 break; 00073 00074 case 3: 00075 motor.brake(0.75f); 00076 break; 00077 00078 case 4: 00079 motor.brake(1.0f); 00080 break; 00081 } 00082 } 00083 void Brakes::EmergencyStop(Motor motor,RoundTrainCircuit rtc, bool emergencyStopActive) 00084 { 00085 if (emergencyStopActive == false) { 00086 00087 emergencyStopActive = true; 00088 00089 //Set brake throttle to zero before disconnected, think is why we had the runaway train imo 00090 motor.throttle(0.0f); 00091 00092 //Disengage motor 00093 motor.disengage(); 00094 00095 //Setting brakes to high 00096 brakeValve22=0; 00097 brakeValve32=0; 00098 00099 if (rtc_output.read() == 1) { //Check RTC pin out 00100 rtc.getTriggerCause(); // Get RTC input status 00101 } 00102 } 00103 }
Generated on Tue Jul 19 2022 04:44:17 by
1.7.2