Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

IO PI

The IO Pi Plus is a 32 channel MCP23017 GPIO expander for the Raspberry Pi

18/12/2015

Posted by:
amer.rubyie

amer.rubyie Avatar

Hi,
I have project that required 48 output(relays), I am using 2 IO PI. the project idea is fetch data from lists and send them to pins, the problem is: after few cycles system halt with this error.
I am using raspberry pi 2
Hope I can find help and thank you in advance
(
ABE_IoPi.py", line 199, in write_pin

self._bus.write_byte_data(self.address, self.GPIOB, self.portbval)
IOError: [Errno 5] Input/output error

)
I made clean installation for rasbrain jessi. swap code between python2 and python3 and same error occure after few cycles
the code I am using is :
from ABE_helpers import ABEHelpersfrom ABE_IoPi import IoPiimport timeimport re
import ndata # place where I put lists of data
mDelay = 0.01
i2c_helper = ABEHelpers() # I use single instanse and 3 instanse and problem remain i2c_bus = i2c_helper.get_smbus()i2c_bus1 = i2c_helper.get_smbus()i2c_bus2 = i2c_helper.get_smbus()
#based on jumpers selection
bus = IoPi(i2c_bus, 0x20)bus1= IoPi(i2c_bus1, 0x21)bus2= IoPi(i2c_bus2, 0x23)
def setup_ports_dir(): bus.set_port_direction(0, 0x00) bus.set_port_direction(1, 0x00) bus1.set_port_direction(0, 0x00) bus1.set_port_direction(1, 0x00) bus2.set_port_direction(0, 0x00) bus2.set_port_direction(1, 0x00)
def rest_ports(): bus.write_port(0, 0xff) bus.write_port(1, 0xff) bus1.write_port(0, 0xff) bus1.write_port(1, 0xff) bus2.write_port(0, 0xff) bus2.write_port(1, 0xff)
def send_2_relays(row):
bus.write_pin(1, int(row[0])) # till row[47]

#main
setup_ports_dir()rest_ports()time.sleep(5)
while True:
for row in ndata.mlist: send_2_relays(row) time.sleep(mDelay)

18/12/2015

Posted by:
andrew

andrew Avatar

Hi

I see in your comments that you have tried a single instance and 3 instances of the i2c_helper but have you tried using a single instance of i2c_bus? Having three instances of the i2c bus could be causing the problem if one instance hasn't closed properly before the next one is accessed. You should be able to initialise all three IoPi instances with a single i2c_bus object.

bus = IoPi(i2c_bus, 0x20)
bus1= IoPi(i2c_bus, 0x21)
bus2= IoPi(i2c_bus, 0x23)

18/12/2015

Posted by:
amer.rubyie

amer.rubyie Avatar

Hi, Thank you for replay, I will make test tomorrow and replay, thank you again for your comment.

Sign in to post your reply


Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.

Home

Shop

Learn

Forum

FAQ

Contact

0 item

Your cart is empty

Please browse our shop to order from the wide range of Raspberry Pi boards and accessories.

Subtotal:£0.00
View Basket Continue to Checkout