Page 1 of 1

MDDS 30 Input Error ESP32 PWM

PostPosted: Tue Mar 19, 2024 8:47 am
by loca5790
Hello All,

Appreciate the help first and foremost.

I have an MDDS30 wired to an esp32 code example below:
- platform: ledc
pin: GPIO23
id: pwm_output
frequency: 1000 Hz

##New for reverse
- platform: gpio
number: GPIO32
mode: INPUT_PULLUP # Assuming an active-low switch
name: "Reverse Input"
id: reverse_input
- delayed_on: 10ms # Debounce configuration
- delayed_off: 10ms
- lambda: |-
if (id(reverse_input).state) {
// Switch is ON
} else {
// Switch is OFF

- platform: adc
pin: GPIO34
id: potentiometer_input
update_interval: 100ms
attenuation: 11db
- calibrate_linear:
- 0.9 -> 0.0
- 2.5 -> 1.0
- platform: template
name: "PWM Output Percent"
accuracy_decimals: 1
update_interval: 100ms
lambda: |-
return id(soft_start_level) * 100;

- id: soft_start_level
type: float
restore_value: no
initial_value: '0.0'
- id: stopped_threshold
type: float
restore_value: no
initial_value: '0.05' # 5% - Considered as "stopped" state
- id: low_speed_threshold
type: float
restore_value: no
initial_value: '0.3' # 30% - Low speed threshold
- id: high_speed_threshold
type: float
restore_value: no
initial_value: '0.7' # 70% - High speed threshold
- id: low_speed_rate
type: float
restore_value: no
initial_value: '0.035' # Soft start rate for low speed # originally .02 and .05 seems aggressive
- id: stopped_rate
type: float
restore_value: no
initial_value: '0.015' # Soft start rate from stopped condition # originally .01 and .02 seems aggressive
# - id: pwm_kill_switch
# type: bool
# restore_value: no
# initial_value: 'false'
- id: max_pwm_level
type: float
restore_value: no
initial_value: '0.8' # 80% maximum PWM level
#New for reverse
- id: relay_state
type: bool
restore_value: yes
initial_value: 'false'

- platform: template
name: "Max PWM Level"
id: target_pwm_level
min_value: 40.0
max_value: 100.0
step: 5.0
restore_value: True
optimistic: true
- lambda: |-
id(max_pwm_level) = (id(target_pwm_level).state/100);

- platform: template
name: "PWM Kill Switch"
id: pwm_kill_switch
optimistic: true
restore_mode: restore_default_off
##New for Reverse
- platform: gpio
name: "Reverse Output"
pin: GPIO33
id: output_relay_switch

- interval: 100ms
- lambda: |-

if (id(pwm_kill_switch).state) {
id(pwm_output).set_level(0.0); // Kill PWM output immediately

float target = id(potentiometer_input).state;
// Correctly use the state of the number component
target = std::min(target, id(max_pwm_level));

if (id(soft_start_level) <= id(stopped_threshold)) {
// Always apply soft start from a "stopped" state
id(soft_start_level) += id(stopped_rate);
} else if (id(soft_start_level) < id(low_speed_threshold)) {
// Apply different soft start logic for low speed
id(soft_start_level) += id(low_speed_rate);
} else if (id(soft_start_level) < target && id(soft_start_level) < id(high_speed_threshold)) {
// Continue with low speed rate until high threshold
id(soft_start_level) += id(low_speed_rate);
} else {
// Directly set to target above high speed threshold, except when starting from stopped
id(soft_start_level) = target;

if (id(soft_start_level) > target) {
id(soft_start_level) = target; // Ensure not exceeding target


The controller constantly sets input error on right channel only and the light blinks very very very dim. Hard to even notice it. When motors are tested via push buttons the left channel goes immedately to full speed and the right ramps to halfish speed (haven't verified pseed but its low).

The wiring is battery negative to negative and positive to positive. The battery voltage is 28.6V. Motors are two 775's.

AN1/2 go to ESP32 for PWM out and DI1/2 go to Digital out for direction. Ground is common between the esp32 and the AN/DI input connectors.

I have also tried testing it in Analog, PWM , Mixed and Indepdent modes with no success. When hooked up and powered on the left motor will randomly start pulsing forwards and backwards at varying intervals. I have tested the controller ontwo ESP32WRoom chips now and bench tested it before installing on LEDS and the sam prepihperal inputs that are used in the setup with success.

The project was previously working on a 24V 1000W scooter controlled but I move to this for direct directional control. Am I missing something in my setup?

Another MDDS30 is on the way as I'm not sure what is wrong because per the documentation and my testing what I'm doing should work. I can get no inptus to work and tech support has asked me to move to a serial setup but I don't want to put the effort and move away from ESPHome to do that with no success. There are reasong I'm refraining from the IDE eviroment if I can.

This is now my third attempt at mkaing this post as I keep getting logged out.

Re: MDDS 30 Input Error ESP32 PWM

PostPosted: Mon Apr 22, 2024 6:43 pm
by waiweng83
Unfortunately we're not familiar with the code for ESPHome.
Anyway, can you please measure the voltage on the pwm pins when the motor driver is showing error?