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: QEI mbed-rtos mbed
Diff: main.cpp
- Revision:
- 12:d09b8ffa176f
- Parent:
- 11:7e19e51b325d
- Child:
- 13:6b3533b4f664
--- a/main.cpp Wed Dec 04 04:19:30 2013 +0000 +++ b/main.cpp Wed Dec 04 04:36:27 2013 +0000 @@ -134,7 +134,7 @@ void computing(void const *args) { float z1=0.0, z2=0.0, dz1 = 0.0, dz2 = 0.0, z3 = 0.0, dz3 = 0.0; bool firstTime = true; - + bool controller = 0; while (true ) { t = T.read(); @@ -173,12 +173,18 @@ z3 = z3 + dz3 * dt; mCurrent = z3; + if (sin(theta2) < 0.0) + controller = 1; + if (cos(theta2) < 0.96) + controller = 0; + //set pwm - if (cos(theta2) < 0.96) { + if ( controller == 0) { + flag = 1; currentEnergy = calcEnergy(); inputVoltage = -2.3*dtheta2*(0.0372 - currentEnergy); - inputVoltage = 0.0; + //inputVoltage = 0.0; } else { flag = 1;