Page 1 of 1

2 LEDC channels, 180 deg. apart

Posted: Sun Aug 04, 2019 8:17 pm
by mikemoy
I need to have 2 pin fade in and out with the same timing, but with a twist. I need them to be exactly 180 deg. apart from one another.
i.e. when pin(a) is at its highest intensity of it's fade cycle, it's at that point when pin(b) is at its lowest.

Re: 2 LEDC channels, 180 deg. apart

Posted: Sun Aug 04, 2019 8:30 pm
by PaulNi
Take a look at a nand gate. But I bet there will be another twist... LED average current and its observable brightness are not linear.

I think there is no alternative than to just use 2 PWM channels.

Re: 2 LEDC channels, 180 deg. apart

Posted: Sun Aug 04, 2019 8:39 pm
by mikemoy
Thanks, but the truth be told i need 3 pins, all 120 deg. apart.
I am trying a crazy idea to use 3 LEDC pins to implement SPWM to control a BLDC motor.

Re: 2 LEDC channels, 180 deg. apart

Posted: Mon Aug 05, 2019 1:55 am
by ESP_houwenxiang
Hi, mikemoy

In the LEDC channel configuration parameters, we provide hpoint to configure the phase. Plese note that these three channels need to use the same timer.

Code: Select all

typedef struct {
    int gpio_num;
    ....
    uint32_t duty;
    int hpoint;
} ledc_channel_config_t;