Thanks to visit codestin.com
Credit goes to github.com

Skip to content

softPwm --> ledcWrite #33

@pllagunos

Description

@pllagunos

Hi.

In my application I am using a ESP32 driving a thrystor using 8 bit PWM. According to the manufacturer the minimum PWM frequency should be 1kHz. Using softPwm, this would mean the windowSize should be < 1 (since millis is used). Since in the .cpp, time variables are uint32_t, the maximum frequency using softPwm would be 1kHz, right?

Then what I don't understand is what would happen with the following MAX31856 example:
`void loop() {
float optimumOutput = tuner.softPwm(relayPin, Input, Output, Setpoint, outputSpan, debounce);

switch (tuner.Run()) {
case tuner.sample: // active once per sample during test
if (!digitalRead(drdyPin)) Input = maxthermo.readThermocoupleTemperature();
tuner.plotter(Input, Output, Setpoint, 0.5f, 3); // output scale 0.5, plot every 3rd sample
break;

case tuner.tunings: // active just once when sTune is done
  tuner.GetAutoTunings(&Kp, &Ki, &Kd); // sketch variables updated by sTune
  myPID.SetOutputLimits(0, outputSpan * 0.1);
  myPID.SetSampleTime(outputSpan - 1);

...`

because when I set outputSpan = 1 (to get the necesarry 1kHz frequency of the PWM) then the PID output will be limited to a max of 0.1.

Would using a function like ledcWrite, which allows frequency to be specified, help solve this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions