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: HIDScope mbed MODSERIAL QEI
Diff: Motor.cpp
- Revision:
- 12:69a9cf74583e
- Parent:
- 11:dd1976534a03
- Child:
- 13:559f8946f16d
--- a/Motor.cpp Mon Oct 30 15:32:27 2017 +0000 +++ b/Motor.cpp Mon Oct 30 16:28:21 2017 +0000 @@ -7,7 +7,7 @@ _Encoder.QEI::reset(); frequency=50000; set_period(frequency); - angle=45; + angle=90; safety_angle = 120; //safety angle in DEGREES _direction= 1; low_PWM = 0.6; @@ -19,7 +19,7 @@ _Encoder.QEI::reset(); frequency=freq; set_period(frequency); - angle= 45; + angle= 90; safety_angle = safe; _direction= 1; low_PWM= low; @@ -36,7 +36,7 @@ int n_pulse= _Encoder.QEI::getPulses(); - angle = 45 + ((n_pulse)*(360/32))/131; // get angle (131 is the gear ratio of the motor in order to work in degrees of the actual arm) + angle = 90 + ((n_pulse)*(360/32))/131; // get angle (131 is the gear ratio of the motor in order to work in degrees of the actual arm) return angle; } @@ -46,10 +46,10 @@ //float step = 360/(32*131); //control_angle = control_angle - fmodf(control_angle, step) ; //changle control angle to posible angles of the sensor - if(control_angle > safety_angle+45) - control_angle = safety_angle+45; - if(control_angle < -safety_angle+45) - control_angle = -safety_angle+45; + if(control_angle > safety_angle+90) + control_angle = safety_angle+90; + if(control_angle < -safety_angle+90) + control_angle = -safety_angle+90; double error = angle - control_angle; //set error probably need some kind of PID