Hardware


Shell Lab Relay is programmable relay module with USB/serial interface

Characteristic:

● 8 reed relays
● USB powered, 2-meter cable length
● beeper embedded, frequency adjustable
● dual color LED blinks to indicate exceptions
● 3D printed case
● interactive serial console with ASCII command, online manual embedded
● programming language is not limited (Python recommended)
● quick test with Testbench App (with various demo codes)
● pip install mcush library (support windows/linux/mac) and write scripts easily

Use cases:

● auxiliary control in product development/test
● educational experiment design
● outdoor case, auto indicator
● system integration for industrial equipment
● prototype design
● art creativity

Software

Serial Communication FAQ
C Programming FAQ

Serial command:

IO control command
=>gpio --help
usage: gpio [--loop[=loop_delay_ms]] [-p port_bit_name] [--input[=input_mode]] [--output[=output_mode]]
[--set[=set_high_val]] [--clr[=set_low_val]] [--toggle[=toggle_val]] [-n] [-U] [-D] [-O]
options:
 -l/--loop       default 1000ms
 -p/--port       port[.bit] name, eg 0[.0]
 -i/--input      set input mode mask
 -o/--output     set output mode mask
 -s/--set        set output high mask
 -c/--clr        set output low mask
 -t/--toggle     toggle output mask
 -n/--number     query
 -U/--pullup     pullup
 -D/--pulldown   pulldown
 -O/--opendrain  opendrain
=> 

Example:

#0~#7 relay is directly controlled by P0.0~P0.7 pins, has been set as low voltage output mode on startup
enable #2 relay
=>gpio -p0.2 -s
=> 
close #4 relay
=>gpio -p0.4 -c
=> 
toggle #5 relay
=>gpio -p0.5 -t
=> 
query #6 relay state
=>gpio -p0.6
1   (0-disabled, 1-enabled)
=> 
disable 4 relays #0~#3
=>gpio -p0 -c 0xF
=> 
in intactive console, toggle all relays, reverse every 500ms
=>gpio -p0 -c 0xF
=>gpio -p0 -t 0xFF -l 500
(MCU is waiting for user interrupt, send Ctrl-C to stop)
=>(stop and print new prompt) 
beep once
=>beep
=> 
set LED indicator (error number) as 12 (zero after default, green slowly)
=>e 12  (red: 1 fast flash then 2 fast flash)
=> 

Python API:

Install: sudo pip3 install mcush
Upgrade: sudo pip3 install -U mcush
class ShellLab(mcush.Mcush.Mcush):
    def gpio(self, port, i=None, o=None, s=None, c=None, t=None):
        # lower level serial command to control IO

    def pinInput(self, pin):
        # set pins as input mode
    
    def pinRead(self, pin):
        # read pin voltage state

    def pinIsHigh(self, pin):
        # check if pin voltage is high
   
    def pinIsLow(self, pin):
        # check if pin voltage is low
  
    def pinOutput(self, pin):
        # set pins as output mode

    def pinOutputHigh(self, pin):
        # set pins as output mode and set high voltage

    def pinOutputLow(self, pin):
        # set pins as output mode and set low voltage

    def pinClr(self, pin):
        # set pins low voltage

    def pinSet(self, pin):
        # set pins high voltage

    def pinSetVal(self, pin, val):
        # set pins voltage

    def pinToggle(self, pin):
        # toggle pins voltage

Example:

import time
import mcush
from mcush.linkong.ShellLab import ShellLab
s = ShellLab('COM10')  # fill the actual serial port
while True:
    s.pinToggle( '0.0' )  # toggle #0 relay
    time.sleep(2)

Download:

Shell Lab Testbench Application


CH341 VCP Driver(Windows)


Application