Page 1 of 1

PWM SETUP

Posted: 03 Nov 2017, 08:52
by luka
I am following the video tutorial for pwm (https://www.youtube.com/watch?v=N6WhKmtAbpE), but I am having trouble understanding the part where instructor uses calculator to convert 11(bin) to 3(dec). I believe it has to do with activating output address.

Could you please explain a little more?

Thanks

Luka

Re: PWM SETUP

Posted: 03 Nov 2017, 09:23
by volker
Hi luka,
sorry for not having this explained in English. But it is easy, so you will get the point in a second:
the configuration word "OutputPWMActive" has 16 bit. Each bit decides whether the output works a s a"normal", plain output which is set by the according output bit or if the output works in "PWM mode" and the %-value is set by the according pwm output byte.
If the according bit of the "OutputPWMActive" word is set to a "1" then this output works in PWM mode.
If the according bit of the "OutputPWMActive" word is set to a "0" then this output works in normal mode.
Bits of a word normally are named by their binary value. So the first bit is called "bit 0" and the last one "bit 15".
Bit 0 would set the mode for output O1 while Bit 15 would set the mode for output O16.
In the video tutorial Dirk is setting O1 and O2 to PWM mode. So the binary value for "OutputPWMActive" needs to be "11" which is 2^0 + ^2^1 = 1 + 2 = 3 in decimal.
If you are using the newest package for piCtory you can also directly use binary or hex format for entering the values. So you could enter the following value for "OutputPWMActive": "0b0000000000000011" or even more simple "0b11".
Hope this makes sense :-)

Re: PWM SETUP

Posted: 03 Nov 2017, 10:04
by luka
It does :)

thank you.