Railway Challenge
/
challenge
Uncommenting of part that allow supercaps to charge up from the batteries
definitions.cpp@0:4788e1df7b55, 2020-03-13 (annotated)
- Committer:
- rwcjoliver
- Date:
- Fri Mar 13 11:48:04 2020 +0000
- Revision:
- 0:4788e1df7b55
- Child:
- 18:d28d458824d4
Uncommented RegenBRaking lines to allow capacitors to charge up from the batteries
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rwcjoliver | 0:4788e1df7b55 | 1 | #include <mbed.h> |
rwcjoliver | 0:4788e1df7b55 | 2 | #include "definitions.h" |
rwcjoliver | 0:4788e1df7b55 | 3 | |
rwcjoliver | 0:4788e1df7b55 | 4 | // COMMS DEFINITIONS |
rwcjoliver | 0:4788e1df7b55 | 5 | Serial pc(USBTX, USBRX); |
rwcjoliver | 0:4788e1df7b55 | 6 | |
rwcjoliver | 0:4788e1df7b55 | 7 | // INTERRUPTS |
rwcjoliver | 0:4788e1df7b55 | 8 | InterruptIn rtc_output(PF_11, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 9 | InterruptIn autoStopTrigger(PD_2, PullDown); //interrupt on lineside equipment detection |
rwcjoliver | 0:4788e1df7b55 | 10 | InterruptIn hallSensor(PG_3); // For Hall Sensor Tachometer |
rwcjoliver | 0:4788e1df7b55 | 11 | |
rwcjoliver | 0:4788e1df7b55 | 12 | // PIN DEFINITIONS |
rwcjoliver | 0:4788e1df7b55 | 13 | |
rwcjoliver | 0:4788e1df7b55 | 14 | // INNOVATION/ COLLISION DETECTION |
rwcjoliver | 0:4788e1df7b55 | 15 | AnalogIn irSensor_1(PF_6); |
rwcjoliver | 0:4788e1df7b55 | 16 | AnalogIn irSensor_2(PF_7); |
rwcjoliver | 0:4788e1df7b55 | 17 | AnalogIn irSensor_3(PC_2); |
rwcjoliver | 0:4788e1df7b55 | 18 | |
rwcjoliver | 0:4788e1df7b55 | 19 | //RTC individual inputs// |
rwcjoliver | 0:4788e1df7b55 | 20 | DigitalIn rtc_1(PG_4, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 21 | DigitalIn rtc_2(PG_6, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 22 | DigitalIn rtc_3(PG_7, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 23 | DigitalIn rtc_4(PG_5, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 24 | DigitalIn rtc_5(PD_10, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 25 | DigitalIn rtc_6(PG_8, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 26 | DigitalIn rtc_7(PE_0, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 27 | DigitalIn rtc_override(PG_14, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 28 | |
rwcjoliver | 0:4788e1df7b55 | 29 | // RTC Outputs |
rwcjoliver | 0:4788e1df7b55 | 30 | DigitalOut rtc_Trigger(PD_14); |
rwcjoliver | 0:4788e1df7b55 | 31 | |
rwcjoliver | 0:4788e1df7b55 | 32 | // Output LEDs |
rwcjoliver | 0:4788e1df7b55 | 33 | //DigitalOut led_rtcOutput(); // No need as RTC has led output |
rwcjoliver | 0:4788e1df7b55 | 34 | //DigitalOut led_emergencyBrake(PE_11); |
rwcjoliver | 0:4788e1df7b55 | 35 | DigitalOut led_parkMode(PF_10); |
rwcjoliver | 0:4788e1df7b55 | 36 | |
rwcjoliver | 0:4788e1df7b55 | 37 | |
rwcjoliver | 0:4788e1df7b55 | 38 | //Motor outputs // ENSURE YOU USE DAC PINS - BOTH MOTORS SHARE PINS |
rwcjoliver | 0:4788e1df7b55 | 39 | AnalogOut motorAccelerator(PA_5); |
rwcjoliver | 0:4788e1df7b55 | 40 | AnalogOut motorBrake(PA_4); |
rwcjoliver | 0:4788e1df7b55 | 41 | |
rwcjoliver | 0:4788e1df7b55 | 42 | ////motor 1 settings |
rwcjoliver | 0:4788e1df7b55 | 43 | DigitalOut keySwitchM1(PF_1); |
rwcjoliver | 0:4788e1df7b55 | 44 | DigitalOut directionFwd(PF_0); |
rwcjoliver | 0:4788e1df7b55 | 45 | DigitalOut directionRev(PD_1); |
rwcjoliver | 0:4788e1df7b55 | 46 | //DigitalOut directionM1(PA_3); // FORWARD AND REVERSE NEED TO BE SEPARATE |
rwcjoliver | 0:4788e1df7b55 | 47 | DigitalOut footswitchM1(PD_4); |
rwcjoliver | 0:4788e1df7b55 | 48 | DigitalOut seatM1(PD_5); |
rwcjoliver | 0:4788e1df7b55 | 49 | DigitalOut inchFwdM1(PD_6); |
rwcjoliver | 0:4788e1df7b55 | 50 | DigitalOut speedLimit2M1(PD_7); |
rwcjoliver | 0:4788e1df7b55 | 51 | DigitalOut speedLimit3M1(PE_3); |
rwcjoliver | 0:4788e1df7b55 | 52 | |
rwcjoliver | 0:4788e1df7b55 | 53 | ////motor 2 settings; |
rwcjoliver | 0:4788e1df7b55 | 54 | //DigitalOut keySwitchM2(PD_10); |
rwcjoliver | 0:4788e1df7b55 | 55 | //DigitalOut directionM2(PG_6); |
rwcjoliver | 0:4788e1df7b55 | 56 | //DigitalOut footswitchM2(PG_4); |
rwcjoliver | 0:4788e1df7b55 | 57 | //DigitalOut seatM2(PC_8); |
rwcjoliver | 0:4788e1df7b55 | 58 | //DigitalOut inchFwdM2(PC_6); |
rwcjoliver | 0:4788e1df7b55 | 59 | //DigitalOut speedLimit2M2(PA_12); |
rwcjoliver | 0:4788e1df7b55 | 60 | //DigitalOut speedLimit3M2(PA_11); |
rwcjoliver | 0:4788e1df7b55 | 61 | |
rwcjoliver | 0:4788e1df7b55 | 62 | DigitalIn superCapPreCharge(PB_11); // Supercaps are pre-charged |
rwcjoliver | 0:4788e1df7b55 | 63 | DigitalIn superCapVoltage(PB_2); // Supercaps are Full |
rwcjoliver | 0:4788e1df7b55 | 64 | |
rwcjoliver | 0:4788e1df7b55 | 65 | //Contactors as digital outputs |
rwcjoliver | 0:4788e1df7b55 | 66 | DigitalOut contactBatt(PE_8); // C-BAT |
rwcjoliver | 0:4788e1df7b55 | 67 | DigitalOut contactCompressor(PG_10); // C-COM |
rwcjoliver | 0:4788e1df7b55 | 68 | DigitalOut contactCapCharge(PG_11); // C-CHA |
rwcjoliver | 0:4788e1df7b55 | 69 | |
rwcjoliver | 0:4788e1df7b55 | 70 | //DigitalOut contactMtr1(PE_0); // DRIVEN BY MOTOR CONTROLLER |
rwcjoliver | 0:4788e1df7b55 | 71 | //DigitalOut contactMtr2(PG_8); |
rwcjoliver | 0:4788e1df7b55 | 72 | |
rwcjoliver | 0:4788e1df7b55 | 73 | //mechanical braking and other air components. |
rwcjoliver | 0:4788e1df7b55 | 74 | DigitalOut brakeValve32(PF_2); |
rwcjoliver | 0:4788e1df7b55 | 75 | DigitalOut brakeValve22(PG_1); |
rwcjoliver | 0:4788e1df7b55 | 76 | DigitalOut whistleValve32(PG_15); |
rwcjoliver | 0:4788e1df7b55 | 77 | |
rwcjoliver | 0:4788e1df7b55 | 78 | DigitalIn pressureSwitch1(PC_13, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 79 | DigitalIn pressureSwitch2(PC_1, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 80 | DigitalIn pressureSwitch3(PC_15, PullUp); |
rwcjoliver | 0:4788e1df7b55 | 81 | //DigitalIn brakePressure(PH_0); // NOT INSTALLED |
rwcjoliver | 0:4788e1df7b55 | 82 | DigitalIn mainlinePressure(PH_1, PullUp); |