Joe3
December 30, 2022, 3:38am
1
Putting any number in the optional transition length creates a slow then fast then slow movement. I had a note years ago that it didn’t work then and I just tried it again with the latest esphome version… Still not working.
Has anyone notice this option isn’t working?
servo:
- id: my_servo
output: pwm_output
- id: my_servo2
output: pwm_output2
transition_length: 5s
Blacky
January 1, 2023, 8:37am
2
Below is the example from ESP Home… have a look at it and then look at your code.
# Example configuration entry
servo:
- id: my_servo
output: pwm_output
# Example output platform
# On ESP32, use ledc output
output:
- platform: esp8266_pwm #what ESP are you using?
id: my_servo2
pin: D1 #what pin are you using?
frequency: 50 Hz
transition_length: 5s
I’m playing with a server right now and I have a similar problem. So I set the servo movement time, upload it to esphome and the first movement ignores the set time length of the movement, only when the second moves according to the set time. I have no idea what it could be, but it’s causing quite a problem. I have the code like this:
# Example output platform
# On ESP32, use ledc output
output:
- platform: ledc
id: pwm_output
pin: GPIO32
frequency: 50 Hz
# Example configuration entry
servo:
- id: my_servo
output: pwm_output
transition_length: 10s
min_level: 3%
idle_level: 7.5%
max_level: 12%
auto_detach_time: 10s
Blacky
January 1, 2023, 4:27pm
4
maybe have a read of this
darisole
(Dario S)
February 2, 2023, 8:52am
5
I’m having the same problem: the very first servo movement after boot is jerky, ignoring the transition_length. From the second movement, everything works fine.
Here is my config:
servo:
- id: rotation_servo
output: servo_pwm_output
transition_length: 10s
auto_detach_time: 1s
restore: false
output:
- platform: ledc
id: servo_pwm_output
pin: GPIO17
frequency: 50Hz
I tried both with restore: true
and restore: false
, with no change in behavior.
At this point I suspect it’s a software bug in ESPhome or underlying libraries, because we’re 3 users using (probably) different servos.
Also, the jerky behavior happens with just a ESP reboot, so without removing power to the servo.
tuct
(Tobias Stanzel)
October 15, 2023, 1:51pm
6
Have the same issue, only that the transition time seems to be always ignored.
I created an issue in github:
opened 01:49PM - 15 Oct 23 UTC
### The problem
When using the servo component, it seems the transition length … is ignored / not working.
Regardless of what I set, I see in the logs the reached a new position in the same sec as it was set.
Here is a link to similar reportings:
https://community.home-assistant.io/t/servo-transition-length-2s-not-working/509970/4
### Which version of ESPHome has the issue?
2023.9.3
### What type of installation are you using?
pip
### Which version of Home Assistant has the issue?
none
### What platform are you using?
ESP32
### Board
esp32-devkit4
### Component causing the issue
servo
### Example YAML snippet
```yaml
number:
- platform: template
id: servo_pos
min_value: -100
initial_value: 0
max_value: 100
step: 10
optimistic: true
set_action:
then:
- servo.write:
id: lid_servo
level: !lambda 'return x / 100.0;'
servo:
- id: lid_servo
output: pwm_servo
transition_length: 50s
auto_detach_time: 1s
```
### Anything in the logs that might be useful for us?
```txt
https://esphome.io/api/servo_8cpp_source
Those lines seem to be reached without delay
if (this->target_value_ == this->current_value_ && this->state_ == STATE_ATTACHED) {
this->state_ = STATE_TARGET_REACHED;
this->start_millis_ = millis(); // set current stamp for potential auto_detach_time_ check
ESP_LOGD(TAG, "Servo reached target");
}
So i expect something wrong here:
if (this->target_value_ != this->current_value_ && this->state_ == STATE_ATTACHED) {
if (this->transition_length_) {
float new_value;
float travel_diff = this->target_value_ - this->source_value_;
uint32_t target_runtime = abs((int) ((travel_diff) * this->transition_length_ * 1.0f / 2.0f));
uint32_t current_runtime = millis() - this->start_millis_;
float percentage_run = current_runtime * 1.0f / target_runtime * 1.0f;
if (percentage_run > 1.0f) {
percentage_run = 1.0f;
}
new_value = this->target_value_ - (1.0f - percentage_run) * (this->target_value_ - this->source_value_);
this->internal_write(new_value);
} else {
this->internal_write(this->target_value_);
}
}
```
### Additional information
_No response_
Checked the code and no obvious issue is visible ( have no debug setup) - but the log definitly shows that the transition time is ignored