background image

Support

Please visit the DI-159 product page for support issues and documentation at

http://www.dataq.com/plc-data-acquisition/di-159-plc.html

.

If you cannot find an answer to your question there please fill out a support ticket at

http://www.dataq.com/ticket

.

78

Summary of Contents for DI-159

Page 1: ...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 Instr...

Page 2: ...o 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 Instrumen...

Page 3: ...ortable 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 op...

Page 4: ...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 T...

Page 5: ...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 Resolutio...

Page 6: ...g 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 Enclosur...

Page 7: ...r 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 Instrument...

Page 8: ...r 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 Co...

Page 9: ...age 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 ma...

Page 10: ...eral 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 Sign...

Page 11: ...ion 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...

Page 12: ...atus 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 se...

Page 13: ...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...

Page 14: ...DI 159 PLC Hardware Manual StickOS Read Data Statements Conditional Statements Looping Conditional Statements Subroutines Timers Digital I O Analog Input Frequency Output Other Statements 14...

Page 15: ...es 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 n...

Page 16: ...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 vpri...

Page 17: ...ore 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...

Page 18: ...rence 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 ali...

Page 19: ...t 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 mov...

Page 20: ...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 Pr...

Page 21: ...rl C auto line clear flash cls cont line delete line line s ubname download slave Hz dir edit line help topic list line line s ubname load name memory new profile line line s ubname purge name renumbe...

Page 22: ...e name undo upgrade uptime for more information help modes renumber program lines and save reset the DI 159 PLC run program save code ram to flash mem ory undo code changes since last save upgrade Sti...

Page 23: ...d statements in RAM are seam lessly merged with the previously saved statements in flash memory to give the appearance of a single current program at a slight performance penalty When the newly edited...

Page 24: ...ity To set the line numbering mode use the command numbers on off To display the line numbering mode use the command numbers Note that unnumbered listings are useful to paste back in to the auto comma...

Page 25: ...program by 10 s and save the BASIC program permanently to flash memory use the command renumber To delete all lines from the BASIC program use the command new Examples 10 dim a 20 for a 1 to 10 auto 3...

Page 26: ...DI 159 PLC Hardware Manual StickOS 20 for a 1 to 10 30 print a 40 next end renumber list 10 rem this is a comment 20 dim a 30 for a 1 to 10 40 print a 50 next end new list end _ 26...

Page 27: ...BASIC program from a specific line number use the com mand cont line To set the autorun mode for the saved BASIC program use the command autorun on off This takes effect after the next DI 159 PLC rese...

Page 28: ...DI 159 PLC Hardware Manual StickOS 40 endwhile save run Ctrl C STOP at line 40 print a 5272 cont Ctrl C STOP at line 30 print a 11546 autorun off autorun on _ 28...

Page 29: ...unaffected by all other StickOS commands than these To display the list of currently stored named programs use the command dir To store the current program under the specified name use the command sa...

Page 30: ...nsert one or more conditional breakpoints in the program with the following statement line assert expression When the program execution reaches line expression is evaluated and if it is false i e 0 th...

Page 31: ...llows you to modify the value of variables with an immediate mode statement like let variable expression Note that if an immediate mode statement references a pin variable the live DI 159 PLC pin is e...

Page 32: ...trace mode for the BASIC program use the command trace While trace mode is on the program will display all executed lines and variable modifications while running Examples 10 dim a sum 20 for a 1 to 1...

Page 33: ...o 10000 30 let sum sum a 40 next 50 print sum end run 10 dim a sum STOP at line 10 cont 20 for a 1 to 10000 let a 1 STOP at line 20 Enter 30 let sum sum a let sum 1 STOP at line 30 Enter 40 next let a...

Page 34: ...isplay the StickOS memory usage use the command memory To reset the DI 159 PLC as if it was just powered up use the command reset Note that the reset command inherently breaks the USB or Ethernet conn...

Page 35: ...used save memory 0 ram code bytes used 1 flash code bytes used 19 ram variable bytes used 0 flash parameter bytes used 1 variables used clear memory 0 ram code bytes used 1 flash code bytes used 0 ram...

Page 36: ...executed in immediate mode at the command prompt without a line number just as if the program had encountered the statement at the cur rent point of execution Variable Declarations System Variables Va...

Page 37: ...s specified in a dimension statement integer is assumed if no as is specified a RAM variable is assumed Array RAM variables Array RAM variables can be dimensioned with the following statements dim var...

Page 38: ...one run of a program to another even if power is lost between runs unlike RAM variables which are cleared to 0 at the start of every run Note that since flash memory has a finite life 100 000 writes...

Page 39: ...70 next 80 for b 0 to 3 90 print array b 100 let led led 110 next 120 print potentiometer is potentiometer 130 print volatile is volatile 140 print persistent is persistent 150 let persistent persiste...

Page 40: ...state These variables are all read only analog analog supply millivolts getchar most recent console character keychar most recent keypad character msecs number of milliseconds since boot seconds numb...

Page 41: ...evaluates to an array index between 0 and the length of the array minus one and the second expression is assigned to the specified array element String variables are assigned with the following state...

Page 42: ...taking one argument on the right the logical and bitwise not oper ators are unary All binary operators evaluate from left to right all unary operators evaluate from right to left Note that the operat...

Page 43: ...s will be removed from the expression based on the precedence rules above Examples 10 print 2 3 4 20 print 2 3 4 list 10 print 2 3 4 20 print 2 3 4 end run 14 14 print 3 4 7 print 3 2 1 print 0 1 prin...

Page 44: ...variable start length variable substring string concatenation operator A string may be tested in a conditional statement with a condition of the form if string relation string then while string relati...

Page 45: ...StickOS DI 159 PLC Hardware Manual 40 print a i 1 50 next run hello h e l l o new 10 dim a 10 20 input a 30 if a y then 40 print yes 50 else 60 print no 70 endif run aya yes run aaa no 45...

Page 46: ...string dec hex raw expression If the expression specifies an array its entire array contents are printed If the expression ref erences an input pin variable the corresponding DI 159 PLC input pin is s...

Page 47: ...s can be used to print integer expressions using either a decimal or hex adecimal output radix or printing raw ASCII bytes vprint variable dec hex raw expression Or strings vprint variable string Or v...

Page 48: ...ences an output pin variable the corresponding DI 159 PLC output pin is immediately updated When the input statement is serviced StickOS prints a prompt to the console _ And the user enters integer or...

Page 49: ...bles at runtime use the read statement read variable read variable variable If a read is attempted when no more data exists the program stops with an out of data error A line may be labeled and the cu...

Page 50: ...if and else clauses and their corresponding statements are optional Alternately the string form of this statement is if string relation string then statements elseif string relation string then statem...

Page 51: ...StickOS DI 159 PLC Hardware Manual 4 is even _ 51...

Page 52: ...ements within the loop execute At the end of the loop if the incremented loop variable would still be within the range inclusive of the first and second expression the loop variable is incremented by...

Page 53: ...of the innermost loop Additionally multiple nested loops can be exited prematurely together using the statement break n Which causes program execution to immediately jump to the statements following t...

Page 54: ...rs 0 thru a is sum 110 let a a 1 120 endwhile run sum of integers 0 thru 0 is 0 sum of integers 0 thru 1 is 1 sum of integers 0 thru 2 is 3 sum of integers 0 thru 3 is 6 sum of integers 0 thru 4 is 10...

Page 55: ...lues of the caller s gosub expressions Simple variable caller s gosub expression s how ever are passed to sub param s by reference allowing the sub to modify the caller s variables all other caller s...

Page 56: ...ntegers 0 thru 1 is 1 sum of integers 0 thru 2 is 3 sum of integers 0 thru 3 is 6 sum of integers 0 thru 4 is 10 sum of integers 0 thru 5 is 15 sum of integers 0 thru 6 is 21 sum of integers 0 thru 7...

Page 57: ...s to execute when it is delivered specified with the statement on timer n statement If statement is a gosubsubname then all of the statements in the corresponding sub are executed when the timer inte...

Page 58: ...DI 159 PLC Hardware Manual StickOS 90 sub fast 100 let ticks ticks 1 110 endsub run slow slow slow ticks is 14 _ 58...

