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: main.cpp
- Revision:
- 17:c2e21d347ca5
- Parent:
- 16:48b81a9246e6
- Child:
- 18:8b3efa4d4a36
--- a/main.cpp Sun Dec 02 14:41:15 2018 +0000 +++ b/main.cpp Sun Dec 02 15:10:57 2018 +0000 @@ -65,7 +65,67 @@ float speed = MAX; int sensor_val[5]; + + /* if restartedFromOff: Load values from file, recalibrate and start. + */ + while (1) { + + /* + switch + if nothing else: line following + if low_batt: slow down and continue + if atPitIntersection: increment internal lap counter + if low_batt && atPitIntersection: Stop && execute pit navigation program + if all_sensors == 1000 (lifted from track): + show Wh and pitstops on display + stop motors, reset PID errors, wait 20 secs, recalibrate sensors + + if all_sensors < 90 (driven off track): + stop and ask for help? Flash LEDs? turn back and continue? Reset PID errors + + Periodically (not necessarily every lap - maybe every 2-5th lap): + Save to file -> possibly only after pit + Check battery voltage -> every couple of minutes + Check light sensors for drift -> recalibrate (optional) + + */ + + + + /* Separate functions + pit_navigation (entering pit from T-intersection all the way to the charger) + pit_execution (only when connected to charger - voltage > V_CHARGER_MIN + add 1 to number of pitstops + charge and wait for signal from the external charging circuit + during charging: integrate v(t) dt, add to cumulative sum + when fully charged (or signal goes high): + Calculate delta_Wh ( integrate{ v(t) dt} * u * 1/3600 ) + Calculate total_Wh + save progress data to file + leave the charger -> pass control to pit_exit + + pit_exit + reverse out of the pit back to T-intersection + continue line following away from T-intersection, recal sensors after a few seconds + + + AfterPitAdmin: Calibrate sensors, save state to file, + + show_results_on_display: + + check_sensors_for_errors: + + check_battery_voltage -> return true false + compare m3pi.battery() < V_CRITICAL + + + + HUSK FOR POKKER KOLLES KODESTANDARD! + + */ + + // Get the position of the line. current_pos_of_line = m3pi.line_position(); proportional = current_pos_of_line;