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.
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 10:8c38a1a5b522
- Parent:
- 9:e8cc37a94fec
- Child:
- 12:f4331640e3ad
--- a/main.cpp Mon Oct 21 12:17:39 2019 +0000
+++ b/main.cpp Mon Oct 21 12:44:20 2019 +0000
@@ -23,8 +23,8 @@
MODSERIAL pc(USBTX, USBRX);
QEI Encoder(D8,D9,NC,8400);
-float PI = 3.1415926;//535897932384626433832795028841971693993;
-float timeinterval = 0.001; // Time interval of the Ticker function
+float PI = 3.1415926f;//535897932384626433832795028841971693993;
+float timeinterval = 0.001f; // Time interval of the Ticker function
bool whileloop = true; // Statement to keep the whileloop in the main function running
// While loop has to stop running when failuremode is activated
@@ -40,7 +40,7 @@
void motorsoff() {
bool aa = true; // Boolean for the while loop
- sendtomotor(0);
+ sendtomotor(0.0f);
while (aa) {
if (button1.read() == 0) { // If button1 is pressed, set MyState to EMG_CALIBRATION and exit the while loop
MyState = EMG_CALIBRATION;
@@ -48,8 +48,11 @@
}
}
}
-
-
+/*
+void emgcalibration() {
+ // do calibration
+}
+*/
//P control implementation (behaves like a spring)
double P_controller(double error)
{
@@ -75,6 +78,7 @@
case EMG_CALIBRATION :
pc.printf("State: EMG Calibration");
+ //measureandcontrol(emgcalibration,timeinterval);
break;
case MOTOR_CALIBRATION :
@@ -113,7 +117,7 @@
default :
pc.printf("Default state: Motors are turned off");
- sendtomotor(0);
+ sendtomotor(0.0f);
break;
}
}
@@ -126,8 +130,8 @@
int main()
{
pc.printf("Starting...\r\n\r\n");
- double frequency = 17000.0;
- double period_signal = 1.0/frequency;
+ double frequency = 17000.0f;
+ double period_signal = 1.0f/frequency;
pc.baud(115200);
button2.fall(failuremode); // Function is always activated when the button is pressed
@@ -146,7 +150,7 @@
}
pc.printf("Programm stops running\r\n");
- sendtomotor(0);
+ sendtomotor(0.0f);
measurecontrol.attach(nothing,10000);
return 0;
}