Dataq DI-159 User manual

The way PC-based instrumentation should be
DI-159
PLC Data Acquisition Device
User's Manual
Manual Revision A
Copyright © 2013 by DATAQ Instruments, Inc. The Information contained herein is the exclusive property
of DATAQ Instruments, Inc., except as otherwise indicated and shall not be reproduced, transmitted, tran-
scribed, stored in a retrieval system, or translated into any human or computer language, in any form or by
any means, electronic, mechanical, magnetic, optical, chemical, manual, or otherwise without expressed
written authorization from the company. The distribution of this material outside the company may occur
only as authorized by the company in writing.
Portions Copyright © 2008-2011; All rights reserved. http://www.cpustick.com.
DATAQ Instruments' hardware and software products are not designed to be used in the diagnosis and treat-
ment of humans, nor are they to be used as critical components in any life-support systems whose failure to
perform can reasonably be expected to cause significant injury to humans.
DATAQ, the DATAQ logo, and WINDAQ are registered trademarks of DATAQ Instruments, Inc. All rights
reserved.
DATAQ Instruments, Inc.
241 Springside Drive
Akron, Ohio 44333 U.S.A.
Telephone: 330-668-1444
Fax: 330-666-5434
Designed and manufactured in the
United States of America

Warranty and Service Policy
Product Warranty
DATAQ Instruments, Inc. warrants that this hardware will be free from defects in materials
and workmanship under normal use and service for a period of 90 days from the date of ship-
ment. DATAQ Instruments' obligations under this warranty shall not arise until the defective
material is shipped freight prepaid to DATAQ Instruments. The only responsibility of DATAQ
Instruments under this warranty is to repair or replace, at its discretion and on a free of charge
basis, the defective material.
This warranty does not extend to products that have been repaired or altered by persons other
than DATAQ Instruments employees, or products that have been subjected to misuse, neglect,
improper installation, or accident.
DATAQ Instruments shall have no liability for incidental or consequential damages of any
kind arising out of the sale, installation, or use of its products.
Service Policy
1. All products returned to DATAQ Instruments for service, regardless of warranty status,
must be on a freight-prepaid basis.
2. DATAQ Instruments will repair or replace any defective product within 5 days of its
receipt.
3. For in-warranty repairs, DATAQ Instruments will return repaired items to the buyer
freight prepaid. Out of warranty repairs will be returned with freight prepaid and added
to the service invoice.

Introduction
This manual contains information designed to familiarize you with the features and functions of
the DI-159 PLC data acquisition starter kit.
The DI-159 PLC provides a USB port interface and can be used under any operating system
that can run a terminal emulator and hook a COM port. A connected terminal emulator pro-
vides direct access to the DI-159 PLC’s embedded BASIC programming environment and,
depending upon the emulator, the ability to save and load an unlimited number of programs
beyond the DI-159 PLC’s built-in flash memory limit of three. Emulators that are available
online for free are Terminator and Konsole (Linux), iTerm2 (OS X), and PuTTY and Ter-
aTerm (Windows).
DATAQ has provided a Windows terminal emulator program to use with all DATAQ Instru-
ments PLC devices.
Features
The DI-159 PLC (programmable logic controller) data acquisition instrument is a portable con-
trol module that communicates through your computer's USB port. Power is derived from the
interface port so no external power is required while the instrument remains tethered to a PC.
An optional power supply (part number 101085) powers the instrument in a stand-alone con-
figuration. Features include:
lEmbedded BASIC (StickOS) programming environment for control applications.
l8 fixed differential analog inputs protected to ±150V (transient); ±10V full scale meas-
urement range (output is in millivolts).
l4 digital inputs protected to ±30V; TTL threshold levels.
l4 digital outputs protected to ±30V; 0.5A sink current max.
l1 general-purpose push-button.
l2 general-purpose LEDs.
l1 heartbeat LED for easy indication of system activity.
Analog Inputs
The DI-159 features eight differential analog inputs located on two sixteen-position screw ter-
minal blocks for easy connection and operation (other terminals used for digital I/O). Connect
the DI-159 PLC to any pre-amplified signal in the typical range of ±5 to ±10VFS. Please note:
The DI-159 does not support analog outputs.
3

