Pi Droid Alpha - Debugging DIO Issue

Moderator: Steve

Pi Droid Alpha - Debugging DIO Issue

Postby alanmcdonley » Tue Aug 25, 2015 4:02 pm

I don't seem to be getting digitalWrite(pin,val) for "pin" 12, 13, 14, or 15 to go high.
I checked all the DIO "signal" pins looking for a high anywhere - no drugs found.

Code: Select all
import PDALib
import time

PDALib.pinMode(6,PDALib.PWM)  # init motor1 speed control pin
PDALib.pinMode(7,PDALib.PWM)  # init motor2 speed control pin

PDALib.pinMode(12,PDALib.OUTPUT)  #init motor1 dirA/Fwd    enable
PDALib.pinMode(13,PDALib.OUTPUT)  #init motor1 dirB/Bkwd  enable
PDALib.pinMode(14,PDALib.OUTPUT)  #init motor2 dirA/Fwd    enable
PDALib.pinMode(15,PDALib.OUTPUT)  #init motor2 dirB/Bkwd  enable

# init all direction pins to off
PDALib.digitalWrite(12,0)  #set to off/coast
PDALib.digitalWrite(13,0)  #set to off/coast
PDALib.digitalWrite(14,0)  #set to off/coast
PDALib.digitalWrite(15,0)  #set to off/coast

# get ready to go forward
PDALib.digitalWrite(12,1)  #set to forward
PDALib.digitalWrite(14,1)  #set to forward

# setting speed will start us going  (zero to fast in one command for this test)
PDALib.analogWrite(6,127)  #set motor1 to half speed
PDALib.analogWrite(7,127)  #set motor2 to half speed


There is power 4.93v to the chip on pin 9.

When I ran the above code, my servos on servo1 (servo header pin 0) and servo2 went berserk so I had to disconnect them.
(When not running PDALib and using pigpio_cgi on GPIO4 and GPIO17 the servos responded very nicely. I didn't try using PDALib to move the servos yet. )

PDALib.py didn't set a BCM|GPIO pin mode - does that matter? (I noticed the servopin[] translation to GPIO mode)
alanmcdonley
 
Posts: 91
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Re: Pi Droid Alpha - Debugging DIO Issue

Postby mikronauts » Tue Aug 25, 2015 5:10 pm

Hi Alan,

You found a couple of bugs! I just tested the issues you reported...

1) in PDALib.py, the definition of pinMode()

pi.INPUT should be pigpio.INPUT
pi.OUTPUT should be pigpio.OUTPUT

2) I have the bytes reversed in my handling of the MCP23017

until I fix that, please use pins 20-23 for the motor directions - this explains why you earlier pointed out that the pin map did not match the schematic.

There is no need for setting the Pi pin numbering mode, as I use the default (BCM) mode. You may need to get the latest pigpio if you are using an older version.

I hooked up a servo to the Servo1 connector, and it did not go crazy like you reported - which is what makes me suspect you may have a different version of pigpio.

I'll fix the byte-order problem and post a new PDALib.py in the next day or two - I want to make sure that I don't introduce other multi-legged critters.
mikronauts
 
Posts: 119
Joined: Tue Sep 16, 2014 6:58 pm

Re: Pi Droid Alpha - Debugging DIO Issue

Postby alanmcdonley » Fri Aug 28, 2015 4:27 am

Do I need the spi_bcm2708 device driver loaded to use PiDA?

Do I need the following (or run raspi-config to enable SPI)?

sudo nano /etc/modules
(add at bottom or uncomment if commented:)
spi-bcm2708

make sure no spi entry in /etc/modprobe.d/raspi-blacklist.conf (mine is 0 bytes)

reboot or load driver with:
sudo modprobe spi-bcm2708

run lsmod to see that spi_bcm2708 is loaded

Any packages I need loaded?
alanmcdonley
 
Posts: 91
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Help Please - Debugging DIO Issue

Postby alanmcdonley » Sat Aug 29, 2015 4:33 pm

I need advice on how to diagnose my DIO A/B not working.

I rang out every pin of the MCP23S17:
no cold solder joints,
no shorts,
power on 18 and 9
Ground on 10
CS,SO,SI,SCLK to connector all proper,
and the MCP3008 works fine so it would seem the SPI signals in and out of the board are OK, and the library is talking SPI ok.

When I run PDALib.dumpDio() I get:
Code: Select all
>>> PDALib.dumpDio()
reg val
--------
 00 0000
 02 0000
 04 0000
 06 0000
 08 0000
 0A 0000
 0C 0000
 0E 0000
 10 0000
 12 0000
 14 0000
 16 0000
 18 0000
 1A 0000
 1C 0000
 1E 0000
