Skip to content

Problems with Adafruit_BBIO.PWM (reference issue #169) #185

@thebrianbug

Description

@thebrianbug

I've had severe problems with PWM on my BBB. I've just re-flashed my board with the latest image, then ran apt-get update. My python code gets the same output stated above. Here's the code:

import Adafruit_BBIO.PWM as PWM
 
servo_pin = "P8_13"
duty_min = 3
duty_max = 14.5
duty_span = duty_max - duty_min
 
#PWM.start(servo_pin, 50, 1000, 1)
#PWM.start(servo_pin, 50)
PWM.start(servo_pin, (100-duty_min), 60.0)
 
while True:
    angle = raw_input("Angle (0 to 180 x to exit):")
    if angle == 'x':
        PWM.stop(servo_pin)
        PWM.cleanup()
        break
    angle_f = float(angle)
    duty = 100 - ((angle_f / 180) * duty_span + duty_min) 
    PWM.set_duty_cycle(servo_pin, duty)

The output is

Your code is running at http://localhost.
Important: use os.getenv(PORT, 8080) as the port and os.getenv(IP, 0.0.0.0) as the host in your scripts!

Traceback (most recent call last):
  File "/var/lib/cloud9/senior_design/pwm.py", line 10, in <module>
    PWM.start(servo_pin, (100-duty_min), 60.0)
RuntimeError: Problem with a sysfs file


Process exited with code: 0

I next tried to test PWM using the BoneScript library with the following code. The first time I run the BoneScript version, it does work. However, if I re-run the code with no change or by changing frequency, duty cycle, or port PWM does not output again, and the running PWM stops. It does not work again until I restart the board. UPDATE - It will output again after I run the pin PWM config given above (and pasted below)

var b = require('bonescript');
b.pinMode('P9_14', b.OUTPUT);
b.analogWrite('P9_14', 0.7, 2000.0, printStatus);
function printStatus(x) {
    console.log('x.err = ' + x.err);
}

I've been reading through this thread and to help out here's additional stuff I've run.

debian@beaglebone:/var/lib/cloud9$ for i in `find /sys/devices/platform/ocp/ -type f |grep pinmux |grep state$|sort -n`; do echo $i: `cat $i`; done
/sys/devices/platform/ocp/ocp:P8_07_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_08_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_09_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_10_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_11_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_12_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_13_pinmux/state: pwm
/sys/devices/platform/ocp/ocp:P8_14_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_15_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_16_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_17_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_18_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_19_pinmux/state: default
/sys/devices/platform/ocp/ocp:P8_26_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_11_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_12_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_13_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_14_pinmux/state: gpio
/sys/devices/platform/ocp/ocp:P9_15_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_16_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_17_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_18_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_21_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_22_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_23_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_24_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_26_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_27_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_30_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_41_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_42_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_91_pinmux/state: default
/sys/devices/platform/ocp/ocp:P9_92_pinmux/state: default

Next, I ran the suggested code above. I found that this will restore PWM to the bonescript code, but I still get the same Problem with a sysfs file error from the Python code.

debian@beaglebone:/var/lib/cloud9$ config-pin -q p9.14
P9_14 Mode: gpio Direction: out Value: 0
debian@beaglebone:/var/lib/cloud9$ config-pin p9.14 pwm
debian@beaglebone:/var/lib/cloud9$ config-pin -q p9.14
P9_14 Mode: pwm
debian@beaglebone:/var/lib/cloud9$
debian@beaglebone:/var/lib/cloud9$ config-pin -q p9.16
P9_16 Mode: default Direction: in Value: 0
debian@beaglebone:/var/lib/cloud9$ config-pin p9.16 pwm
debian@beaglebone:/var/lib/cloud9$ config-pin -q p9.16
P9_16 Mode: pwm
debian@beaglebone:/var/lib/cloud9$
debian@beaglebone:/var/lib/cloud9$ config-pin -q p8.19
P8_19 Mode: default Direction: in Value: 0
debian@beaglebone:/var/lib/cloud9$ config-pin p8.19 pwm
debian@beaglebone:/var/lib/cloud9$ config-pin -q p8.19
P8_19 Mode: pwm
debian@beaglebone:/var/lib/cloud9$
debian@beaglebone:/var/lib/cloud9$ config-pin -q p8.13
P8_13 Mode: pwm
debian@beaglebone:/var/lib/cloud9$ config-pin p8.13 pwm
debian@beaglebone:/var/lib/cloud9$ config-pin -q p8.13
P8_13 Mode: pwm

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy