You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to implement servo ease control but I require a limited range of motion.
ServoData servoData;
servoData.speed = 60.0;
servoData.ease = 0.2;
servoData.position = 0;
const int minUs = 1500; // minimum timer width in microseconds for 0 degrees
const int maxUs = 2400; // maximum timer width in microseconds for 180 degrees
servo1.attach(SERVOPIN1, minUs, maxUs);
servo1.setFrequency(SERVOPIN1, 50);
float ye1 = 0.3;
servo1.write(SERVOPIN1, servoData.position);
delay(2000);
while (true) {
// Ensure position is within the range 40 to 180
if (ye1 <= 0.0) {
servoData.position = 180;
} else if (ye1 >= 1.0) {
servoData.position = 0;
}
ye1 = servo1.write(SERVOPIN1, servoData.position, servoData.speed, servoData.ease);
ESP_LOGI(TAG, "ye1: %f, position: %d", ye1, servoData.position);
delay(5);
I tried using the minUs/maxUs to limit it, and it kind of works,
But when the while loop is running in the first iteration before updating the position when ye1 =~ 0.2 then the servo rotates to what looks like close to position 0 then rotates to 180 and then rotates to the position = minUs. From this point it cycles between 180 and position =minUs (good)
Its the initial motion that I dont understand. Essentially I want to limit it to 45deg to 180. It should never go below 45. Does anyone have any recommendations?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to implement servo ease control but I require a limited range of motion.
I tried using the minUs/maxUs to limit it, and it kind of works,
But when the while loop is running in the first iteration before updating the position when ye1 =~ 0.2 then the servo rotates to what looks like close to position 0 then rotates to 180 and then rotates to the position = minUs. From this point it cycles between 180 and position =minUs (good)
Its the initial motion that I dont understand. Essentially I want to limit it to 45deg to 180. It should never go below 45. Does anyone have any recommendations?
Beta Was this translation helpful? Give feedback.
All reactions