Live Chat
Welcome to the exciting world of Data Acquisition and Control Electronic Energy
Control, Inc.

Serving the Energy Management
and Scientific Fields since 1978

(800) 842-7714



Internet Email cst@eeci.com


Relay Interface Analog to Digital Status Input Support Contact Us EECI Home Page


RELAY CONTROL SOURCE CODE
EXAMPLES IN
VISUAL BASIC AND C#
.NET OR ASP


CONTROL SOFTWARE
(for use with the AR-8, AR-8X, AR-16 Relay Interfaces and the EX-16, EX-32 Relay Expansion Cards)


The following relay codes will send direct relay control commands to the AR-16, allowing the AR-16 to be controlled with any operating system or programming language (including DOS). Relays are energized or de-energized by transmitting a single byte code from the computer RS-232. Even codes de-energize relays. Odd codes energize relays. The relay will latch in the requested state until the discrete relay control code (energize or de-energize) is received or until power to the AR-16 is removed. The relay codes are in sequence up to code 255 (relay #1 codes = 0 and 1, relay #2 codes = 2 and 3, relay #3 codes = 4 and 5, etc.)

SIMPLE PROGRAMMING EXAMPLE IN VISUAL BASIC

Please note that special drivers or DLLs are not used. The following code directly controls the AR-16.

Use this code to set your com port:

SerialPort1.PortName = "COM1"
SerialPort1.BaudRate = 9600
SerialPort1.Open()

Use this code to send the AR-16 relay command:

XOut = Chr(1)              'set variable to relay code
SerialPort1.Write(XOut)    'energize relay 1


SIMPLE PROGRAMMING EXAMPLE IN C#

Use this code to set your com port:

serialPort1.PortName = "Com1";
serialPort1.BaudRate = 9600;
serialPort1.Open();


Use this code to send the AR-16 relay command:

relayByte[0] = 1;                     //relay 1 energize code
serialPort1.Write(relayByte,0,1);     //energize relay 1


The following two formulas are used to control relays up to relay #128.
The command...    SerialPort1.Write(Chr(255))  will energize relay #128.
EXAMPLE: 255 = (128 times 2) - 1. Use these formulas in your software to compute relay code as a function of relay number and status.
RELAY CODE = (RELAY # times 2) - 1 ...to energize relay
RELAY CODE = (RELAY # times 2) - 2 ...to de-energize relay
More detailed information is provided with the documentation supplied with the AR-8, AR-8X or AR-16. Programming examples are provided on CD in Microsoft Visual Basic (both VB6 and .Net), Microsoft ASP.Net, Microsoft Visual C#, C++, Python, Turbo C, GW Basic, QuickBasic, LabView, Assembly and others. Desktop and Network Relay Control software is also provided.

Event Notification for your Smartphone


Electronic Energy Control, Inc.
14960 Maple Ridge Rd
Milford Center OH 43045-9016

TOLL FREE (24 hour order line)
(800) 842-7714

Technical Support (937) 349-6000
International Phone +1.9373496000
Internet Email cst@eeci.com

Copyright ©1996 - 2024 Electronic Energy Control, Inc.
All Rights Reserved
Document End