0

PWM Example on BBB with Ubuntu 16.04
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Thu Feb 16, 2017 8:40 am

Thank you . Good to know that the two distros share similar kernels..
I think you are on track with the pinmux-
I think I'm looking at and example of someone having to change the pinmux of
the Ubuntu 16.04 overlay in order to enamble PWM...
I'll try what you asked here.

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Thu Feb 16, 2017 3:21 pm

Results after build, reboot, and application of cape-universaln
https://gist.github.com/dmemphis/131330e22633e3577b2e929595e4d9d3

I'm not getting too far but I guess I'm learning a lot.

FWIW: This tutorial did work for me.
https://mcututorials.wordpress.com/2017 ... vice-tree/
Not sure if will still work as written now that I've rebuilt the device tree overlay sources....
Last edited by dmemphis on Thu Feb 16, 2017 3:23 pm, edited 1 time in total.

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Thu Feb 16, 2017 5:09 pm

The last post included the wrong output for the pins.
Please see this.
https://gist.github.com/dmemphis/d7a09cd516b1ca1764704fbf75ab6c9a

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by drewfustini on Thu Feb 16, 2017 11:50 pm

Are you able to now call PWM.start() successfully?
import Adafruit_BBIO.PWM as PWM
PWM.start("P8_13", 95.0, 60)

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Fri Feb 17, 2017 12:10 am

Ah, no I did not try it yet. I thought you were going to review the whether the "pins"
data was now as you expected it to be for the Python I/O lib.
I will try it in the mean time also.
Thanks for hanging in there with me.

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Fri Feb 17, 2017 12:24 am

Same as before: I get no errors on the commands, but no activity on the pin.
I suspect that you need a 0x06 on the mode and I think it is still 0x27.

Here is the block from the universaln file
/* P8_13 (ZCZ ball T10) */
P8_13_default_pin: pinmux_P8_13_default_pin {
pinctrl-single,pins = <0x024 0x27>; }; /* Mode 7, Pull-Dow$
P8_13_gpio_pin: pinmux_P8_13_gpio_pin {
pinctrl-single,pins = <0x024 0x2F>; }; /* Mode 7, RxActive$
P8_13_gpio_pu_pin: pinmux_P8_13_gpio_pu_pin {
pinctrl-single,pins = <0x024 0x37>; }; /* Mode 7, Pull-Up,$
P8_13_gpio_pd_pin: pinmux_P8_13_gpio_pd_pin {
pinctrl-single,pins = <0x024 0x27>; }; /* Mode 7, Pull-Dow$
P8_13_pwm_pin: pinmux_P8_13_pwm_pin {
pinctrl-single,pins = <0x024 0x24>; };

And if #13 is the corresponding entry in the "pins" list, it says its 0x27.

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by drewfustini on Fri Feb 17, 2017 4:47 pm

dmemphis wrote:Same as before: I get no errors on the commands, but no activity on the pin.
I suspect that you need a 0x06 on the mode and I think it is still 0x27.

Do you mean that this line in cape-universaln-00A0.dts should be different?
P8_13_pwm_pin: pinmux_P8_13_pwm_pin {
pinctrl-single,pins = <0x024 0x24>; }; /* Mode 4, Pull-Down, RxActive */

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Fri Feb 17, 2017 5:12 pm

Maybe! I'm asking you. :)
I just thought I was helpful providing the overlay section that *I think* is pertinent.

Seems to me a 0x06 pin mode should be there based on my experience with the
example that I sent a link to prior, which wanted to see a 0x6 pin mode of P9_18.

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by drewfustini on Sat Feb 18, 2017 3:32 am

Ah, ok.

I'm going to download and flash ubuntu-16.04.1-console-armhf-2017-01-23.tar.xz so that I can replicate what you are seeing.

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Sat Feb 18, 2017 12:33 pm

Ah good idea! It won't take too long. Thanks very much!

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Sat Feb 18, 2017 2:22 pm

I did the opposite,
I went back to the latest Debian distro from beagleboard on the eMMC. I see the cape-universaln is installed by default. And I see
that the pins list looks the same as on my Ubuntu experiments after setting cape-universaln.
Under these procedures, PWM works:
https://learn.adafruit.com/setting-up-i ... k?view=all
Which is a relief, to know that I'm not completely inept.

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Sat Feb 18, 2017 4:42 pm

My aim is to get 4 PWMs going. My first attempt to start a seconde
PWM I got this:

>>> PWM.set_duty_cycle("P9_14", 50)
>>> PWM.set_frequency("P9_14", 1000)
>>> PWM.set_duty_cycle("P9_14", 70)
>>> PWM.start("P9_16", 50)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: Problem with a sysfs file
>>>

When I tried it again, that problem seemed to go away.
Explanation?

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by drewfustini on Sun Feb 19, 2017 1:28 am

Please try running the same code with the strace:

sudo apt-get install strace
sudo strace -o trace.txt python


The trace.txt should hopefully contain what file i/o occurred before that error.

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Sun Feb 19, 2017 2:34 am

Ok thanks. I've gone on past that point, the error has not come up again,
but will remember to apply that technique to diagnose further.
Otherwise, things are going much better now.

I might have seen an issue with switching between two PWM's, but I'll investigate further.

Let me know how you make out with Ubuntu!

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Re: PWM Example on BBB with Ubuntu 16.04

by dmemphis on Tue Feb 21, 2017 10:11 am

How's your progress with Ubuntu?

dmemphis
 
Posts: 24
Joined: Wed Feb 15, 2017 11:51 am

Please be positive and constructive with your questions and comments.