Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWM out and RES_16BIT problem #66

Open
lucalenardi opened this issue Apr 11, 2015 · 2 comments
Open

PWM out and RES_16BIT problem #66

lucalenardi opened this issue Apr 11, 2015 · 2 comments
Assignees
Labels

Comments

@lucalenardi
Copy link

Hello and thanks for the hard work.

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

  • Issuing a pwmWrite(PWM1A, 255) works as expected and the LED lights up to full brightness (allowed by the voltage divider);
  • Issuing a pwmWrite(PWM1A, 65536, RES_16BIT) doesn't work, it doesn't log any error and the LED stays turned off. Changing values doesn't make any difference.

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

@alexanderhiam alexanderhiam self-assigned this Apr 17, 2015
@n-epifanov
Copy link

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants