Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Changing Duty Cycle Dynamically Creates Runt PWM pulse #10

Closed
@RockingYProductions

Description

@RockingYProductions

Arduino IDE version 1.8.13
RP2040 Core Version arduino-pico core v2.5.2
RP2040 Board type RASPBERRY_PI_PICO
Using OSX 12.6

Contextual information

There was observed to be a runt or glitch generated when switching the duty cycle, that lasted only the cycle the update occurred at. This runt/glitch is detectable by our receiver, and although it only lasts one cycle, it causes jitter issues.

Is there a way to switch Duty Cycle precisely between the last complete cycle of the current PWM cycle and the next complete cycle of the new PWM duty cycle value.

Simplest possible steps to reproduce (see attached scope shot). You can pick different duty cycles and get the same effect.

const float PWMFREQ           = 100;      // PWM frequency on GPIO pin
const byte GPIO_PIN           = 19;

void setup()
{
  PWM_Instance = new RP2040_PWM(GPIO_PIN, PWMFREQ, 0);
  PWM_Instance->setPWM(GPIO_PIN, PWMFREQ, 0, true);
  ..
}
void loop()
{   
  PWM_Instance->setPWM(GPIO_PIN, 100, 50, true);
  ...
  PWM_Instance->setPWM(GPIO_PIN, 100, 20, true);
  ...
}

Attached Scope Screen Shot where the duty cycle changed.

SDS00007

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions