6) PWM experiments
I wrote three python scripts to run pwm on mraa pin 62 (P9-16). Remembering
the mraa library is now v1.0 and not 1.5.
period range max <1 sec. min 1us (using _us)
when using .write() to set the duty cycle results in some screwy things
happening and locking up of the pwm chip. I quickly decided it is best to
us .pulsewidth() to directly set the value.
pulsewidth(), pulsewidth_ms() minimum value cannot be less than 1ms
(.001sec) the max cannot be more than the period.
I had the best luck with "_us" range, and did not experience pulse width
related hardware/ software crashes.
I could get the pwm chip to generate signals from 1us period to 1x10^6 us
period, that i could see on my scope.
import mraa
print (mraa.getVersion())
# set up pins to run stepper motor pulse & direction
pin = mraa.Pwm(62)
pindir = mraa.Gpio(59)
#set initial direction of motor, 1st tell pin that it is to send a signal
(dir), then write value (0 or 1)
pindir.dir(mraa.DIR_OUT)
pindir.write(0)
# variable to set frequency and pulse width for testing
period = 100
#enable the pwm pin
pin.enable(True)
# initialize the pin
pin.period_us(period)
#set the pulsewidth to 25% of the period
pin.pulsewidth_us(int(period/4))
#program loop it is not necessary to write to the pin every loop
while period <> 0:
period = input("integer(us)number /0 to quit: ")
pin.pulsewidth_us(0)
pin.period_us(period)
pin.pulsewidth_us(int(period/4))
# a bit of clean up
pin.enable(False)
On Sunday, November 13, 2016 at 4:09:06 PM UTC-6, Chris M wrote:
>
> Some thoughts and findings as I begin to learn the BBG (Beaglebone Green)
>
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/5349e1c3-67e2-4967-a29e-0d3c05f72d46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.