About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Search
Register or Sign In
Forum

Controlling relay board // Relay switchs off while turning other pin off

656 Views - Created 29/10/2018

29/10/2018

Posted by:
rriveral

Users Avatar

I have the IO pi, I am writing the commands on the board an triggering relays, 5 V ones, the pi is connected directly to the board no additional power supply ... 

 

The issue is, that if I turn a relay on, output pin 1 for example, then if I send a command to turn on relay number two at output pin 2, then the relay at pin 1 shuts off, not sending the command, I believe this might be related to the pull-down resistors of the bus? but the pi already has? so probably adding external PS? thoughts? 

 

Thank you! 

30/10/2018

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hi

When you write to the IO Pi to update a pin are you using the writepin() or writeport() function?  writepin() should update one pin without affecting the others but with writeport() it updates all pins on the port so writing to pin 2 without also setting pin 1 would make pin 1 turn off.  To set pins 1 and 2 to an on state you would need to write 0x03 or 0b00000011 in binary. 

If you are using writepin then there could be a bug in the software in which case if you could let me know which programming language you are using I will check to make sure it is working correctly.

AB Electronics UK Tech Support

30/10/2018

Posted by:
rriveral

Users Avatar

I am using the code that is available for python 

 


def main():
    """
    Main program function
    """

bus = IOPi(0x21)   

bus.set_port_direction(0, 0x00)

bus.write_pin(pin,1) "I parse here the pin that I want to write to"

 

I dont know if the port direction shall be set everytime that I trigger the  outputs? or is stored somewhere? 
 

 

30/10/2018

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

The port direction will be stored within the IO Pi until the power is reset so you should only need to set the direction the first time you use the board after powering on your Raspberry Pi.

I have just tested the python library by writing to the pins individually and it is not resetting the previously set pins so I don't think there is a bug with the software library.

Are you powering the relays directly from the IO Pi outputs or through a relay driver like a mosfet or darlington transistor?  Each output pin can supply a maximum of 25mA and an overall limit of 125mA per chip so one possible reason for it not working is you are drawing too much current from the pins which could cause the IO chip to reset.  Also, make sure your relays have reverse protection diodes across the coil inputs otherwise you could get a voltage spike on the input when the relay turns on or off which would also cause problems with the IO chip.

AB Electronics UK Tech Support

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.