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:
- 34:b035131eda3e
- Parent:
- 32:da34d27a13f3
- Child:
- 35:51914ac2d7f4
diff -r da34d27a13f3 -r b035131eda3e motorAndSensorControl.cpp --- a/motorAndSensorControl.cpp Wed Oct 09 14:19:23 2019 +0000 +++ b/motorAndSensorControl.cpp Thu Oct 10 10:56:23 2019 +0000 @@ -29,7 +29,7 @@ const double PI = 3.14159265358979; const float countsToRadians = (2*PI)/uniqueMeasurementPoints; //Number of radians per count - + motorData motorReturn; void motorAndEncoder(float PWM1, float PWM2, float dt) { @@ -60,7 +60,9 @@ motor2.period(periodPWM); motor2.write(PWM2); + //Read encoders + //Counts //set the value from last loop to poisition 0 in the vector countsMotor1[0] = countsMotor1[1]; @@ -75,12 +77,13 @@ velocityMotor1 = ((countsMotor1[1]-countsMotor1[0])/countsToRadians)/dt; //rad/s velocityMotor2 = ((countsMotor2[1]-countsMotor2[0])/countsToRadians)/dt; //rad/s - motorReturn.motor1.counts = countsMotor1[1]; - motorReturn.motor2.counts = countsMotor2[1]; + ::motorReturn.motor1.counts = countsMotor1[1]; + ::motorReturn.motor2.counts = countsMotor2[1]; - motorReturn.motor1.angle = angleMotor1; - motorReturn.motor2.angle = angleMotor2; + ::motorReturn.motor1.angle = angleMotor1; + ::motorReturn.motor2.angle = angleMotor2; - motorReturn.motor1.velocity = velocityMotor1; - motorReturn.motor2.velocity = velocityMotor2; + ::motorReturn.motor1.velocity = velocityMotor1; + ::motorReturn.motor2.velocity = velocityMotor2; + }