Demand Peripherals             Robotics and Automation Made Easy

  

PWMOUT4: Quad Pulse Width Modulated Output

PWMOUT gives you four channels of 12 bit PWM output. You can set the PWM counter to one of eight different frequencies. When used with the quad open-drain driver card the PWMOUT4 peripheral can control the speed of four DC motors or the brightness of four strings of LEDs.

 

Hardware:

The PATGEN4 peripheral puts a PWM output on four FPGA pins. Each PWM output can be on from 0 to 4094 counts of the PWM clock. The outputs are not synchronized in any way. That is, one output might, or might not, start at the same time as another output. Typically, the outputs all start at different times but there is no guarantee of this. The PWM total period is always 4096 counts long.

PATGEN4 works with any of the following cards:
     GPIO with pin headers
     GPIO with screw terminals
     Open-Drain Driver Card

 

Resources:

pwm : PWM pulse widths as four 12-bit hex numbers.
The pulse widths are separated by spaces and terminated by a newline. Each of the four pulse widths can vary between 000 and fff.

config : clock rate in Hertz. This is the frequency at which the PWM counter is incremented. Valid frequencies include: 20 MHz, 10 MHz, 2 MHz, 1 MHz, 500 KHz, 200 KHz, 100 KHz, and 0. A clock frequency of zero turns off all PWM outputs. The frequency of the PWM pulses is config frequency divided by 4096. This resouce works with dpset and dpget.

phase : start/stop times for each PWM channel.<
This read-only resource shows the start count and end count for each PWM channel. The output is start/stop followed by a space. A dash is used where there is no start or stop times, i.e. when the duty cycle is either 0 or 100 percent. It is possible for a pulse to wrap from then end of the 4096 cycle to the start. When this happens the stop count will be smaller than the start count. As an example, the output of this resource might appear as:

    100/2ff 0/381 0/- 200/0fc

 

Examples:

Set the MSB to 100 percent, the next lower MSB to 50 percent, and the two LSBs to 0 percent. Set the PWM counter frequency to 10 MHz.

    dpset pwmout4 pwm 3ff 1ff 0 0
    dpset pwmout4 config 10000000