pwm1_set_dutycycle_ratio() versus pwm1_set_dutycycle_percent()?

9 views
Skip to first unread message

A Webuser

unread,
Mar 6, 2023, 9:27:57 PM3/6/23
to jallist
What input does pwm1_set_dutycycle_ratio() take?  Is it expecting a byte?

Is it linear or is there some unique property to it?


Thanks!

Rob CJ

unread,
Mar 7, 2023, 1:41:09 PM3/7/23
to jal...@googlegroups.com
Hi Webuser,

For this you have two options to check:
  1. Check the library. It says: procedure pwm1_set_dutycycle_ratio(word in ratio) 
  2. Compile it. If you pass a byte or word there will be no warning or error. If you pass an sbyte or other you will get a compiler error or warning.

As far as I can see it is linear.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens A Webuser <awebu...@gmail.com>
Verzonden: dinsdag 7 maart 2023 03:27
Aan: jallist <jal...@googlegroups.com>
Onderwerp: [jallist] pwm1_set_dutycycle_ratio() versus pwm1_set_dutycycle_percent()?
 
What input does pwm1_set_dutycycle_ratio() take?  Is it expecting a byte?

Is it linear or is there some unique property to it?


Thanks!

--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallist/21022d65-9a53-4c30-b48a-86771ba9d678n%40googlegroups.com.

A Webuser

unread,
Mar 7, 2023, 9:34:53 PM3/7/23
to jallist
OK, sounds good, but odd since a 16-bit value is far beyond the resolution an 8-bit PIC PWM channel can generate, which is at best 10-bit.  It also depends on frequency, etc, so it is typically lower (8-bit is common)

I guess the function does some "magical" scaling to make FFFF essentially equal a 100% PWM duty-cycle.
Reply all
Reply to author
Forward
0 new messages