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: FastPWM HIDScope MODSERIAL QEI Matrix biquadFilter controller errorFetch mbed motorConfig refGen MatrixMath inverseKinematics
Fork of Minor_test_serial by
Revision 20:4ce3fb543a45, committed 2017-10-06
- Comitter:
- tvlogman
- Date:
- Fri Oct 06 07:23:26 2017 +0000
- Parent:
- 19:f08b5cd2b7ce
- Child:
- 21:d266d1e503ce
- Commit message:
- Fixed the direction problems, tried, tested, works.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Oct 06 05:29:52 2017 +0000
+++ b/main.cpp Fri Oct 06 07:23:26 2017 +0000
@@ -36,15 +36,17 @@
// MOTOR CONTROL PART
+bool m1_direction = false;
+
// Function getReferenceVelocity returns reference r between -8.4 and 8.4 rad/s
float getReferenceVelocity(){
const float maxVelocity = 8.4; // max velocity in rad/s
double r;
- if(motor1_direction = false){
+ if(m1_direction == false){
// Clockwise rotation yields positive reference
r = maxVelocity*pot.read();
}
- if(motor1_direction = true){
+ if(m1_direction == true){
// Counterclockwise rotation yields negative reference
r = -1*maxVelocity*pot.read();
}
@@ -103,7 +105,7 @@
void M1switchDirection(){
- motor1_direction = !motor1_direction;
+ m1_direction = !m1_direction;
}
// readEncoder reads counts and revs and logs results to serial window
@@ -118,7 +120,7 @@
int main()
{
pc.printf("Main function");
- motor1_direction = false; // False = clockwise rotation
+ motor1_direction = 0; // False = clockwise rotation
motor1_pwm.period(pwmPeriod);//T=1/f
sw2.fall(&killSwitch);
sw3.fall(&turnMotorsOn);
