Page 1 of 1

Pi Droid Alpha - Debugging DIO Issue

PostPosted: Tue Aug 25, 2015 4:02 pm
by alanmcdonley
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)

Re: Pi Droid Alpha - Debugging DIO Issue

PostPosted: Tue Aug 25, 2015 5:10 pm
by mikronauts
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.

Re: Pi Droid Alpha - Debugging DIO Issue

PostPosted: Fri Aug 28, 2015 4:27 am
by alanmcdonley
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?

Help Please - Debugging DIO Issue

PostPosted: Sat Aug 29, 2015 4:33 pm
by alanmcdonley
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.

Debugging DIO - Too many open files?

PostPosted: Sat Aug 29, 2015 5:03 pm
by alanmcdonley
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

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

PostPosted: Sat Aug 29, 2015 8:30 pm
by alanmcdonley
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

Re: Pi Droid Alpha - Debugging DIO Issue

PostPosted: Mon Aug 31, 2015 7:10 pm
by mikronauts
Will do, my lab should be back in operation tomorrow as I have internet back, and the new UPS is charged :)

Re: Pi Droid Alpha - Debugging DIO Issue

PostPosted: Wed Sep 02, 2015 3:51 pm
by alanmcdonley
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.

Re: Pi Droid Alpha - Debugging DIO Issue

PostPosted: Thu Sep 03, 2015 8:12 am
by mikronauts
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.

Re: Pi Droid Alpha - Debugging DIO Issue

PostPosted: Thu Sep 03, 2015 2:44 pm
by alanmcdonley
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