graycatlabs / PyBBIO

A Python library for Arduino-style hardware IO support on the Beaglebone
https://github.com/graycatlabs/PyBBIO/wiki
MIT License
251 stars 89 forks source link

PWM out and RES_16BIT problem #66

Open lucalenardi opened 9 years ago

lucalenardi commented 9 years ago

Hello and thanks for the hard work.

I'm testing the PWM output (PWM1A) to regulate an LED brightness:

Tested with both PWM1* and PWM2*. Any clues?

n-epifanov commented 8 years ago

Hi, e.g.

duty_ns = int(value * (period_ns/resolution))

https://github.com/graycatlabs/PyBBIO/blob/master/bbio/platform/beaglebone/pwm.py#L37 looks like is using integer division, in python 2.7 "/" for ints returns int. Is it intentional?

from __future__ import division

would help.

alexanderhiam commented 8 years ago

Interesting, looking through that file (it's been a while since I wrote that) it looks like there are a few divisions that I should reassess. Just importing the new division operator could potentially cause trouble elsewhere since I tend to use the default floor division intentionally.

This module is next on my list to move to a C extension to speed things up, so I'll probably leave it as is for now and get to doing that ASAP.