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.
Fork of motor by
Diff: motor.cpp
- Branch:
- testing
- Revision:
- 9:22b119eef1de
- Parent:
- 8:4df2a47ab4ee
- Child:
- 10:f4fc8ccde4ad
--- a/motor.cpp Mon Nov 07 16:12:48 2016 +0000
+++ b/motor.cpp Mon Nov 07 16:37:58 2016 +0000
@@ -1,5 +1,6 @@
#include "mbed.h"
#include "TFC.h"
+#include <math.h>
DigitalOut myled(LED1);
@@ -132,6 +133,43 @@
}
+void speedSetting(int w1, int w2 ,int w1M, int w2M)
+{
+ // need to compare the measured frequency
+
+ float deltaW1 = w1 - w1M;
+ float deltaW2 = w2 - w2M;
+
+ if(delatW1 <0)
+ {
+ changespeed(0,w1);
+ }
+
+ else if(delatW1 >0)
+ {
+ changespeed(1,w1);
+ }
+ return;
+}
+
+//need to fill out function for calculating the change in speed.
+void changespeed(bool a, float w)
+{
+ float change;
+
+ if(a == 1)
+ {
+ w+= change;
+ }
+
+ else if (a ==0)
+ {
+
+ w-= change;
+ }
+ return;
+}
+
//----------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------Cornering Control-----------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------
@@ -171,6 +209,8 @@
float deltaTheta = center- theta;
+
+ // need to convert to degrees/radians. that can do the above as well.
if(deltaTheta <0)
{
// going left?
@@ -180,7 +220,7 @@
else()
{
//going right?
- corner(w2,w1,deltaTheta)
+ corner(w2,w1,deltaTheta);
}
