MDDS 30 Input Error ESP32 PWM

Autonomous Robot, Manual Robot, DC Motor Driver, Stepper Motor Driver, Servo, Multi PWM chip.....

MDDS 30 Input Error ESP32 PWM

Postby loca5790 » Tue Mar 19, 2024 8:47 am

Hello All,

Appreciate the help first and foremost.

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

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

sensor:
- platform: adc
pin: GPIO34
id: potentiometer_input
update_interval: 100ms
attenuation: 11db
filters:
- calibrate_linear:
datapoints:
- 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;

globals:
- 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'

number:
- 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
on_value:
then:
- lambda: |-
id(max_pwm_level) = (id(target_pwm_level).state/100);

switch:
- 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:
- interval: 100ms
then:
- lambda: |-

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

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
}

id(pwm_output).set_level(id(soft_start_level));


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.
loca5790
Fledgling
 
Posts: 1
Joined: Tue Mar 19, 2024 8:25 am

Re: MDDS 30 Input Error ESP32 PWM

Postby waiweng83 » Mon Apr 22, 2024 6:43 pm

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?
With the power of dream, nothing is impossible...
User avatar
waiweng83
Moderator
 
Posts: 208
Joined: Wed Apr 15, 2009 2:17 pm


Return to Robot Controller

Who is online

Users browsing this forum: No registered users and 10 guests