Besides a collection of GPIO pins, the MinnowBoard Max also sports two PWM drivers on its 26-pin DIL header.1

The userspace API

The PWM outputs can be controlled by a standard userspace API in sysfs.2

This assumes that the kernel has been compiled with the relevant modules: I forget the details, but you can grab the config I used3 from GitHub.

On the MinnowBoard Max the two PWM drivers appear as separate chips:

# ls /sys/class/pwm/							
pwmchip0  pwmchip1							
# ls /sys/class/pwm/pwmchip0/						
device  export  npwm  power  pwm0  subsystem  uevent  unexport		
# ls /sys/class/pwm/pwmchip1/						
device  export  npwm  power  subsystem  uevent  unexport		

In the example above, channel 0 of pwmchip0 has been exported for use.

The only oddity I encountered was that the duty_cycle parameter is the active time of the signal (measured in ns), and not the active fraction.

Adafruit Python GPIO library

I hacked support for sysfs-driven PWM into the Adafruit Python GPIO Library.4

You can get the library from GitHub5 but be warned: it’s only a proof of concept and not production quality!

Once installed you can fade LEDs thus:

import Adafruit_GPIO.PWM as PWM						
import time								
									
pwm = PWM.get_platform_pwm()						
									
pin = 0									
									
pwm.start(pin, 50.0, 10000.0)						
									
while True:								
    for x in range(0,2):						
        for f in range(0,100):						
            if x == 0:							
                g = f 							
            else:							
                g = 99 - f						
            pwm.set_duty_cycle(pin, g)					
            time.sleep(0.01)						

Wiring

PWM0 is on pin 22 of the DIL header, so connect an LED (plus series resistor) between there and ground on pin 2.