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 View Cart


ANALOG TO DIGITAL SOURCE CODE
EXAMPLES IN
VISUAL BASIC AND C#
.NET OR ASP


CONTROL SOFTWARE
(for use with the ADC-4, ADC-16 and the EX-16, EX-32 Relay Expansion Cards)


The following codes will send direct adc control commands to the ADC-16, allowing the ADC-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 ADC-16 is removed. The relay codes are in sequence up to code 255 (relay #1 codes = 32 and 33, relay #2 codes = 34 and 35, relay #3 codes = 36 and 37, etc.)

SIMPLE PROGRAMMING EXAMPLE IN VISUAL BASIC

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

Use this code to set your com port:

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

Use this code to send the ADC-16 data request command:

XOut = Chr(0)              'set variable to channel 1 code
SerialPort1.Write(XOut)    'send

                           'To Receive:
XIn = SerialPort1.ReadByte 'XIn is analog data


SIMPLE PROGRAMMING EXAMPLE IN C#

Use this code to set your com port:

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


Use this code to send the ADC-16 data request command:

channelByte[0] = 0;                   //channel 1 code
serialPort1.Write(relayByte,0,1);     //transmit

                                      //to receive:
InByte[i] = serialPort1.ReadByte();   //InByte[i] is analog array


The following two formulas are used to control the ADC-16 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 ADC-16. Programming examples are provided on CD in Microsoft Visual Basic (both VB6 and .Net), Microsoft ASP.NET, Microsoft Visual C#, Turbo C, GW Basic, QuickBasic, Assembly and others. Desktop relay control software is also provided.

Event Notification for your Smartphone


Last revision 3-29-2017....URL: http://www.eeci.com
For information, please contact our web master at....webmanager@eeci.com

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