Introduction


This guide contains all the information you will need to run the OSA Electronics 16Ch 12Bit SAR ADC Board HAT.

Summary

  1. What we need
  2. Assembly
  3. Test instructions

What we need


Assembly


Use the nylon screws and standoffs to assembly the Raspberry Pi together with the 16Ch 12Bit SAR ADC Board HAT, as shown on the image below:

 

 

GPIO use


By default, the board will start with OFF state relays. To change to ON state, you will need to control via I2C the main chip (PCF8574). The board requires 5v and 3.3v to operate.

The following image shows you the pinout of the board:

 

 

Test Instructions for Raspberry Pi


First off, make sure the board is fully assembled with your Raspberry Pi, and you have everything needed to continue qith this guide.

You can download Raspberry OS and other distributions from here.

Step 1
Use your desired Linux distribution or install a fresh image of Raspberry OS.

Make sure your distro is up to date, or in any case, run:

sudo apt-get update 
sudo apt-get dist-upgrade

Step 2
If not installed, install SMBus:

sudo apt-get install python-smbus

Step 3
The next step is to create a new Python file:

nano RLB0665N_test_script.py

This file should be blank! Just copy and paste the following text into the file:

# Test program for 6 Ch Relay Board RLB0665N 

# Imports Section 
import smbus 
import time 

# Initial Setup 
RELAY1 = 0xFE 
RELAY2 = 0xFD 
RELAY3 = 0xFB 
RELAY4 = 0xF7 
RELAY5 = 0xEF 
RELAY6 = 0xDF 

bus = smbus.SMBus(1) 

# Set the I2C address 
PCF8574_addr = 0x20 

# Run the program 
try: 
    while True: 
    
        bus.write_byte(PCF8574_addr, 0xFF) # Turn OFF all relays 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY1) # Turn ON Relay 1 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY2) # Turn ON Relay 2 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY3) # Turn ON Relay 3 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY4) # Turn ON Relay 4 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY5) # Turn ON Relay 5 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY6) # Turn ON Relay 6 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, 0x00) # Turn ON all relays 
        time.sleep(0.5) 
        
except KeyboardInterrupt: 				# Trap a CTRL+C keyboard interrupt 
    bus.write_byte(PCF8574_addr, 0xFF)  # Turn OFF all relays

Save the file as usual (Ctrl+O) and exit (Ctr+X).

Step 4
Now, run the script typing:

sudo python RLB0665N_test_script.py

Voilà! Your Relay Board should start to work!

To cancel the script at any time, just press Ctrl+C and it will be stopped.

 

Test Instructions for Rock 4 / Rock 5


First off, make sure the board is fully assembled with your Rock 4 / Rock 5 board, and you have everything needed to continue qith this guide.

You can download Debian OS and other distributions from here (Rock 4) and here (Rock 5).

NOTE*: If you are using SSH, by default Debian has it disabled, in that case type:

sudo systemctl start ssh
sudo systemctl enable ssh

Step 1
Use your desired Linux distribution or install a fresh image of DebianOS.

Make sure your distro is up to date, or in any case, run:

sudo apt-get update 
sudo apt-get dist-upgrade

Step 2
If not installed, install SMBus:

sudo apt-get install python3-smbus

Step 3
If not enabled, enable I2C7 bus on your Rock board:

rsetup

Navigate to: Overlays -> Yes -> Manage Overlays -> Enable I2C7 (press spacebar to mark it). Exit from the setup.

Step 4
The next step is to create a new Python file:

nano RLB0665N_test_script.py

This file should be blank! Just copy and paste the following text into the file:

# Test program for 6 Ch Relay Board RLB0665N 

# Imports Section 
import smbus 
import time 

# Initial Setup 
RELAY1 = 0xFE 
RELAY2 = 0xFD 
RELAY3 = 0xFB 
RELAY4 = 0xF7 
RELAY5 = 0xEF 
RELAY6 = 0xDF 

bus = smbus.SMBus(7) 

# Set the I2C address 
PCF8574_addr = 0x20 

# Run the program 
try: 
    while True: 
    
        bus.write_byte(PCF8574_addr, 0xFF) # Turn OFF all relays 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY1) # Turn ON Relay 1 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY2) # Turn ON Relay 2 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY3) # Turn ON Relay 3 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY4) # Turn ON Relay 4 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY5) # Turn ON Relay 5 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, RELAY6) # Turn ON Relay 6 
        time.sleep(0.5) 
        
        bus.write_byte(PCF8574_addr, 0x00) # Turn ON all relays 
        time.sleep(0.5) 
        
except KeyboardInterrupt: 				# Trap a CTRL+C keyboard interrupt 
    bus.write_byte(PCF8574_addr, 0xFF)  # Turn OFF all relays

Save the file as usual (Ctrl+O) and exit (Ctr+X).

Step 5
Now, run the script typing:

sudo python RLB0665N_test_script.py

Voilà! Your Relay Board should start to work!

To cancel the script at any time, just press Ctrl+C and it will be stopped.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.