0

Adafruit_BBIO problems
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Adafruit_BBIO problems

by denys on Tue Sep 11, 2018 8:11 pm

Good morning (here at least).
it is interesting that this BBB .. (192.168.10.117)
root@beaglebone:~# uname -a
Linux beaglebone 3.8.13 #1 SMP Wed Sep 4 09:09:32 CEST 2013 armv7l GNU/Linux
root@beaglebone:~#

has the MCP23017 on I2C bus 1.....

root@beaglebone:~# i2cdetect -r -y 2
Error: Could not open file `/dev/i2c-2' or `/dev/i2c/2': No such file or directory
root@beaglebone:~# i2cdetect -r -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@beaglebone:~#

While the other .... (192.168.10.119)
debian@beaglebone:~$ uname -a
Linux beaglebone 4.14.49-ti-r54 #1 SMP PREEMPT Fri Jun 15 22:14:13 UTC 2018 armv7l GNU/Linux
debian@beaglebone:~$

has he MCP23017 on I2C bus 2.....

debian@beaglebone:~$ i2cdetect -r -y 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory
debian@beaglebone:~$ i2cdetect -r -y 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
debian@beaglebone:~$


That was a source of confusion for a while.

I am running this bash script to test each pin. (with the bus number changed to suit the board).
Code: Select all | TOGGLE FULL SIZE
    # init the MCP23017
    mcp=0x27

    iodira=0x00
    iodirb=0x10
    gpioa=0x09
    gpiob=0x19
    gppua=0x06
    gppub=0x16
    olata=0x0a
    olatb=0x1a

    i2cset -y 1  $mcp $iodira 0x00   # portA 0-7 outputs
    i2cset -y 1  $mcp $iodira 0x00   # do it twice.
    i2cset -y 1  $mcp $iodirb 0x00   # portB 0-7 outputs
    i2cset -y 1  $mcp $iodirb 0x00   # do it twice.
    i2cset -y 1  $mcp $olata  0x3f    # port A "off"
    i2cset -y 1  $mcp $olatb  0xff    # port B "off"
     

    COUNTER=0
    while [ $COUNTER -lt 100000 ]; do
    i2cset -y 1  $mcp $olatb  0x7f    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xff    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xbf    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xff    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xdf    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xff    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xef    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xff    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xf7    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xff    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xfb    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xff    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xfd    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xff    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xfe    # port B
    sleep .1
    i2cset -y 1  $mcp $olatb  0xff    # port B
    sleep .1
   
    i2cset -y 1  $mcp $olata  0xbf    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x7f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x2f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x1f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x37    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3b    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3d    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3f    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3e    # port A
    sleep .1
    i2cset -y 1  $mcp $olata  0x3f    # port A
    sleep .1
   
     ((COUNTER++))
    done




I don't know if I will get back to it today.

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Re: Adafruit_BBIO problems

by silver2row on Tue Sep 11, 2018 10:50 pm

Hello Again denys,

Seth here. I cannot believe that the board looks like that now. What you showed me first off was not that well manicured. Nice job!

Seth

P.S. Your old distro should not be working anymore b/c people have moved on. I know this concept is depressing since things used to work well on your side. There are many ways to get things to work. I would not get so discouraged yet. I had a difficult time w/ a L298 motor driver and at times, that darn motor controller still gets me pissed off. EE! Anyway, this P.S. is taking too long. See you guys soon. Geaux BBB!

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: Adafruit_BBIO problems

by denys on Wed Sep 12, 2018 6:46 pm

silver2row wrote:P.S. Your old distro should not be working anymore b/c people have moved on.


Hi Seth.
Yes, but the problem is the new distros are not working either.
As people have moved on, they forgot to bring the library fixes with them ;)

Thanks for the good words on the board. I'm pretty pleased with it. The little surface mount 8 pin H bridge is a beauty.
I've managed to squeeze quite a bit onto the board. In places it is about as tight as I can make it, and still hand solder it with an iron. Going with solder paste and an oven were not successful for me. In fact, I tried reflowing a video board from a Mac and the oven malfunctioned. SMOKE! The board was not so much reflowed as incinerated.
Denys.

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Re: Adafruit_BBIO problems

by drewfustini on Thu Sep 13, 2018 3:48 pm

Denys:
to show what system software is on a BeagleBone, then "cat /etc/dogtag" and "cat /etc/debian_version" are also very useful to show. It will show information about the version of the Debian image. "uname" only shows the Linux kernel version.

Please do NOT use the older Linux 3.8.x kernel that is on your BeagleBone with IP address 192.168.10.117.

Please use the BeagleBone (192.168.10.119) with the 2018 Debian image on it. This the system where uname showed Linux 4.14.49-ti-r54 kernel.

Please paste the Python code that you are attempting to run.

Please paste the exact errors messages that occur.

I will attempt to reproduce the errors that you encounter.

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

Re: Adafruit_BBIO problems

by GCarp on Wed Sep 19, 2018 10:26 am

Good afternoon,

I'm working with the I2C backpack from adafruit connected to HD44780 20x4 LCD.
The Adafruit git repositories are fantastic and work perfectly.
You guys saved me a lot of time.

The reason I'm replying is to clarify 1 problem.
I had a problem with the libraries,
IOError: [Errno 16] Device or resource busy
.

I read all this issue post but nothing worked for me until I found that the default BeagleBone Black I2C default bus number was set to 1 but in fact is the number 2, P9_19 and P9_20.

I hope this helps you guys ;)
Attachments
chrome_2018-09-19_15-16-13.png
chrome_2018-09-19_15-16-13.png (47.05 KiB) Viewed 285 times

GCarp
 
Posts: 2
Joined: Tue Sep 18, 2018 12:19 pm

Re: Adafruit_BBIO problems

by drewfustini on Wed Sep 19, 2018 11:55 am

GCarp: Thanks for adding your insights.

There was a change in the past in how the i2c devices are enumerated by the Linux kernel on the BeagleBone. This results in some code needing to be changed from busnum=1 to busnum=2.

As a result of Re: LED Backpack not working on beaglebone black with debian, I added comments about busnum to use on BeagleBone in the Adafruit_Python_LED_Backpack repo.

What instructions and GitHub repos were you using for your project?

I would like to update the instructions and comments to include this advice.

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

Re: Adafruit_BBIO problems

by GCarp on Wed Sep 19, 2018 12:18 pm

Hello,

So I started by reading this document:
https://cdn-learn.adafruit.com/download ... -black.pdf

And then I was jumping between README.md files and issues on adafruit forum.

I follow all the instruction in the README.md files from the following repositories:
- https://github.com/adafruit/Adafruit_Python_GPIO
- https://github.com/adafruit/adafruit-be ... -io-python
- https://github.com/adafruit/Adafruit_Python_CharLCD

Also, install the Adafruit_Python_PureIO as you recommended.

Some of the files were already in the BBB and were not install.

At the very end, I was following your bits of advice on this issue.

My BBB has the following configuration:
Linux beaglebone 4.14.49-ti-r54 #1 SMP PREEMPT Fri Jun 15 22:14:13 UTC 2018 armv7l GNU/Linux

eeprom:[A335BNLT000C1818BBBG2298]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2018-06-17]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2018.03-00002-gac9cce7c6a]:[location: dd MBR]
kernel:[4.14.49-ti-r54]
nodejs:[v6.14.3]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20180611.0-0rcnee0~stretch+20180611]
pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~stretch+20180517]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[roboticscape]:[0.4.4-git20180608.0-0rcnee0~stretch+20180609]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee1~stretch+20180328]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep pinctrl-single
[ 1.075430] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[ 1.082103] gpio-of-helper ocp:cape-universal: ready
END

GCarp
 
Posts: 2
Joined: Tue Sep 18, 2018 12:19 pm

Re: Adafruit_BBIO problems

by drewfustini on Wed Sep 19, 2018 1:52 pm

Thank you for your detailed response.

I will look at updating that documentation with the note about trying different busnum.

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

Re: Adafruit_BBIO problems

by silver2row on Wed Sep 26, 2018 9:40 pm

Hello,

Whatever happened? Are we still using the older/new software to update the chip? If not, I get it. Things get complicated and frustrating, e.g. like there is no end to Hell. Ha!

Seth

P.S. Let me know if anything changes. I may want to look further into this specific chip.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: Adafruit_BBIO problems

by denys on Wed Sep 26, 2018 11:11 pm

