First test of the RaspiHats Isolated IO module

 

First tests of the Isolated IO boards from http://raspihats.com/ This is the 6 in/out module featuring 6 relay isolated outputs and 6 opto isolated inputs. 3 Boards are currently being produced. A relay output board, an isolated input board and the mixed board shown here.

I’ve connected it here to a system under test to simulate a PLC interface for verification. The Raspberry PI is pretending to do the PLC handshake with our equipment to verify its all working to specification.

 

 

Taking to the board from the Raspberry PI is exceeding easy, for a start its a HAT module so supports the auto set up that newer PIs support. The only thing you need to do is enable the PIs I2C from the rasp-config tool (see here https://www.raspberrypi.org/documentation/configuration/raspi-config.md)

After I2C is enabled ensure you have the following packages installed via apt-get

sudo apt-get install python-smbus python-pip

then using pip install the raspihats package

sudo pip install raspihats

If you want a video walk through of the setup you can find one below :-

 

And here is my python test script simulating some of the PLC. The pupose of this script is to simulate some exteral hardware they we do not have to test the machine against. The particular handshake is defined by our specifications but it shows how easy a test script can be written and the RaspiHats modules used

from raspihats.i2c_hats import Di6Rly6
from time import sleep
import time

board = Di6Rly6(0x60)

#force reset

board.do_set_state(3,1)
sleep(1)
board.do_set_state(3,0)

board.do_set_state(4,1)
board.do_set_state(5,0)
#board.do_set_state(7,1) # only 6 relays this is forced 0


while (1):
 sleep(1)

print("Waiting for ready signal")
 #wait for ready signal
 while(board.di_get_state(0)==0):
 print("Not ready")
 time.sleep(1)

print("system is ready")
 print(" .. Moving head to load position and requesting vac")

board.do_set_state(0,1) # req vac

#wait for vac on signal
 while(board.di_get_state(2)==0):
 #do nothing
 time.sleep(1)

print("VAC on requesting a cal cycle")

board.do_set_state(2,1) # req cal cycle


 #wait for done signal
 while(board.di_get_state(1)==0):
 #do nothing
 time.sleep(1)

#read passfail

if board.di_get_state(5)==1:
 print("** ITS A PASS **")
 else:
 print("** ITS A FAIL **")


 board.do_set_state(2,0) # clear cal cycle request

print("robot head in position, signal vac off")

#move head and turn on robot vac then say our vac is on by deasserting vac req signal
 board.do_set_state(0,0)

print("waiting for vac off comfirm")

#wait for vac off signal
 while(board.di_get_state(2)==1):
 #do nothing
 time.sleep(1)

print("Cycle complete")

#loop around and wait for ready signal

Leave a Reply