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 Thu Aug 16, 2018 7:18 am

Hello denys,

Seth here. I see you have help now. You might want to listen to this fellow over me. My bootloader is updated to 03/2018.

Seth

P.S. Oh and I saw you had kernel 4.1.x. You may want to get kernel 4.14.x instead.

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

Re: Adafruit_BBIO problems

by silver2row on Thu Aug 16, 2018 7:34 am

Hello Again,

One thing I saw is that, from https://learn.adafruit.com/character-lc ... o-expander, you need to make your pin configurations known in the software.

Seth

P.S. I will let you know if I come across any solutions to your issue.

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 8:43 am

I'm off to bed now. In fact, I got up for a while, so it is off to bed again ;)
Both BeagleBone Black boards are running with one of my OMCB boards now using that BASH script. So I have 2 to compare.
Good night.

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 8:45 pm

I've been playing around a bit more with bash and have my 2 FET outputs pulsing away.
There does look to be a way to run bash commands from Python using "subprocess.call" so I'm planning trying to grow them into my original Python code and just do away with the broken Python libraries altogether.
At least, for the MCP23017 chip as it is running well.
the analog and PWM are another matter I think.

This is the latest bash script that pulses one FET every 31 times through the loop to reset the external counter hardware.
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 2  $mcp $iodira 0x3f   # portA 0-5 inputs, 6-7 outputs
    i2cset -y 2  $mcp $iodira 0x3f   # do it twice.
    i2cset -y 2  $mcp $iodirb 0xff   # portB 0-7 inputs
    i2cset -y 2  $mcp $iodirb 0xff   # do it twice.

    i2cset -y 2  $mcp $gpioa 0x3f  # 8-13 high, 14 & 15 low
        i2cset -y 2  $mcp $gppua 0x3f  # pullups 8-13
        i2cset -y 2  $mcp $gppub 0xff  # pullups 0-7


        i2cset -y 2  $mcp $olata 0      # both FETs off
        i2cset -y 2  $mcp $olata 64     # FET2 on = reset counter
        sleep .1
        i2cset -y 2  $mcp $olata 0      # both FETs off

error_count=0
    COUNTER=0
    COUNTER2=0
    while [ $COUNTER -lt 100000 ]; do
       ((COUNTER2  +=1))
     if [[ $COUNTER2 = 31 ]] ;
        then # echo wink $COUNTER  # wink the reset?
           i2cset -y 2  $mcp $olata 64    # FET2 on = reset counter
           sleep .01
           i2cset -y 2  $mcp $olata 0  # both FETs off.
           sleep .01
         (( COUNTER2 = 0))
           Expected=0x3ffe     # expected read back of inputs.
    else
         #echo notwinking
           i2cset -y 2  $mcp $olata 128    # FET1 on = pulse counter
           sleep .01
           i2cset -y 2  $mcp $olata 0  # both FETs off.
           sleep .01
    fi
((COUNTER++))
    done




This is a great learning curve for me but there is some progress.
Still, it will be interesting to see if I can get it to work.

I still do not understand the original Python library problem, why now so many hoops need to be jumped through, and cannot find code examples that work. That is strange as the bash code has no problems at all.
Denys.

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

Re: Adafruit_BBIO problems

by silver2row on Thu Aug 16, 2018 8:52 pm

Hello denys,

Seth here. That is good news. If you need any additional ideas, let me know. I know some stuff but not everything. You get the picture.

Seth

P.S. Thank you for allowing me to try to help you.

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 8:58 pm

Thanks for your help Seth. It was greatly appreciated.
It is fun to be able to assist. I do a bit of that re electronic hardware, on https://forum.allaboutcircuits.com as there are a lot of novice electronic enthusiasts there.

If I manage to get my code running, I'll post it back here for you to look at.
Denys.

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

Re: Adafruit_BBIO problems

by silver2row on Thu Aug 16, 2018 9:18 pm

Okay,

Cool deal. Um, I think the only thing that needs to happen is to set a class and some functions in that MCP230xx module. I am sure it can be done but if we are done here, it is okay by me. More work for free sometimes gets old.

Seth

P.S. Oh and sir, I tried to listen to more info. about your software and the MCP23017 chip. I have fairly gotten through a bunch of it and I am understanding more about that chip during each read. Thank you for stating that you needed support. See you later and I cannot wait to see your finished example.

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

Re: Adafruit_BBIO problems

by denys on Thu Aug 16, 2018 10:02 pm

So far, working using bash calls :)

Thew read back is sus as yet.

Code: Select all | TOGGLE FULL SIZE
# run as unbuffered...
# python -u OMCB_IO_11.py
# 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
# patch bash calls into it.

import subprocess
import time

   # init the MCP23017

mcp = 0x27

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

error_count=0

subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x00", "0x3f"])   # portA 0-5 inputs, 6-7 outputs
subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x00", "0x3f"])   # do it twice.
subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x10", "0xff"])   # portB 0-7 inputs
subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x10", "0xff"])   # do it twice.

subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x09", "0x3f"])  # 8-13 high, 14 & 15 low
subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x06", "0x3f"])  # pullups 8-13
subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x16", "0xff"])  # pullups 0-7


subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x0a", "0"])      # both FETs off
subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x0a", "64"])     # FET2 on = reset counter
subprocess.call([  "sleep", ".1"])
subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x0a", "0" ])     # both FETs off



error_count ==0
for j in range(1000000):  # a loop sounter
       if (j&31) == 0:       # wink the reset?
        subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x0a", "64"])     # FET2 on = reset counter
        subprocess.call([  "sleep", ".1"])
        subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x0a", "0" ])     # both FETs off
        Expected = 0x3ffe     # expected read back of inputs.


        print('\r'),

        PA = (subprocess.call(["i2cget",  "-y", "2",  "0x27", "0x0a",]))      # read portA
        PB = (subprocess.call(["i2cget",  "-y", "2",  "0x27", "0x1a",]))      # read portB
        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
       else:
          error_count = error_count + 1
          print
          print("Expected="),
          print'{:14b}'.format (Expected),
          print("  Read="),
          print'{:14b}'.format (PX),
          print(" Errors="),
          print error_count

          if (j&1) == 1:         # inc input sounter every 2 loops
           subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x0a", "128"])     # FET1 on = reset co$
           subprocess.call([  "sleep", ".1"])
           subprocess.call([  "i2cset",  "-y", "2",  "0x27", "0x0a", "0" ])     # both FETs off
           Expected = (((Expected * 2) +1)& 0x3fff)
           subprocess.call([  "sleep", ".1"])




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

Re: Adafruit_BBIO problems

by drewfustini on Fri Aug 17, 2018 1:08 am

I don't think I have yet seen the version of bootloader installed on your eMMC.

Please paste the output from 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 Fri Aug 17, 2018 1:16 am

Hi again.
As far as I know, I'm running from the SD card now.
But here is the result...



debian@beaglebone:~$ sudo /opt/scripts/tools/version.sh

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for debian:
git:/opt/scripts/:[31292bce1d4b35b497cc7a013d6d57e7e1f4f5c4]
eeprom:[A335BNLT0A5A1513BBBK3706]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2018-06-17]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[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/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep pinctrl-single
[ 1.066750] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[ 1.073445] gpio-of-helper ocp:cape-universal: ready
END
debian@beaglebone:~$

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

Re: Adafruit_BBIO problems

by drewfustini on Fri Aug 17, 2018 1:39 am

Thanks. This is what I was looking and it looks ok:
Code: Select all | TOGGLE FULL SIZE
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.03-00002-gac9cce7c6a]:[location: dd MBR]


l can try wiring up the MCP23017 to my BeagleBone and trying the same software. It will help me troubleshoot if I can reproduce the issue you are having.

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

Re: Adafruit_BBIO problems

by denys on Fri Aug 17, 2018 1:49 am

Thanks.
I have a little bit of hair left after all the pulling i tout in frustration ;)

It is a battle.
At the moment, the Bash stuff is giving me headaches too.
I can write to the MCP23017 fine, for example,
subprocess.call([ "i2cset", "-y", "2", "0x27", "0x0a", "64"]) # FET2 on = reset counter

But reading it is strange.
This is Bash is ok....
debian@beaglebone:~$ i2cget -y 2 0x27 0x19
0x7d <------ changes as I switch the inputs.

But I can't figure out how to do it in Python.
PB = (subprocess.call(["i2cget", "-y", "2", "0x27", "0x19"])) # read portB
The above does not change PB. It stays as 0.
I'm sure that is something simple.
Spent about 7 hours on it today so far.

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

Re: Adafruit_BBIO problems

by drewfustini on Fri Aug 17, 2018 1:22 pm

I'll try to recreate your setup once I have access to the parts, but that may not be until Monday.

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

Re: Adafruit_BBIO problems

by denys on Fri Aug 17, 2018 8:33 pm

Thanks drewfustini.
I should give it a rest anyway as it kept me awake last night after spending the day trying to get it working.
I just need to set PWM, read ADC, and read and write I2C to the MCP23017 as before.
I'm interested to find what I'm missing now.
A weekend off is a good idea. I may go and play with my grandchildren :)
Denys.

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

Re: Adafruit_BBIO problems

by silver2row on Mon Aug 20, 2018 9:38 pm

denys,

Seth here for the final time. Here:

Code: Select all | TOGGLE FULL SIZE
https://github.com/tdack/Adafruit-Raspberry-Pi-Python-Code/tree/abd95a03492e678ac3d0e49357f38bc395beb418/Adafruit_MCP230xx


and...

Code: Select all | TOGGLE FULL SIZE
https://github.com/tdack/Adafruit-Raspberry-Pi-Python-Code


Seth

P.S. Enjoy!

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

Please be positive and constructive with your questions and comments.