Hi All.
I have not had the energy to get back to it. But when I do, I'll let you know.
Nothing done so far actually makes my code work.
I'll try again when get some other stuff finished.

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Re: Adafruit_BBIO problems

by denys on Sat Sep 29, 2018 12:22 am

Hi again.
My son has spent a short time getting it going, then a number of hours trying to figure out the PWM.
He has added a flag to enable or disable the PWM section so the rest can be tested.
test_pwm = False

What do I need to do to get the PWM working???


Code: Select all | TOGGLE FULL SIZE
# run as unbuffered...
# python -u OMCB_IO_9A_works.py
# same as version 5 but much longer loop.
# also added counter reset to each loop so I can see the FET switching.
# try to read input and compare it to expected result.
# add error counter

import Adafruit_BBIO.ADC as ADC
ADC.setup()
import Adafruit_BBIO.PWM as PWM
import time
import smbus
import Adafruit_GPIO.I2C as I2C

i2c_bus_number = 2
mcp_address = 0x27

mcp = I2C.Device(mcp_address, i2c_bus_number)

iodira = 0x00
iodirb = 0x10
gpioa = 0x09
gpiob = 0x19
gppua = 0x06
gppub = 0x16
olata = 0x0a

mcp.write8(iodira,0x3f) # 8-13 inputs, 14 & 15 outputs
mcp.write8(iodirb,0xff) # 0-7 inputs
mcp.write8(gpioa,0x3f)  # 8-13 high, 14 & 15 low
mcp.write8(gpiob,0xff)  # 0-7 high
mcp.write8(gppua,0x3f)  # pullups 8-13
mcp.write8(gppub,0xff)  # pullups 0-7

mcp.write8(olata,0)      # both FETs off
mcp.write8(olata,64)    # FET2 on = reset counter
time.sleep(.01)
mcp.write8(olata,0)      # both FETs off

test_pwm = False

# enable PWM but with motor off.
#optionally, you can set the frequency as well as the polarity from their defaults:
if test_pwm:
    PWM.start("P9_14", 0, 2000, 1)
    PWM.start("P9_16", 0, 2000, 1)

error_count = 0
for j in range(1000000):  # a loop sounter
       if (j&31) == 0:       # wink the reset?
          mcp.write8(olata,64)    # FET2 on = reset counter
          time.sleep(.01)
          mcp.write8(olata,0)    # both FETs off.
          Expected = 0x3ffe     # expected read back of inputs.


       print('\r'),

       PA = (mcp.readU8(gpioa))
       PB = (mcp.readU8(gpiob))
       PX = PB + (PA * 256)
       if (PX == Expected):

        print("PortA="),
        print'{:06b}'.format (PA),  # print PortA inputs
        print("  PortB="),
        print'{:08b}'.format (PB),  # printb PortB inputs

        print("  Anl1="),
        print'{:4.2f}'.format (23.8*(ADC.read("AIN0"))),    #print Analog 1 input
        print("  Anl2="),
        print'{:4.2f}'.format (23.8*(ADC.read("AIN1"))),    #print Analog 2 input
        print("  Supply="),
        print'{:2.2f}'.format (35.9*(ADC.read("AIN2"))),    #print Volts
        print("V "),
        print("  Motor_I="),
        print'{:4.2f}'.format (3.125*(ADC.read("AIN3"))), #print AUX cutrrent
       else:
          error_count = error_count + 1
          print
          print("Expected="),
          print'{:14b}'.format (Expected),
          print("  Read="),
          print'{:14b}'.format (PX),
          print(" Errors="),
          print error_count

       # ramp the AUX PWM up and down, switching the o/p FETS as indicators.
       if (j&192) == 0:
          if test_pwm:
             PWM.start("P9_14",((j&63)*1.56),2000,1)  # Motor fwd, ramp up
             PWM.start("P9_16",0,2000,1)
             if (j&192) == 64:        # FET1 on
                PWM.start("P9_14",((63-(j&63))*1.56),2000,1) #Motor fwd, ramp down
                PWM.start("P9_16",0,2000,1)
             if (j&192) == 128:    # FET2 on
                PWM.start("P9_14",0,2000,1)   # Motor rev, ramp up
                PWM.start("P9_16",((j&63)*1.56),2000,1)
             if (j&192) == 192:
                PWM.start("P9_14",0,2000,1)   # Motor rewv, ramp down.
                PWM.start("P9_16",((63-(j&63))*1.56),2000,1)

          if (j&1) == 1:         # inc input sounter every 2 loops
             mcp.write8(olata,128)    # FET1 on = pulse the counter
             time.sleep(.01)
             mcp.write8(olata,0)    # both FETs off
             Expected = (((Expected * 2) +1)& 0x3fff)
          time.sleep(.1)

