Forums - How to use PioConfigPWM

3 posts / 0 new
Last post
How to use PioConfigPWM
kian
Join Date: 8 Jun 16
Posts: 43
Posted: Tue, 2016-07-19 23:49

Hi all,

I am quite confused by how the PioConfigPWM command works. In the documentation, it is stated as this:
 

bool PioConfigPWM (uint16 pwm_id, pio_pwm_mode mode, uint8 dull_on_time, uint8 dull_off_time, uint8 dull_hold_time, uint8 bright_on_time, uint8 bright_off_time, uint8 bright_hold_time, uint8 ramp_rate) Allows the user application to configure the PIO's Pulse Width Modulation driver. 

dull_off_time the amount of time, in units of ~30us, for which the LED should be off during the dullest part of the flash sequence.

dull_on_time the amount of time, in units of ~30us, for which the LED should be on during the dullest part of the flash sequence.

dull_hold_time the amount of time, in units of ~16ms, for which the LED should be held in the dullest part of the flash sequence.

bright_off_time the amount of time, in units of ~30us, for which the LED should be off during the brightest part of the flash sequence.

bright_on_time the amount of time, in units of ~30us, for which the LED should be on during the brightest part of the flash sequence.

bright_hold_time the amount of time, in units of ~16ms, for which the LED should be held in the brightest part of the flash sequence.

ramp_rate the ramp rate for ramping between brightness levels, in units of ~30us per step with 0 being instantaneous (no ramp).

 

A PWM signal is basically varying between a high and low state with a pre-configured duty cycle and period. So be it should be something as simple as specifiying the duration of the HIGH state and the duration of the LOW state.

Is the PIO pin in a HIGH state or low state when it dull? What exactly does dull_on_time, dull_off_time and dull_hold_time mean?

Lets say if I want to blink my LED at maximum brightness for 160ms, the turn off the LED for another 160ms (50% duty cycle), what should be the configuration?

Another scenerio, lets say I want to adjust the brightness of my LED and set it to 10% brightness (10% duty cycle), what should be the configuration?

Finally, what is the useage of ramp rate? This is all so confusing.

  • Up0
  • Down0
kian
Join Date: 8 Jun 16
Posts: 43
Posted: Wed, 2016-07-20 04:22

I figured it out.

dull_on_time and dull_off_time sets the duty cycle and dull_hold_time sets the period.

Similarly, bright_on_time and bright_off_time sets the duty cycle and bright_hold_time sets the period.

 

  • Up0
  • Down0
cbs
Profile picture
Join Date: 4 Mar 15
Location: IoT consultant, Cambridgeshire, UK
Posts: 21
Posted: Wed, 2016-07-20 09:16

You wouldn't normally set 160ms for the PWM on an LED - the cycle time needs to be below the critical fusion frequency (40Hz or approx 25ms) otherwise you'll see it flashing rather than a controllable dimness. I'd go as high frequency as you can permitting sufficient control of the duty factor - your LED and the electronics driving it are likely to have a response much faster than 30us.

Chris

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.