
final
Dependencies: MatrixMath Matrix ExperimentServer QEI_pmw MotorShield
Revision 4:7a1b35f081bb, committed 2020-08-21
- Comitter:
- elijahsj
- Date:
- Fri Aug 21 16:59:39 2020 +0000
- Parent:
- 3:2e531f5b80ce
- Child:
- 5:1ab9b2527794
- Commit message:
- updated mbed version;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Jul 19 16:57:28 2019 +0000 +++ b/main.cpp Fri Aug 21 16:59:39 2020 +0000 @@ -14,24 +14,25 @@ DigitalOut motorRev(D7); // Motor backward enable Timer t; // Timer to measure elapsed time of experiment -QEI encoder(D3,D4, NC, 1200 , QEI::X4_ENCODING); // Pins D3, D4, no index, 1200 counts/rev, Quadrature encoding +QEI encoder(D3,D4, NC, 1200, QEI::X4_ENCODING); // Pins D3, D4, no index, 1200 counts/rev, Quadrature encoding -int main (void) { +int main (void) +{ // Link the terminal with our server and start it up server.attachTerminal(pc); server.init(); // PWM period should nominally be a multiple of our control loop motorPWM.period_us(500); - + // Continually get input from MATLAB and run experiments float input_params[NUM_INPUTS]; - + while(1) { if (server.getParams(input_params,NUM_INPUTS)) { float v1 = input_params[0]; // Voltage for first second float v2 = input_params[1]; // Voltage for second second - + // Setup experiment t.reset(); t.start(); @@ -41,23 +42,23 @@ motorPWM.write(0); // Run experiment - while( t.read() < 2 ) { + while( t.read() < 2 ) { // Perform control loop logic - if (t.read() < 1) + if (t.read() < 1) motorPWM.write(v1); - else + else motorPWM.write(v2); - - // Form output to send to MATLAB + + // Form output to send to MATLAB float output_data[NUM_OUTPUTS]; output_data[0] = t.read(); output_data[1] = encoder.getPulses(); output_data[2] = encoder.getVelocity(); - + // Send data to MATLAB server.sendData(output_data,NUM_OUTPUTS); - wait(.001); - } + wait(.001); + } // Cleanup after experiment server.setExperimentComplete(); motorPWM.write(0);
--- a/mbed-os.lib Fri Jul 19 16:57:28 2019 +0000 +++ b/mbed-os.lib Fri Aug 21 16:59:39 2020 +0000 @@ -1,1 +1,1 @@ -https://github.com/armmbed/mbed-os/#5941d1718339116cd12914238ec331c84da3d08f +https://github.com/armmbed/mbed-os/#b6370b4c37f3d4665ed1cdcb1afea85396bba1b3