if test_pwm:
    PWM.stop("P9_14")   # PWM off.
    PWM.stop("P9_16")

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Re: Adafruit_BBIO problems

by silver2row on Sat Sep 29, 2018 1:10 pm

Hello denys,

Seth here. Um, PWM should work out of the box as it is described on their GitHub.com page. Please remember to use your
Code: Select all | TOGGLE FULL SIZE
config-pin
utility to make sure your PWM pins are available.

...

If you restart your board or poweroff and then boot it, you will need to use config-pin again on those specific PWM pins you want to use. If you want to make sure your PWM pins are configured each time you boot your board, please use a .sh script and then create a service to make your board understand it needs to set those pins for usage w/ PWM.

...

in /usr/bin/, create a .sh file.

Code: Select all | TOGGLE FULL SIZE
#!/bin/bash
sudo config-pin P9.14 pwm
sudo config-pin P9-16 pwm


Save that file. Then, go to /etc/systemd/system and create a .service file for starting your .sh script on boot.

...

This should help in testing. So, if you change config-pin utility ideas or forget about them, you can look to your .sh script and .service file.

Sir, do you understand .sh scripts and .service files?

Seth

P.S. I know you are testing now and it can get frustrating. I know! I just went up-the-walls w/ a Sabertooth and BBGW. All I was testing was motors.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: Adafruit_BBIO problems

by denys on Sat Sep 29, 2018 4:45 pm

Hi Seth.
I think that is what he has been fighting.
Here is an error message...

Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ sudo config-pin P9.14 pwm
[sudo] password for debian: #
P9_14 pinmux file not found!# config-pin overlay cape-universal
Pin has no cape: P9_14 overlay

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Re: Adafruit_BBIO problems

by silver2row on Sat Sep 29, 2018 6:02 pm

Hello Sir,

Man...so? config-pin does not work? That is not good. You need to update the kernel and/or image to suit the needs of that particular utility.

I say go to beagleboard.org/latest-images and grab what they have available, e.g. https://debian.beagleboard.org/images/b ... 4gb.img.xz.

That image is updated and represented by the BeagleBoard.org people. Also, if you are using an older image, the config-pin utility will not be available. So say, you are using Wheezy or kernel 4.1.x, none of what is going on will work. I know this is difficult to understand since it once worked well. Although it worked, those overlays are no longer available b/c no one is maintaining them.

...

and...

...

Use this idea if you do not have access to another image for some reason: https://elinux.org/Beagleboard:BeagleBo ... el_Upgrade. If you do not know how to upgrade your kernel, please let me know.

...

Hey, one more thing. Use this command: sudo config-pin P9.19 uart.

Try that for P9.20, too.

Seth

P.S. I repeat, if config-pin is not working, you need to update your image and kernel to the newest, most-recent image. What I mentioned earlier should work too, e.g. that link.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: Adafruit_BBIO problems

by denys on Sat Sep 29, 2018 6:30 pm

Hi again Seth.
I have another BBB and it is running Angstrom. My son got it going with his updated code on the old kernel.
I could not as apt-get did not work, but he showed me the opkg installing.
It does look like my main problem started with updating to the latest kernel.

Still, the other BBB is running the latest kernel, and all is running except the PWM.

EDIT:
The newest kernel BBB now will not restart the code after running until the ssh connection was lost when my mac went to sleep.
This is what comes up now...
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ python -u OMCB_IO_9A_works.py
Traceback (most recent call last):
  File "OMCB_IO_9A_works.py", line 9, in <module>
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are:
  - A cape with a conflicting pin mapping is loaded
  - A device tree object is loaded that uses the same name for a fragment: helper
debian@beaglebone:~$


Whatever has been done in the new kernel sure makes the BBB a lot harder to use!

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Please be positive and constructive with your questions and comments.