Page 59: ...digital output channel Led1 Pb digital input channel for the pushbutton Digital input 0 is configured and the variable i0 is bound to the Di0 pin with the following state ment dim i0 as pin Di0 for d...

Page 60: ...the program Line 10 configures the dtin0 pin for digital output and creates a variable named square whose updates are reflected at that pin Line 20 starts an infinite loop typically DI 159 PLC program...

Page 61: ...run in a program can also be run in immediate mode at the command prompt For example after having run the above program the square variable and dtin0 pin remain configured so you can type print squar...

Page 62: ...le c0 is bound to the Ch0 pin with the following statement dim c0 as pin Ch0 for analog input A pin is configured for analog input and a variable bound to that pin with the following state ment dim va...

Page 63: ...otentiometer as pin an0 for analog input 20 print potentiometer is potentiometer run potentiometer is 2026 _ Note that analog inputs and outputs are represented by integers in units of millivolts mV N...

Page 64: ...l I O or analog input The following BASIC program generates a 1kHz square wave on a frequency output pin dtin0 for 1 second new 10 dim audio as pin dtin0 for frequency output 20 let audio 1000 30 slee...

Page 65: ...ms us Note that the minimum sleep resolution is the clock tick which is 0 25 milliseconds Note also that in general it would be a bad idea to use a sleep statement in the on handler for a timer You c...

Page 66: ...l Software Installation 1 Go to http www dataq com 159 in your web browser 2 Click on the DI 159 PLC Terminal Emulator download link and download the setup exe file The following prerequisites are req...

Page 67: ...text file Save As Ctrl S Opens the Windows Save File dialog box Allows you to save the cur rently loaded program to a text file on your computer Exit Exits the program DI 159 Menu Run F5 Runs the curr...

Page 68: ...ides the Version number of the software and copyright infor mation Icons Load Opens the Windows File Selection dialog box allowing you to load a BASIC program saved as a text file Save Program to Text...

Page 69: ...ow can hold about 1000 rows The Output Display provides 4 program icons View in Excel Enabled after you are streaming data to a csv file Click this button to open Microsoft Excel and view data recorde...

Page 70: ...ll not be identified until the code is saved into memory It is recommended to load example one in Help Sample PLC Code Ex 1 Boilerplate code before creating a program from scratch There are 3 program...

Page 71: ...as pin Do3 for digital output 170 dim push_button as pin Pb for digital input 180 dim led0 as pin Led0 for digital output 190 dim led1 as pin Led1 for digital output 200 rem your program starts here...

Page 72: ...heral Led0 in this case Timer intervals can be configured in seconds s mil liseconds ms or microseconds us and can range from milliseconds to hours Example 3 Flash Both LEDs Object Flash both LEDs at...

Page 73: ...ur timers for 1 sec interval configure second of four timers for 1 4 sec interval execute subroutine flash_led0 when timer0 fires execute subroutine flash_led1 when timer1 fires do nothing while waiti...

Page 74: ...down return from the subroutine Comment Note that the pushbutton and LEDs are low true A 0 written to either LED lights it and the pushbutton transitions from 1 to 0 when pressed Example 6 Create a Sq...

Page 75: ...260 sub readin 270 cr cr 1 280 let o0 cr 1 290 let o1 cr 2 300 let o2 cr 4 310 let o3 cr 8 320 print cr c0 c1 c2 c3 c4 c5 c6 c7 i0 i1 i2 i3 o0 o1 o2 o3 330 led0 o0 340 led1 o1 350 endsub dimension cr...

Page 76: ...DI 159 Block Diagram 76...

Page 77: ...Dimensional Drawing 77...

Page 78: ...59 product page for support issues and documentation at http www dataq com plc data acquisition di 159 plc html If you cannot find an answer to your question there please fill out a support ticket at...

Page 79: ...241 Springside Drive Akron Ohio 44333 Telephone 330 668 1444 Fax 330 666 5434 Submit a support ticket to www dataq com ticket Direct Product Links click on text to jump to page Data Acquisition Data...

Reviews: