Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more. Accepting essential orders - here's how.
0

Adafruit_BBIO problems
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Adafruit_BBIO problems

by silver2row on Wed Aug 15, 2018 11:12 pm

Hello and Okay,

I think I made some headway for you. Please see these error codes:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "taco.py", line 7, in <module>
    mcp=MCP23017()
  File "/home/debian/MCP230xx.py", line 153, in __init__
    super(MCP23017, self).__init__(address, **kwargs)
  File "/home/debian/MCP230xx.py", line 50, in __init__
    self.write_iodir()
  File "/home/debian/MCP230xx.py", line 133, in write_iodir
    self._device.writeList(self.IODIR, self.iodir)
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO-1.0.3-py2.7.egg/Adafruit_GPIO/I2C.py", line 129, in writeList
    self._bus.write_i2c_block_data(self._address, register, data)
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_PureIO-0.2.3-py2.7.egg/Adafruit_PureIO/smbus.py", line 294, in write_i2c_block_data
    self._device.write(data)
IOError: [Errno 16] Device or resource busy


I am not completely sure what these all mean for now. I will have to look them up.

Seth

P.S. But, I did find in the MCP230xx.py module that there was a class w/ MCP23017. I will keep trying. Oh and sir, look to the config-pin utility for setting up your PWM pins for P9_14 and P9_16, respectively. So:

Code: Select all | TOGGLE FULL SIZE
sudo config-pin P9.14 pwm


and...

Code: Select all | TOGGLE FULL SIZE
sudo config-pin P9.16 pwm


...

Please remember that every time you boot the board, the config-pin is set back to default. So, you can either set up a .service file or set config-pin each time when testing.

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

Re: Adafruit_BBIO problems

by drewfustini on Thu Aug 16, 2018 1:04 am

It is important to know how the system software on your BeagleBone is configured. In particular, there will be problems with device tree overlays if the version of the u-boot bootloader on the eMMC is too old.

Please paste the output of this command:
Code: Select all | TOGGLE FULL SIZE
sudo /opt/scripts/tools/version.sh

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 1:09 am

Trying that produces...
debian@beaglebone:~$ sudo /opt/scripts/tools/version.sh
sudo: /opt/scripts/tools/version.sh: command not found
debian@beaglebone:~$


Version I'm running....
debian@beaglebone:~$ uname -a
Linux beaglebone 4.1.15-ti-rt-r43 #1 SMP PREEMPT RT Thu Jan 21 20:13:58 UTC 2016 armv7l GNU/Linux
debian@beaglebone:~$

And why do I now have to use the config pin commands as I've never used that before.
Also, the BASH code I'm running is driving the MCP23017 fine without it.
I find all this so confusing.
Last edited by denys on Thu Aug 16, 2018 1:17 am, edited 1 time in total.

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

Re: Adafruit_BBIO problems

by drewfustini on Thu Aug 16, 2018 1:15 am

That is very odd that version.sh is not found.

All current BeagleBoard.org Debian images should have that version.sh script installed. It will output important information including the version of the bootloader installed on the eMMC. This important to know as old versions of the bootloader can causes problems with setting the pin modes (pinmuxing).

Please paste the output of these commands:
Code: Select all | TOGGLE FULL SIZE
ls -la /opt/scripts/tools/
cat /etc/dogtag
cat /etc/issue
cat /boot/uEnv.txt


If you still have trouble, then I would recommend trying the latest Debian image on BeagleBoard.org:

Stretch IoT (without graphical desktop) for BeagleBone and PocketBeagle via microSD card
Debian 9.4 2018-06-17 4GB SD IoT image

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 1:20 am

As far as I know, I went to this one..
bone-debian-9.4-iot-armhf-2018-06-17-4gb.img
But I'll download again from your link :)
Thanks.

It is possible I clicked on the wrong one when burning the SD card!

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

Re: Adafruit_BBIO problems

by drewfustini on Thu Aug 16, 2018 1:26 am

Please paste the output of these commands once you boot with the new image:
Code: Select all | TOGGLE FULL SIZE
ls -la /opt/scripts/tools/
cat /etc/dogtag
cat /etc/issue
cat /boot/uEnv.txt


And run version.sh as it should exist on the image.
Code: Select all | TOGGLE FULL SIZE
sudo /opt/scripts/tools/version.sh

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 1:47 am

One thing I found, with my board swapping, the SD card was not all the way in so it was running on the MMC.
Now it is..

debian@beaglebone:~$ cat /etc/issue
Debian GNU/Linux 9 \n \l

BeagleBoard.org Debian Image 2018-06-17


Reloading the BashTest2 script is running ok.

But I have tried all my code on a couple of boards to no avail since the original smoke episode.
Before that, I had the code running ok on a Beaglebone Black and a Beaglebone Green.

