Remote Processing RPC-220 User Manual

Page 38

Advertising
background image

PWM AND ANALOG OUTPUT

SECTION 12

PAGE 12-1

INTRODUCTION

P W M A N D A N A L O G O U TP U T

SECT ION 12

The RP C-220 has two program mable PW M outputs.
These outputs are the source for the two analog outputs.
Thus, w hen using an analog output, its corresponding
PW M outpu t may not be used. PWM frequen cy is
progr amm able for a pproxim ately 162 H z to 43Khz. Duty
cycle is variable from 0 to 100% in 256 steps. The
freque ncy is set for both PW M outpu t channels w hile
each chan nel had indep endently pr ogram mable du ty
cycles.

Analog ou tput takes the P WM signal and filter s it.
Output voltage range is programm able from 0 to about
5V in 256 steps. It is effectively an 8 bit D-A.

PROGRAMMING PWM

PWM output signals come directly from the CPU at port
J3. J3-22 is designated as PWM 0 while J3-20 is PWM1.
There is no buffering. Drive levels are TTL compatible.
Lines must be buffe red to directly dr ive opto modules.

Repetition frequency for both outputs is given by:

fpwm = 43369/(1+ PWMP)

Where:

PWM P is the prescaler frequency control
register value at special function register
address 0xfe. Its range is 0 to 255.

The duty cycle (in percent) for both outputs is given by:

Dcy = 100 * (1 - (PWM n/255))

Where:

PWM n is from 0 to 255. PWM 0 is at special
function register address 0xfc and PWM1 is at
0xfd.

100% duty cycle is def ined as alwa ys high while 0 % is
always low.

Quick PWM Program ming E xample
PWM outputs are at J3-22 for PWM 0 and J3-20 for
PWM 1. To pr ogram them, use monitor comma nd ' MS'
to modify the registers. F or example type in the
following command.

MS fc

Address 0xfc is PWM 0 duty cycle register.
The boa rd re sponds with

00FC 00

Type in a 40. This makes channel 0 a mostly high pulse.
E n te r th e da ta sh o wn b el ow . T h is pr o gr a m s P W M
outputs for 4.8 Khz repetition rate pulses. View the
outputs at J3-22 for PWM0 and J3-20 for P WM 1.

00FC 00 40 00FD 00 c0 00FE FF 08 <cr>

Address 0xfd is PWM 1 duty cycle register a nd address
0xfe deter mines both channels r epetition ra te
(frequency).

E x am p le p ro g ra m P W M . C un d er d ir e ct or y P W M
genera tes a ram p at the analog o utputs by continu ously
varying the duty cycle.

ANALOG OUTPUTS

Output voltag e is propor tional to the PW M cha nnel' s
duty cycle. Thus, the output voltage changes in steps of
1/255, or approximately 20 mv/ step. This makes the
analog output act like an 8 bit D-A converter. Accuracy
depends upon the 5V supply. The analog outputs are
proportional to the PWM duty cycle.

Using on card regulators, maximum output voltage can
be 0.25 from the ideal 5.0V. Thus, the output can be as
much as 5% off.

When a nalog output is use d as part of a system w ith
feedback, absolute accu racy is ge nerally no t critical.
This is because the output changes according to demand
requirements. When the output is used as a reference
(i.e. 2. 5V = 1/2 speed) and there is no feedback, then
accura cy can suffe r. In situations wh ere acc uracy is
important, it is better to use a card with accurate analog
output (such as the RPC-210), or adjust the output by
reading the input.

The outpu t may be " adjusted" by bringing the outputs to
one of the A-D's on board. (The A-D uses a fixed
reference so accuracy is higher. ) Simply read the analog
output and adjust the duty cycle as necessary to bring the
voltage to the co rrec t level.

R e sp o ns e Ti m e
Since the analog outputs are der ived from digital pulses,
there ar e a couple of th ings you have to take into
account. Fir st, there is some ripple on the output. T he
amount of ripple depends upon the PWM frequency.
Generally, the higher the frequency, the better. The
CPU PWM P register should be program med for 0x10 or
less. Lower PW M frequencies increase ripple.

Advertising