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: FastPWM mbed QEI biquadFilter HIDScope MODSERIAL
Diff: main.cpp
- Revision:
- 28:aec0d9bdb949
- Parent:
- 27:3430dfb4c9fb
- Child:
- 29:d8e51f4cf080
--- a/main.cpp Tue Oct 30 09:13:59 2018 +0000 +++ b/main.cpp Tue Oct 30 09:17:31 2018 +0000 @@ -42,9 +42,6 @@ QEI Encoder3(D13,D12,NC,4200); // Counterclockwise motor rotation is the positive direction Ticker motor; Ticker encoders; -HIDScope scope(2); -Ticker HIDTicker; - // Global variables const float pi = 3.14159265358979; @@ -55,22 +52,8 @@ const double Ki = 1.02; // given value is 1.02 //const double Ts = 0.0025; // Sample time in seconds -volatile float x; -volatile float xprev = 0; -volatile float y; - // Functions -void ShowHIDScope() -{ x = pot1; - scope.set(0,x); - y = (xprev+x)/2.0; - scope.set(1,y); - xprev = x; - - scope.send(); -} - -/* //Subfunctions + //Subfunctions int Counts1input() { int counts1; counts1 = Encoder1.getPulses(); @@ -100,7 +83,7 @@ double ErrorCalc(double yref,double CurAngle) { double error = yref - CurAngle; - return error; + return error; } double Pcontroller(double yref,double CurAngle) @@ -192,7 +175,7 @@ pin5.period(0.1); pin6.period(0.1); motor.attach(turn1,dt); - HIDTicker.attach(ShowHIDScope,dt); + emergencybutton.rise(Emergency); //If the button is pressed, stop program while (true)