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: motorAndSensorControl.cpp
- Revision:
- 22:4197629a300f
- Parent:
- 21:0a37e3280bbd
- Child:
- 27:71be6e074d0f
--- a/motorAndSensorControl.cpp Fri Oct 04 10:07:27 2019 +0000 +++ b/motorAndSensorControl.cpp Fri Oct 04 10:17:19 2019 +0000 @@ -24,7 +24,7 @@ const double PI = 3.14159265358979; const float countsToRadians = (2*PI)/uniqueMeasurementPoints; //Number of radians per count -float motorAndEncoder(float voltage1, float periodMotor1, float voltage2, float periodMotor2, float dt) +void motorAndEncoder(float voltage1, float periodMotor1, float voltage2, float periodMotor2, float dt, float &countsMotor1Return, float &countsMotor2Return, float &velocityMotor1Return, float &velocityMotor2Return) { //Set motors //Direction @@ -64,5 +64,8 @@ velocityMotor1 = ((countsMotor1[1]-countsMotor1[0])/countsToRadians)/dt; //rad/s velocityMotor2 = ((countsMotor2[1]-countsMotor2[0])/countsToRadians)/dt; //rad/s - return (velocityMotor1, velocityMotor2, countsMotor1[1], countsMotor2[1]); + countsMotor1Return = countsMotor1[1]; + countsMotor2Return = countsMotor2[1]; + velocityMotor1Return = velocityMotor1; + velocityMotor2Return = velocityMotor2; } \ No newline at end of file