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: speedlimiter.cpp
- Revision:
- 8:51549d7108dd
- Parent:
- 7:d636d073b942
- Child:
- 9:3e8bb4aba7c7
--- a/speedlimiter.cpp Fri Oct 26 17:50:47 2018 +0000
+++ b/speedlimiter.cpp Tue Nov 06 22:07:05 2018 +0000
@@ -6,6 +6,15 @@
#define debug SpeedLimiter::pc->printf
+const float valeursVitessesRecommandes[20] = {0,2.7546,5.5052,8.2467,10.974,13.682,16.365,19.23,22.058,24.846,27.587,29.858,29.981,29.876,29.968,29.833,29.895,29.941,29.888,29.937};
+
+float getNextReferenceSpeed() {
+ static int index = 0;
+ return valeursVitessesRecommandes[index++];
+}
+
+
+
Serial* SpeedLimiter::pc = new Serial(USBTX, USBRX);
SpeedLimiter::SpeedLimiter(const PinName& pedalInHi, const PinName& pedalInLo, const PinName& pedalOutHi, const PinName& pedalOutLo)
@@ -24,6 +33,17 @@
void SpeedLimiter::ipControllerTransferFunction()
{
+ static int counter = 0;
+ // une fois par 10 * 0.1 secondes -> 1 seconde
+ if (counter < 10 - 1) {
+ counter++;
+ }
+ else {
+ counter = 0;
+ float nextReferenceSpeed = getNextReferenceSpeed();
+ setReferenceSpeed(getNextReferenceSpeed());
+ pc->printf("%f\n\r", nextReferenceSpeed);
+ }
// write voltages at beginning of function to prevent jitter
// voltage will be delayed by 1 call which is okay.
// pc->printf("H\n\r");