Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

softPwm --> ledcWrite #33

Open
pllagunos opened this issue Jun 20, 2023 · 0 comments
Open

softPwm --> ledcWrite #33

pllagunos opened this issue Jun 20, 2023 · 0 comments

Comments

@pllagunos
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant