TS-RELAY8

From embeddedTS Manuals
TS-Relay8
Ts-relay8.jpg
Product Page
Documentation
Schematic
Relay Datasheet

Overview

The TS-RELAY8 is PC/104 compatible peripheral board that provides eight independent software controlled PC board relays. This daughter board is compatible with any PC/104 main board.

Getting Started

Get the PC104 base address for 8bit access from your SBC page. You will use this as the base and add the other addresses for the registers. For example, on the TS-7800 this is 0xEE00_0000. If you have no jumpers set on the TS-Relay8, then the base address of this board will be 0xEE00_0140.

# This is only needed on the TS-7800
pc104on # part of ts7800.subr in fastboot

# Read the Identifier.  This will return 0x9b
peekpoke 8 0xEE000140 

# Turn off all of the relays
peekpoke 8 0xEE000142 0x00

# Turn on all of the relays
peekpoke 8 0xEE000142 0xFF

TS-Relay8 Programming

The simplest method will be to use system/popen calls in C/C++. If you need lower latency, the next best option would be to mmap the addresses and edit them there. This example below is for the TS-7800, and assumes no jumpers are on the relay. You can adjust for those based off of your SBC's page and from the address selection table.

#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdint.h>

// This is for the TS-7800
#define BASE_ADDRESS 0xEE000000
#define PLD_OFFSET 0x140

typedef enum
{
  RLYON = 0xFF,
  RLYOFF = 0x00,
  RLY1 = 1 << 0, 
  RLY2 = 1 << 1, 
  RLY3 = 1 << 2,
  RLY4 = 1 << 3,
  RLY5 = 1 << 4,
  RLY6 = 1 << 5,
  RLY7 = 1 << 6,
  RLY8 = 1 << 7
} RelayFlags;

void set_relays(volatile int8_t *relays, RelayFlags bits)
{
    *relays = bits;
    usleep(20000);
}

int main(int argc, char **argv)
{
    int mem = open("/dev/mem", O_RDWR|O_SYNC);
    void *base = mmap(0, 
                 getpagesize(), 
                 PROT_READ|PROT_WRITE, 
                 MAP_SHARED, 
                 mem, 
                 BASE_ADDRESS); 
 
    volatile int8_t *relays;
 
    // Controlled at 8bit pc104 io address + PLD location (pin selection) + 2
    relays = (volatile int8_t*)(base + PLD_OFFSET + 2);

    // All relays on
    set_relays(relays, RLYON);
 
    // All relays off
    set_relays(relays, RLYOFF);

    // Enable relays 2, 4 and 7
    set_relays(relays, RLY2 | RLY4 | RLY7);

    // Enable relays 3, 4 and 5
    set_relays(relays, RLY3 | RLY4 | RLY5);

    return 0;
}

The PCH-105D2H relay is normally open, closes in 10ms, and opens in 5ms. A very safe assumption would be that it will switch after 20ms.

IO Address Selection

The address selected below must not collide with other PC104 boards. If you are using others, see their page and make sure their configuration doesn't collide with this board.

JP1 JP2 Address
OFF OFF 0x140
ON OFF 0x150
OFF ON 0x160
ON ON 0x170

Register Map

Address Description Access Notes
Base + 0 Board Identifier Read Only Relay8 is identified by 0x9b
Base + 1 PLD Revision Read Only
Base + 2 Relay Control Read/Write Control relays ON/OFF

Relay-specific addressing

Relay control is implemented in the third PLD register at base address + 2.

Bit Relay
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8

Usage with 3rd party devices

Please note that while efforts are made to follow the PC/104 specification this peripheral is not tested with third party SBCs or connected peripherals. This card is not guaranteed to operate as intended when third party PC104 peripherals or SBCs are connected.