DI-159 PLC Hardware Manual Introduction
Digital Inputs
The DI-159 contains four digital lines (bits) to access and process external, discrete (on/off)
events. Connect switch closures or discrete levels with a maximum input of 30V and a thresh-
old of 1.8V. The inputs float at 1 level, about 3.3V relative to the "-" terminal, and require sink-
ing about 50uA to bring them down to 0.8V and guarantee a 0.
Digital Outputs
The DI-159 contains four general purpose digital output lines (30 VDC or peak AC, 500 mA
max) to initiate external discrete (on/off) control.
Software
StickOS BASIC is embedded in the device for easy programming and is accessible via any ter-
minal emulator program that can hook a COM port. The DI-159 includes a free Windows-
based terminal emulator software program to communicate with the device (available via down-
load at http://www.dataq.com/159).
StickOS(TM)
The embedded programming environment (StickOS) provides BASIC language applications.
See StickOS in this documentation for more information.
DATAQ PLC Terminal
The DATAQ Instruments PLC Terminal program provides an interface to communicate and
program the DI-159 in a Windows environment (Windows XP and above). See DATAQ
Instruments Terminal Emulator for more information.
Other Drivers and Terminals (Linux)
The DI-159 PLC is compatible with any terminal emulator software that can hook a com port.
In order to program the device a generic driver should be installed first. Linux has two different
generic drivers, which are appropriate for a USB to COM port converter. The first is an
Abstract Control Model driver designed for modem devices, and is simply named acm. The
other one is a generic USB to serial driver named usbserial. DATAQ Instruments does not sup-
port non-Windows drivers or their installation, nor do they support any other terminal emulator
program.
4

Specifications
Analog Inputs
Number of Channels: 8
Channel Configuration: Differential
Voltage Measurement Range: ±10V Full Scale
Input impedance: 2 MΩ, differential
Isolation: none
Overall inaccuracy: ±64mV (at 25°C)
Minimum common mode rejec-
tion: 40db @ 50-60 Hz and @ 25°C
Max input without damage: ±75 V peak continuous; ±150 V peak, one minute or less
Max common mode voltage: ±10V
Analog frequency response: -3db @ 1,000 Hz
Digital Inputs
Number of Channels: 4
Pull-up value: 47 KΩ
Isolation: none
Input high voltage threshold: 1.8 V minimum
Input low voltage threshold: 1.4 V maximum
Absolute maximum values: ±30 VDC
ADC Characteristics
Resolution:
Overall: approx. 1 part in 1,024 (10-bit)
Above zero: approx. 1 part in 511
Below zero: approx. 1 part in 512
Max. sample throughput rate: 10,000 Hz - 11,000 Hz for 11 enabled channels (8 analog,
3 digital)
Min. sample throughput rate: 11.44 Hz (0.000350 Hz with WinDaq software)
Sample rate timing accuracy: 50 ppm
Digital Outputs
Number of Channels: 4
Isolation: none
Absolute max ratings: >Voltage: 30 VDC or peak AC
Sink current: 0.5 A
5

DI-159 PLC Hardware Manual Specifications
Source current: 3 mA
On resistance < 2Ω
Power
Power Consumption: <1.0 Watt, via USB interface
Indicators and Connections
Interface: USB 2.0 (mini-B style connector)
Indicators (LED): Three. Two for general-purpose use, one reserved for activ-
ity indication.
Push button: General-purpose use.
Input Connections: Two 16-position terminal strips
Environmental
Operating Temperature: 0°C to 35°C (32°F to 95°F)
Operating Humidity: 0 to 90% non-condensing
Storage Temperature: -20°C to 45°C (-4°F to 113°F)
Storage Humidity: 0 to 90% non-condensing
Physical Characteristics
Enclosure: Hardened Plastic
Mounting: Desktop; bulkhead
Dimensions: 2.625D × 5.5W × 1.53H in.
(6.67D × 13.97W × 3.89H cm.)
Weight: < 4 oz. (< 140 grams)
Software Support
Embedded: StickOS(TM) BASIC (www.cpustick.com)
Downloadable:
DI-159 PLC Windows-based Utility software for terminal
emulation, program archive, and data logging. Supports
Windows XP and both 32- and 64-bit versions of Win-
dows Vista, Windows 7, and Windows 8.
6

Installation
The following items are included with each DI-159 PLC. Verify that you have the following:
lA DI-159 PLC data acquisition instrument.
lUSB cable.
lA DATAQ Instruments screwdriver for signal lead connections.
If an item is missing or damaged, call DATAQ Instruments at 330-668-1444. We will guide
you through the appropriate steps for replacing missing or damaged items. Save the original
packing material in the unlikely event that your unit must, for any reason, be sent back to
DATAQ Instruments.
Installing Windows Drivers
USB Drivers for the DI-159 PLC can be installed via a downloadable executable directly from
the DATAQ Instruments web site. No CD is shipped with the device. If you are going to
install and run the DATAQ Instruments DI-159 PLC Terminal Emulator program, you do not
need to install the drivers separately - the Terminal installation program will also install the driv-
ers (see DATAQ Instruments Terminal Emulator for installation instructions).
1. Disconnect all DATAQ Instruments USB devices from your Computer.
2. Go to http://www.dataq.com/159 in your web browser.
7

DI-159 PLC Hardware Manual Installation
3. The DI-159 uses the same driver as the DI-145. Click on the Windows DI-145 USB
Driver link.
4. Save the file to your local hard drive.
5. Double-click on the downloaded file (145usbdriver.EXE) to extract the program and
begin software installation.
6. Driver installation is complete.
You can now plug the device(s) into your PC and connect via your chosen terminal program.
Go to DATAQ Terminal Emulator for instructions installing and running the DATAQ Instru-
ments PLC terminal program.
Connecting the Instrument to Your Computer
DI-159 instruments can be connected to your computer’s USB port using the provided USB
cable. No external power is required. Connect one end of the communications cable to the
instrument port and the other to your PC’s port.
Note: Use a powered USB hub or a USB port on your PC. Non-powered USB hubs may
not have sufficient power to run the instrument.
8

Controls, Indicators, and Connections
Please note: The SD card slot is not used in the DI-159. Allowing foreign materials to
enter the device through the SD card slot may result in damage to the instrument.
Mini-B USB Connection
Use the supplied USB cable to connect and power the instrument through your computer’s
USB port.
Connecting Input Signals
All input signal connections are made to the 16-port screw terminals. Each terminal is labeled
directly on the instrument case.
DI-159 Signal Connections
Refer to the following for screw terminal port identification.
9

DI-159 PLC Hardware Manual Controls, Indicators, and Connections
Analog Inputs Ch#: Analog channels 0-7 (±10VFS, ±150V transient max.)
Digital Inputs: General purpose digital inputs (bits 0-3).
Digital Outputs: General purpose digital outputs (bits 0-3).
Connect Analog Input Channel 0
Use the following diagram to connect Analog Input Channel 0.
Connecting Signal Leads
To connect signal leads to the DI-159:
1. Insert the stripped end of a signal lead into the desired terminal directly under the screw.
10

Controls, Indicators, and Connections DI-159 PLC Hardware Manual
2. Tighten the pressure flap by rotating the screw clockwise with a small screwdriver. Make
sure that the pressure flap tightens only against the signal wire and not the wire insulation. Do
not over-tighten.
3. Tug gently on the signal lead to ensure that it is firmly secured.
Digital Inputs
The DI-159 contains 4 general purpose digital inputs. Valid signals are switch closures or dis-
crete levels with a maximum input of 30 V and a threshold of 1.8 V.
Digital Outputs
The DI-159 contains 4 general purpose digital outputs to allow the DI-159 to initiate external
discrete control. Loads up to 30V peak and 500mA are supported.
11

DI-159 PLC Hardware Manual Controls, Indicators, and Connections
LED Indicators
The DI-159 provides three green LEDs for instrument status and notification.
Led0 and Led1: General-purpose LEDs.
Heartbeat: Indicates the device is powered (slow heartbeat at once per second) or when
a program is running (fast heartbeat at about 4 times per second).
Push Button
The DI-159 provides a general-purpose push button whose function is defined by the program
written to the device.
12

StickOS
StickOS is a BASIC programming engine embedded in the DI-159 PLC. It offers transparent
line-by-line compilation, as well as integer variable, string variable, and array support. Block-
structured programming is also supported using easily-recognized IF, FOR, WHILE, DO, and
GOSUB constructs. Use any terminal program that can hook a com port to connect to and pro-
gram the DI-159 PLC.
Quick Reference Guide
Command Line
StickOS Commands
Help Command
Entering Programs
Running Programs
Loading and Storing Programs
Debugging Programs
Other Commands
BASIC Program Statements
Variable Declarations
System Variables
Variable Assignments
Expressions
Strings
Print Statements
Variable Print Statements
Input Statements
13

StickOS DI-159 PLC Hardware Manual
StickOS Quick Reference
Commands |Device Statements |Expressions |Strings |General Statements |Modes |Block
Statements |Variables
Commands
<Ctrl-C> stop running program
auto [line]automatically number program lines
clear [flash]clear ram [and flash] variables
cls clear terminal screen
cont [line]continue program from stop
delete ([line][-[line]]|subname)delete program lines
dir list saved programs
editline edit program line
help [topic]online help
list ([line][-[line]]|subname)list program lines
load name load saved program
memory print memory usage
new erase code ram and flash memories
purge name purge saved program
renumber [line]renumber program lines (and save)
run [line]run program
save [name|library]save code ram to flash memory
undo undo code changes since last save
upgrade upgrade StickOS firmware!
Uptime print time since last reset
Device Statements
timers:
configure timer nfor n(s|ms|us)
on timer ndo statement
off timerndisable timer interrupt
mask timernmask/hold timer
interrupt unmask timer nunmask timer interrupt
watchpoints:
on expression do statement
off expression disable expr watchpoint
mask expression mask/hold expr watchpoint
unmask expression unmask expr watchpoint
15

DI-159 PLC Hardware Manual StickOS
Expressions
the following operators are supported as in C, in order of decreasing precedence:
ndecimal constant
0xn hexadecimal constant
'c’ character constant
variable simple variable
variable[expression] array variable element
variable# length of array or string
( ) grouping
! ~ logical not, bitwise not
*/% multiply, divide, mod
+ - add, subtract
>> << shift right, left
<= < >= > inequalities
== != equal, not equal
|^& bitwise or, xor, and
|| ^^ && logical or, xor, and
Strings
V$ is a null-terminated view into a byte array v[]
string statements:
dim, input, let, print,
vprint
if expression relation
expression then
while expression relation
expression
do until expression rela-
tion expression
string expressions:
"literal"literal string
variable$variable string variable$
[start:length]variable substring
+concatenates strings
string relations:
<= < >= > inequalities
== != equal, not equal
~ !~ contains, does not contain
General Statements
16

StickOS DI-159 PLC Hardware Manual
Line delete program line
line statement // comment enter program line
variable[$]=expression, ... assign variable
?[dec|hex|raw]expression, ...[;] print strings/expressions
assert expression break if expression is false
data n[, ...] read-only data
dim variable[$][[n]] [as ...], ... dimension variables
end end program
halt loop forever
input [dec|hex|raw]variable[$], ... input data
label label read/data label
let variable[$]=expression, ... assign variable
print [dec|hex|raw]expression, ...[;] print strings/expressions
read variable [, ...] read data into variables
rem remark remark
restore [label]restore data pointer
sleep expression (s|ms|us)delay program execution
stop insert breakpoint in code
vprint var[$]=[dec|hex|raw]expr, ... print to variable
Modes
analog [millivolts]set analog voltage scale
autorun [on|off]autorun mode (on reset)
echo [on|off]terminal echo mode
indent [on|off]listing indent mode
numbers [on|off]listing line numbers mode
pins [assign [pinname|none]] set/display pin assignments
prompt [on|off]terminal prompt mode
step [on|off]debugger single-step mode
trace [on|off]debugger trace mode
watchsmart [on|off]low-overhead watchpoint mode
Block Statements
if expression then
[elseif expression then] [else]
endif
for variable = expression to expression [step expression]
[(break|continue) [n]]
next
while expression do
[(break|continue) [n]] endwhile
17

DI-159 PLC Hardware Manual StickOS
do
[(break|continue) [n]]
until expression
gosub subname [expression, ...]
sub subname [param, ...] [return]
endsub
Variables
all variables must be dimensioned
variables dimensioned in a sub are local to that sub
simple variables are passed to sub params by reference
array variable indices start at 0
v is the same as v[0], except for input/print statements
ram variables:
dim var[$][[n]]
dim var[[n]]as (byte|short)
flash parameter variables:
dim varflash[[n]]as flash
pin alias variables:
dim varpin[[n]]as pin pinname for \ (digital|analog|frequency) \ (input|output) \
absolute variables:
dim varabs[[n]]at address addr
dim varabs[[n]]as (byte|short)at addressaddr
system variables (read-only): analog,getchar,keychar,msecs,nodeid,random,sec-
onds,ticks,ticks_per_msec
18

StickOS DI-159 PLC Hardware Manual
Command Lines
In the command and statement specifications that follow, the following nomenclatures are used:
bold literal text; enter exactly as shown
italics parameterized text; enter actual parameter value
(alternate1|alternate2|...)alternated text; enter exactly one alternate value
regular displayed by StickOS
<key>press this key
To avoid confusion with array indices (specified by [...]), optional text will always be called
out explicitly, either by example or by text, rather than nomenclated with the traditional [...].
Command-line editing is enabled via the terminal keys:
key function
← move cursor left
→ move cursor right
↑ recall previous history line
↓ recall next history line
<Home>move cursor to start of line
<End>move cursor to end of line
<Backspace>delete character before cursor
<Delete>delete character at cursor
<Ctrl-C>clear line (also stops running program)
<Enter>enter line to StickOS
If you enter a command or statement in error, StickOS will indicate the position of the error,
such as:
> print i forgot to use quotes
error - ^
> _
19

DI-159 PLC Hardware Manual StickOS
StickOS Commands
StickOS commands are used to control the StickOS BASIC program. Unlike BASIC program
statements, StickOS commands cannot be entered into the StickOS BASIC program with a line
number.
Help Command
Entering Programs
Running Programs
Loading and Storing Programs
Debugging Programs
Other Commands
20
Table of contents
Other Dataq I/O System manuals