Demand Peripherals     Robotics and Automation Made Easy

PWMIN4: Quad Pulse Width Modulation Input

The PWMIN4 peripheral lets you measure the duty cycle of four inputs. Outputs include the duty cycle as a decimal fraction as well as an output that gives the relative timing of the pulses.



The quad PWM input peripheral measures the widths of periodic pulses on each of the four pins on a Baseboard connector. Pulse widths are measured with 16 bits of accuracy for both the high and low periods of a pulse. The clock source driving the pulse width counters ranges from 5 Hertz to 20 Megahertz.

The PWMIN4 peripheral uses direct input from FPGA pins. That is, the peripheral works best with either of the GPIO cards. More information about the GPIO cards is available here cards/gpio4.html and here cards/gpio4-st.html.



PWMIN4 has resources to set the sample clock rate, and to report the pulse low and high times.

clock_rate : frequency of the PWM sample counters.
A clock frequency of zero turns off the peripheral. The frequency is given in Hertz and must be one of the following:


counts : duty cycles of the four inputs.
Dutycycle is a read-only resource that gives the number of clock cycles for the low and high times of each input. A zero indicates that a timeout occurred before the completion of the cycle for that input. Dutycycle works with dpcat.

The peripheral captures three transitions for each of the four input lines. Only three transitions on a pin are needed to determine the low and high clock counts (and the thus the frequency and duty cycle) for that input. Input from a pin is ignored once all three transitions on it have been recorded. This input masking prevents a fast changing input from overflowing the sample buffer.

The format of the output on the counts resource is:




Many radio controlled airplanes use four servos as actuators. Configure the PWMIN4 peripheral to monitor and output the pulse widths from a four channel RC receiver.

The cycle time on an RC receiver is usually 20 milliseconds. A clock rate of 1 MHz gives maximum cycle time of 65 milliseconds. (5 MHz is too fast, giving a maximum cycle time of just over 13 milliseconds.) Since the on time for an RC control pulse is between one and two milliseconds, a time resolution of 1 microsecond corresponds to about 10 bits of precision.

Configure the clock and start the stream of duty cycle readings

    dpset pwmin4 clock_rate 1000000
    dpcat pwmin4 counts


FPGA Defined Peripherals
User Interface
FPGA Configuration
FPGA Buttons & LEDs
Host Tx/Rx Interface
AVR Interface
Stereo Audio Amplifier
Text LCD and Keypad
Quad WS2812 Interface
Quad Slide Pot
IR Recv/Xmit
6 Digit LCD
RC Decoder
Keyfob RF Decoder
Rotary Encoder Interface
Quad Touch Interface
Motion Control
Dual DC Motor Controller
Dual Quadrature Decoder
Quad 13 Bit Servo
Bipolar Stepper Controller
Unipolar Stepper Controller
Simple Input / Output
Quad Binary Output
Quad Binary Input
Octal Input/Output
32 Channel Binary Output
32 Channel Binary Input
Quad Serial Output
Octal Serial Output
Octal 12-bit ADC
Quad Ping))) Interface
Pololu QTR Interface
Octal SRF04 Interface
Generic I2C
Generic SPI
Octal 8-Bit DAC
Quad Digital Potentiometer
Quad PWM Output
Quad PWM Input
Quad Event Counter
Real Time Clock
Dual Pulse Generator

Interface Cards
Control Cards
User Interface
Stereo Audio Amplifier
IR Recv/xmit
Six Digit LCD Display
Keyfob RF Receiver
Rotary Encoder
Quad Switch Card
Text LCD / keypad
Quad Slide Pot
Quad Touch Interface
Motion Control
Dual 7-amp H-bridge
Quad Open Drain Driver
Quad 10 Amp Relay Card
Input / Output
Octal 8-Bit DAC
Quad Digital Potentiometer
Octal 12-bit ADC
Octal SRF04
I2C Prototyping
SPI Prototyping
USB 2.0 Hub
Real Time Clock
Octal Input/Output
32 Channel Input
32 Channel Output
Power Distribution Card
15 Amp Power Distribution
5 Volt Switching Regulator
ATX Power Break-Out Card
Disk Drive Power Break-Out
MP43 Aluminum Mounting Plate
WW4 Large Prototyping Card
WW2 Prototyping Card
WW1 Small Prototyping Card
SMP SMD Prototyping Card