Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Use for PWM on /dev/bone/pwm/
- from pathlib import Path
- from sysfs_pwm import Pwm # see https://pastebin.com/R70P1wAn
- from time import sleep
- pwm1b = Pwm('/dev/bone/pwm/1/b/', frequency=50, value=0)
- GPIO = Path('/sys/class/gpio/gpio48/direction')
- GPIO.write_text('out')
- GPIO = Path('/sys/class/gpio/gpio48/value')
- GPIO.write_text('0')
- GPIO1 = Path('/sys/class/gpio/gpio26/direction')
- GPIO1.write_text('out')
- GPIO1 = Path('/sys/class/gpio/gpio26/value')
- GPIO1.write_text('0')
- # https://pastebin.com/R70P1wAn
- # initialize and enable pwm, automatically disable when scope is left
- #with Pwm('/dev/bone/pwm/1/b', frequency=20000, value=0) as pwm:
- # while True:
- # pwm.value = float(input("Enter PWM value (between 0.0 and 1.0): "))
- try:
- while True:
- port = int(input("Please type 0 or 1 : "))
- if port == 0:
- GPIO.write_text('1')
- pwm1b.frequency=50
- pwm1b.value=0.2
- sleep(1)
- elif port == 1:
- GPIO.write_text('1')
- pwm1b.frequency=50
- pwm1b.value=0.3
- sleep(1)
- except KeyboardInterrupt:
- GPIO.write_text("0")
- GPIO1.write_text("0")
- pwm1b.enabled = False
- print("Kosher Salt!")
- and...The file in question, i.e. (TB6600_PWM.py)
- debian@BeagleBone:~/Ball_Screw/Third$ ./TB6600_PWM.py
- Please type 0 or 1 : 1
- Please type 0 or 1 : 0
- Traceback (most recent call last):
- File "/home/debian/Ball_Screw/Third/./TB6600_PWM.py", line 33, in <module>
- pwm1b.frequency=50
- File "/home/debian/Ball_Screw/Third/sysfs_pwm.py", line 144, in frequency
- raise RuntimeError("Cannot set frequency when PWM value is non-zero (i.e. duty_cycle is non-zero)")
- RuntimeError: Cannot set frequency when PWM value is non-zero (i.e. duty_cycle is non-zero)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement