TS-RELAY8: Difference between revisions

From embeddedTS Manuals
Line 32: Line 32:


= TS-Relay8 Programming =
= 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.
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 pins are on the relay.  You can adjust for those based off of your SBC's page and from the IO address table.


<source lang="c">
<source lang="c">
Line 49: Line 49:
                 MAP_SHARED,  
                 MAP_SHARED,  
                 mem,  
                 mem,  
                 0xEE000000);
                 0xEE000000); // This address is for the TS-7800


     volatile int8_t *relays;
     volatile int8_t *relays;

Revision as of 17:04, 20 July 2011

TS-Relay8
Ts-relay8.jpg
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 pins are on the relay. You can adjust for those based off of your SBC's page and from the IO address table.

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

int main(int argc, char **argv)
{
   int mem = open("/dev/mem", O_RDWR|O_SYNC);
   void *base_address = mmap(0, 
                getpagesize(), 
                PROT_READ|PROT_WRITE, 
                MAP_SHARED, 
                mem, 
                0xEE000000); // This address is for the TS-7800

    volatile int8_t *relays;
    relays = (volatile int8_t*)(base_address + 0x142);

    *relays = 0x00; // All relays off
    usleep(20000); // 20ms pause 

    *relays = 0xFF; // All relays on
    usleep(20000); // 20ms pause 
}

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