Servo & I2C Timer issue

lynestelles
Posts: 1
Joined: Fri Feb 15, 2019 1:37 pm

Servo & I2C Timer issue

Postby lynestelles » Fri Feb 15, 2019 1:56 pm

I have a ESP32 that I am trying to use to drive a prop. In this I have a RGB sensor running on i2c and a servo. At start up, I call Wire.begin() to get I2C set up, and then set up my servo . At about this time I have the ESP32Servo Class is printing out to the serial monitor:

"PWM requested on ledcwrite channel 1 using timer 0
WARNING PWM channel 1 shares a timer with 0
changing the frequency to 1000.00 Hz will ALSO change channel 0
from its previous frequency of 50.00 Hz".

When I start the sketch, the I2C sensor works and reports its values to the serial monitor every second as it should, but once it becomes time for the servo to move, it knocks the I2C sensor offline. Using the return value from the ESP32Servo::attach() function, it tells me that it is using channel 1.

From what I can determine, this is simply an issue of one of the 4 timers being used for two separate things and conflicting. I THINK its an issue with the I2C clock using the same timer as the Servo. It may be worth noting that I have the I2C clock running at 10000.

Can anyone advise what would be the best way to handle this?

idahowalker
Posts: 166
Joined: Wed Aug 01, 2018 12:06 pm

Re: Servo & I2C Timer issue

Postby idahowalker » Fri Feb 15, 2019 3:57 pm

I found that the ESPservo likes to distribute the servos amongst the timers. You just might get away with declaring two dummy servos before declaring the real servos. The 2 dummy servos should get assigned to timer 0 and the 3rd servo to timer 1. You'd just not use the dummy servos assigned to timer0

madhephaestus
Posts: 1
Joined: Tue Feb 04, 2020 1:39 am

Re: Servo & I2C Timer issue

Postby madhephaestus » Tue Feb 04, 2020 1:43 am

Author of ESP32Servo here.

Take a look into the sensor and see if you can specify which timer to use. The ESP32Servo class will allocate timers in order, starting with 0.

If that's not possible, before calling servo.begin(), call

```
ESP32PWM::timerCount[0]=4;
```

This should lock out timer channel 0 and allow the timer allocations for the servos jump right to timer 1.

If you wanted to deallocat timers 0 and 1, then you would call:

```
ESP32PWM::timerCount[0]=4;
ESP32PWM::timerCount[1]=4;
```

Adding dummy servos was something you did in the old version to avoid the random dispersal across many timers.

idahowalker
Posts: 166
Joined: Wed Aug 01, 2018 12:06 pm

Re: Servo & I2C Timer issue

Postby idahowalker » Fri Feb 07, 2020 10:38 pm

madhephaestus wrote:
Tue Feb 04, 2020 1:43 am
Author of ESP32Servo here.

Take a look into the sensor and see if you can specify which timer to use. The ESP32Servo class will allocate timers in order, starting with 0.

If that's not possible, before calling servo.begin(), call

```
ESP32PWM::timerCount[0]=4;
```

This should lock out timer channel 0 and allow the timer allocations for the servos jump right to timer 1.

If you wanted to deallocat timers 0 and 1, then you would call:

```
ESP32PWM::timerCount[0]=4;
ESP32PWM::timerCount[1]=4;
```

Adding dummy servos was something you did in the old version to avoid the random dispersal across many timers.
Oi! The author of ESP32Servo.

I used ESP32Servo for a few. I switched to using the MCPWM, why not use the MCPWM for ESP32 servo?

Who is online

Users browsing this forum: Google [Bot] and 42 guests