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: ExperimentServer QEI_pmw MotorShield
Diff: main.cpp
- Revision:
- 23:4056ae374b62
- Parent:
- 22:c010476ffeb8
- Child:
- 24:4d2f1b7746de
--- a/main.cpp Sat Sep 25 21:09:19 2021 +0000 +++ b/main.cpp Mon Sep 27 19:55:21 2021 +0000 @@ -22,6 +22,7 @@ //Controller values float volt = 0; float duty = 0; +float cum_error = 0; Serial pc(USBTX, USBRX); // USB Serial Terminal ExperimentServer server; // Object that lets us communicate with MATLAB @@ -38,6 +39,7 @@ void current_control() //Current control function { float error = 0; + theta = encoderA.getPulses()*(6.2831/1200.0); velocity = encoderA.getVelocity()*(6.2831/1200.0); current = -(motorShield.readCurrentA()*(30.0/65536.0)-15.0); //read current for motor A in amps. Note: this is a slightly different current sensor so its a different conversion than last lab. error = current_d - current; @@ -94,7 +96,7 @@ // Run experiment while( t.read() < 5 ) { // Perform control loop logic - // current_d = 0; // Set commanded current from impedance controller here. + //current_d = 0; // Set commanded current from impedance controller here. // Send data to MATLAB float output_data[NUM_OUTPUTS];