TS-RELAY8
Product Page | |
Documentation | |
---|---|
Schematic |
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
{
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;
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);
*relays = 0x00; // All relays off
usleep(20000); // 20ms pause
*relays = RLY1;
usleep(20000); // 20ms pause
*relays = RLY1 | RLY2;
usleep(20000); // 20ms pause
*relays = RLY1 | RLY2 | RLY3;
usleep(20000); // 20ms pause
*relays = RLY1 | RLY2 | RLY3 | RLY4;
usleep(20000); // 20ms pause
*relays = RLY1 | RLY2 | RLY3 | RLY4 | RLY5;
usleep(20000); // 20ms pause
*relays = RLY1 | RLY2 | RLY3 | RLY4 | RLY5 | RLY6;
usleep(20000); // 20ms pause
*relays = RLY1 | RLY2 | RLY3 | RLY4 | RLY5 | RLY6 | RLY7;
usleep(20000); // 20ms pause
*relays = RLY1 | RLY2 | RLY3 | RLY4 | RLY5 | RLY6 | RLY7 | RLY8;
usleep(20000); // 20ms pause
*relays = 0xFF; // All relays on
usleep(20000); // 20ms pause
return 0;
}
You can find the datasheet for the relays here.
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 | 140 |
ON | OFF | 150 |
OFF | ON | 160 |
ON | ON | 170 |
PLD 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 |