I had a bad few days back then. Killed both boards with power to the wrong pins= :(

Obviously I should not work late when tired!

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

Re: Adafruit_BBIO problems

by drewfustini on Thu Aug 16, 2018 1:58 am

Please paste the output from this command:
Code: Select all | TOGGLE FULL SIZE
sudo /opt/scripts/tools/version.sh


denys wrote:Reloading the BashTest2 script is running ok.

But I have tried all my code on a couple of boards to no avail since the original smoke episode.
Before that, I had the code running ok on a Beaglebone Black and a Beaglebone Green.


I'm uncertain from your response. Is there still an issue?

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 2:15 am

Yes.
I have this code running months ago, but after the "Smoke", was completely unable to make it work again.
Code: Select all | TOGGLE FULL SIZE
# run as unbuffered...
# python ADC_Test
# same as version 5 but much longer loop.
# also added counter reset to eack loop so I can se 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
from mcp23xxx import MCP23017   # mcp23017 is no longer working. Trying others..
mcp=MCP23017()

mcp.set_iodira(0x3f) # 8-13 inputs, 14 & 15 outputs
mcp.set_iodirb(0xff) # 0-7 inputs
mcp.set_gpioa(0x3f)  # 8-13 high, 14 & 15 low
mcp.set_gpiob(0xff)  # 0-7 high
mcp.set_gppua(0x3f)  # pullups 8-13
mcp.set_gppub(0xff)  # pullups 0-7

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

# enable PWM but with motor off.
#optionally, you can set the frequency as well as the polarity from their defaults:
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.set_olata(64)    # FET2 on = reset counter
          time.sleep(.01)
          mcp.set_olata(0)   # both FETs off.
          Expected = 0x3ffe     # expected read back of inputs.


       print('\r'),

       PA = (mcp.get_gpioa())
       PB = (mcp.get_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:
          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.set_olata(128)    # FET1 on = pulse the counter
             time.sleep(.01)
             mcp.set_olata(0)   # both FETs off
             Expected = (((Expected * 2) +1)& 0x3fff)
          time.sleep(.1)
   PWM.stop("P9_14")   # PWM off.
   PWM.stop("P9_16")



I've spent the last few months trying to get it to work again.
As it was, this took me some weeks to write as I'm not much of a programmer. I did not image the SD card with the code running as I'd gone to the internal memory for reasons that escape me now.
I've even tried unsuccessfully, replacing the power management IC on a BBB to see it it would come back.
I have an early BBB with 2GBG internal memory so thought that may be a problem so purchased yet another BBB last month.
I'm thinking about making an adapter for an Arduino to test my board as I just cannot get this fixed.

I've tried here too...
https://forum.allaboutcircuits.com/thre ... ng.148883/

Denys.

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 2:23 am

Is there a full still working example of how to load everything needed to read and write to an MCP23017 via I2C somewhere?
As far as I can determine, all the Adafruit examples no longer work. Or at least, they don't work for me.
I'd settle for a full system ISO with my working code in it ;)
Last edited by denys on Thu Aug 16, 2018 3:38 am, edited 1 time in total.

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

Re: Adafruit_BBIO problems

by drewfustini on Thu Aug 16, 2018 2:40 am

Could you post a photo and/or diagram of your setup?

I would suggest breaking the testing down into to smaller parts (test PWM, test MCP23017, etc).

Have you tried this wiring and code to test the MCP23017?
https://learn.adafruit.com/character-lc ... o-expander

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 3:11 am

This is part of the main circuit.
Attachments
OMCB_cct1.jpg
OMCB_cct1.jpg (415.06 KiB) Viewed 232 times

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 3:13 am

And there is a motor drive too.


I'm not showing the serial or CAN here, plus some other stuff that has no connection to this circuit.
Attachments
OMCB-Motor.jpg
OMCB-Motor.jpg (95.6 KiB) Viewed 232 times

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 3:16 am

The plugged in test unit has a counter on it driven from one FET output and then the counter is decoded to a one off 14 outputs that selects one of the board inputs at a time.
That all works fin.
In fact, the whole lot was working fine.

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 3:28 am

drewfustini wrote:Could you post a photo and/or diagram of your setup?

I would suggest breaking the testing down into to smaller parts (test PWM, test MCP23017, etc).

Have you tried this wiring and code to test the MCP23017?
https://learn.adafruit.com/character-lc ... o-expander


The hardware is fine! The MCP23017 working was never the problem. It is just the code I was using, that worked real well for months, is now broken, and no one seems to know how to fix it.
As mentioned earlier, I can run the MCP23017 via the BASH script.
Code: Select all | TOGGLE FULL SIZE
# init the MCP23017
i2cset -y 2  0x27 0x00 0x3f   # portA 0-5 inputs, 6-7 outputs
i2cset -y 2  0x27 0x00 0x3f   # do it twice.
i2cset -y 2  0x27 0x10 0xff   # portB 0-7 inputs
i2cset -y 2  0x27 0x10 0xff   # do it twice.
i2cset -y 2  0x27 0x0a 0x7f # pulse o/p 1 on to reset the test board counter
sleep .1               # a short delay
i2cset -y 2  0x27 0x0a 0x3f # then off.
sleep .1

# this loop pulses o/p 2 to clock the test board counter
COUNTER=0
while [ $COUNTER -lt 100000 ]; do
i2cset -y 2  0x27 0x0a 0xbf   # o/p 2 on to clock the count
sleep .1               # a short delay
i2cset -y 2  0x27 0x0a 0x3f   # o/p 2 off again
sleep .1
done


But I don't know if I can do all the functions of my test code in BASH.

This script has been hammering away at the board for some hours now quit well.

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

Please be positive and constructive with your questions and comments.