Pro I: Digital-I/O- and Counter Modules
Programming the Module Pro-PWM-4(-I)
ADwin
136
ADwin-Pro
Hardware, manual version 2.9, June 2006
5.8.22 Programming the Module Pro-PWM-4(-I)
Programming the four PWM outputs on the
ADwin-Pro
module PWM-4 is
made by using the PWM commands which are available when the file
<
ADWPDIO.INC
> has been included into the
ADbasic
source code.
The equation shows the formula for calculating the output frequency of the
PWM signal.
Legend for the equation:
ts
low
= duration of the low level
ts
high
= duration of the high level
ts
per
= period duration
presc = prescaler factor
f
out
= output frequency
Instructions for the PWM modules
PWM_SET
PWM_SET
does the settings of the defined module for the prescaler and the
duration of the high- and low-pulses of the PWM output channel.
PWM_SET(
module
,
channel
,
prescale
,
low
,
high
)
Parameters
Description
The values of the parameters
low
und
high
represent the number of
cycles after the prescaler, which have to be achieved by the counter to
change the logic level.
The prescaler is clocked with a frequency of 5MHz.
f
out
5MHz
presc
----------------
⎝
⎠
⎛
⎞
1
ts
per
-----------
⎝
⎠
⎛
⎞
5MHz
presc
----------------
⎝
⎠
⎛
⎞
1
ts
low
ts
+
high
--------------------------------
⎝
⎠
⎛
⎞
⋅
=
⋅
=
LONG FLOAT VAR CONST
module
defined module address
9
-
9
9
channel
PWM output channel (1...4)
9
-
9
9
prescale
pre-scaler value 0…7, corresponds to a
division by 2
0
… 2
7
9
-
9
9
low
number of cycles for the low-time, after the
prescaler.
9
-
9
9
high
number of cycles for the high-time, after
the prescaler
9
-
9
9