>>>



I can't make sense of the MCP23S17 Bank0 Bank1 tables, but I think it says that on reset, I should be seeing some 0xFF in the dumpDio().

I ordered a couple replacement MCP23S17 from DigiKey. Hopefully a new chip will do the trick.
alanmcdonley
 
Posts: 91
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Debugging DIO - Too many open files?

Postby alanmcdonley » Sat Aug 29, 2015 5:03 pm

Code: Select all
import PDALib
import time
import sys
import signal



def signal_handler(signal, frame):
  print '\n** Control-C Detected'
  sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

for pin in range(8,23+1):
  PDALib.pinMode(pin,PDALib.OUTPUT)
print "Pins set as output"

while True:
  for pin in range(8,23+1):
    PDALib.digitalWrite(pin,1)

  print "Pins High"
  time.sleep(5)

  for pin in range(8,23+1):
    PDALib.digitalWrite(pin,0)

  print "Pins Low"
  time.sleep(5)




Code: Select all
Pins High
Pins Low
Pins High
Pins Low
Traceback (most recent call last):
  File "douts.py", line 18, in <module>
  File "/home/pi/PDALib/PDALib.py", line 157, in digitalWrite
  File "/home/pi/PDALib/PDALib.py", line 280, in setDioBit
  File "/home/pi/PDALib/PDALib.py", line 259, in readDio
IOError: [Errno 24] Too many open files
alanmcdonley
 
Posts: 91
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Re: Too many open files - suggested PDALib.py edits

Postby alanmcdonley » Sat Aug 29, 2015 8:30 pm

alanmcdonley wrote:Traceback (most recent call last):
File "douts.py", line 18, in <module>
File "/home/pi/PDALib/PDALib.py", line 157, in digitalWrite
File "/home/pi/PDALib/PDALib.py", line 280, in setDioBit
File "/home/pi/PDALib/PDALib.py", line 259, in readDio
IOError: [Errno 24] Too many open files
[/code]


I wrapped all the SPI read or writes with the appropriate open and spi.close(). I no longer get this error.

I would really appreciate if you would run both the attached dout tests. One uses PDALib.py and the other does not. Neither work on my board. I think both should work to flip the bank A and bank B pins high then low (if my board assembly and MCP23S17 chip are functioning).

Alan
Attachments
PDALib_and_dout_tests.alan.zip
PDALib with my edits, and two digital out tests: one using PDALib and one does not
(4.57 KiB) Downloaded 2556 times
alanmcdonley
 
Posts: 91
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Re: Pi Droid Alpha - Debugging DIO Issue

Postby mikronauts » Mon Aug 31, 2015 7:10 pm

Will do, my lab should be back in operation tomorrow as I have internet back, and the new UPS is charged :)
mikronauts
 
Posts: 119
Joined: Tue Sep 16, 2014 6:58 pm

Re: Pi Droid Alpha - Debugging DIO Issue

Postby alanmcdonley » Wed Sep 02, 2015 3:51 pm

New MCP23S17 just arrived - did the trick. Both douts.py (with PDALib) and douts2.py (without PDALib) work.

This is exciting. Now I can try the motor control test.
alanmcdonley
 
Posts: 91
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Re: Pi Droid Alpha - Debugging DIO Issue

Postby mikronauts » Thu Sep 03, 2015 8:12 am

I am glad you got it working!

Weird about the MCP23S71 being dead, it was fresh from Mouser.

My lab is almost functional now, one workstation perfectly restored, another about half there. The power surges before the outage went right through the surge protector.
mikronauts
 
Posts: 119
Joined: Tue Sep 16, 2014 6:58 pm

Re: Pi Droid Alpha - Debugging DIO Issue

Postby alanmcdonley » Thu Sep 03, 2015 2:44 pm

mikronauts wrote:(0=i2c version, S=SPI version)

Yikes, I must have grabbed the wrong IC.

I can mail you a MCP23S17 if you like, or include an extra next time you order something.


I'm good - no problem.

mikronauts wrote: Weird about the MCP23S71 being dead


Perhaps it was not dead, just the wrong version of the chip? The chip from the kit is marked MCP23017-E/SP; Perhaps it is the I2C version of the chip.

The chip which works is marked MCP23S17-E/SP - note the S between the 23 and 17 signifies the SPI version.

Alan
alanmcdonley
 
Posts: 91
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida


Return to Pi Droid Alpha

Who is online

Users browsing this forum: No registered users and 1 guest

cron