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: MPU6050_V3 mbed-rtos mbed
Fork of BroBot_RTOS_Development by
Diff: stepper_motors.h
- Revision:
- 11:2553f5798f84
- Parent:
- 6:62cdb7482b50
- Child:
- 12:16d1a5390022
diff -r 48f640a54401 -r 2553f5798f84 stepper_motors.h
--- a/stepper_motors.h Tue Jan 10 21:10:39 2017 +0000
+++ b/stepper_motors.h Thu Jan 19 19:18:54 2017 +0000
@@ -1,6 +1,6 @@
//STEPPER MOTORS
#define ZERO_SPEED 1000000 //65535
-#define MAX_ACCEL 7
+#define MAX_ACCEL 2
#define ENABLE 0
#define DISABLE 1
@@ -57,8 +57,12 @@
void setMotor1Speed(int16_t speed)
{
long timer_period;
+ //If the speed has not changed, do not update the timer!
+ if(speed_M1 == speed){
+ return;
+ }
speed = CAP(speed, MAX_CONTROL_OUTPUT);
-
+
//Calculate acceleration from the desired speed
int16_t desired_accel = speed_M1 - speed;
if(desired_accel > MAX_ACCEL)
@@ -87,6 +91,10 @@
void setMotor2Speed(int16_t speed)
{
long timer_period;
+ //If the speed has not changed, do not update the timer!
+ if(speed_M2 == speed){
+ return;
+ }
speed = CAP(speed, MAX_CONTROL_OUTPUT);
//Calculate acceleration from the desired speed
