Home

qterm-r55 user`s manual revision 6

image

Contents

1. x User s Panel Figure 3 7 Cutout Dimensions for the QTERM R55 Large Character Panel Mount Terminal The EIA 485 interface uses intelligent electronics to con trol the direction of the interface transmit vs receive The interface is held in receive mode until the user application transmits data The circuit senses the beginning of the transmission and immediately switches to transmit mode until the transmission is ended At that time the interface reverts to receive mode until another transmission is requested All of this is handled by the interface electronics and is completely transparent to the user application This can simplify the task of writing software for the EIA 485 interface because the application does not need to directly control the direction of the interface The QTERM R55 operating system does not specify or enforce any protocol or link layer functions on the EIA 485 interface This must be provided by the user application Most EIA 485 networks use some form of master slave protocol to control network traffic This is accomplished in software by adhering to a few simple rules 1 Slave devices must never initiate a transmis sion unless they are queried by the master The slave then needs to respond within a cer tain time period 2 Master devices may initiate transmissions to slaves but after doing so the master should wait and not transmit again until the slave 21 has responded o
2. Precision Argument E space Value is the variable to be con verted OPTIONAL One or more flags can be used to modify the result of the output as follows Left adjustment of the output in the specified field width Number will be printed with a sign If the first character does not con tain a sign a space will be added Leading zeros will pad the field A decimal point will always be added For g and G formats see below trailing zeros will be removed REQUIRED A number that specifies the minimum width of the field The output will be printed in a field at least this wide wider if necessary The fewer characters than specified Padding on the right will occur if left alignment was used OPTIONAL required if precision is used Separates the Field width from the Precision OPTIONAL Maximum number of characters to be printed after the decimal point for e E and f output For g and G it represents the number of significant digits Floating point ouput Xxx yyy The number of y digits is specified by the Precision 6 is the default precision 0 will suppress the decimal point unless the flag is used Floating point ouput xx yyyye ZZ Or XX yyyyE 2z The number of y digits is specified by the Precision 6 is the default precision 0 will suppress the decimal point Floating point ouput e or SE are used if the exponent is less than 4 or greater than or equ
3. nN L Lett Column of Keys QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 6 Pin Modular Connector 485 RTx 422 Tx 1 ts 485 RTx 422 Tx 232 Tx 2 o 5 422m 422 Rx 232 Rx 3 o 8 s c 9 Power Ground 5 DB9 Female Figure 1 2 QTERM Connector Pin Assignments e Use the POS Up POS Down POS Left and POS Right keys to highlight the menu item for the parame ter which you would like to change Press the POS Enter key to select that item The System menu allows adjustment of the display contrast and keyboard settings When Contrast is selected the word CONTRAST will appear on the screen The desired contrast is increased or decreased by pressing the POS Up or POS Down keys repeat edly Press the POS Enter key to return to the POS menu e Keyboard settings such as Key Click Key Repeat Repeat Delay and Repeat Rate are accessed from the Keypad menu under the System menu The Key Click and Key Repeat are toggled on and off by pressing the POS Enter key when Click or Rpt are selected The Repeat Delay and Repeat Period may be incremented or decremented in 10 ms increments by pressing the POS Up or POS Down after Rpt Dly or Rpt Prd has been selected When the desired value is displayed press the POS Enter key to accept the value e Selecting Back from any menu returns to the previ ously displayed menu The COM Setup menu is used to set the serial
4. a 1 next a print is a reversed If you try this program you will get this output Please enter a word hello olleh is hello reversed In the above program everything from for to next is repeated while the variable a goes from its initial value len a to its final value 1 Note the step clause The number after step here 1 is added to a after every repetition The step clause makes a go down with every iteration If the step clause 3 is omitted step 1 is assumed Within the for next loop above the string functions len and mid are applied see section 2 4 2 7 Data and Arrays Occassionally the need arises to supply a program with ini tial data Example 8 program converts numbers to strings Example 8 restore names read maxnum dim namess maxnum for a 1 to maxnum read names a next a label loop input Please enter a number num num int num if nums 1 and num lt maxnum then print num names num goto loop Ti endif print Sorry can t convert num label names data 9 one two three data four data seven eight nine five ij six The following program Example 9 produces similar out put but is written using totally different language con structs Example 9 label loop input Please enter a number number number int number on number 1 gosub sorry one two three four five sorry goto loop label sorry print Sorry can t conve
5. 9 Keypad Backlight If the QTERM RS55 was purchased with the keypad back light option the keypad backlight may be turned on and off with the keypad commands keyback on keyback off 2 8 10 Speaker The internal speaker beeps in response to either of the fol lowing commands see Example 10 beep bell QTERM R77 User s Manual 2 8 11 Pause Execution The following identical commands delay program execu tion see Example 7 pause lt time gt wait lt time gt lt time gt is the amount of time execution is delayed in sec onds 2 8 12 Defining the Keyboard Input from the keyboard can be done in two ways The first method is to check periodically if there has been a key pressed by using the iskeypressed string function If there has been a key pressed the resulting string from this func tion will be the value of the key that was pressed Other wise the string will be empty Here is an example of how this function can be used inChar iskeypressed if len inChars lt gt 0 then send COM1 inChars endif The other method of getting input from the keypad is to use the inkey string function This function will stop execu tion of the BASIC program until the user of the terminal presses a key on the keypad When he does the value of the key is returned as the result print inkey The keyboard has a default definition for characters that are returned to the input functions This definition contains t
6. Used to combine to conditional statements Returns the ASCII value of the characture that is passed to it Calculates the ArcSine of x Calculates the ArcTangent of x Calculates the ArcTangent of y x Used to control whether the display scrolls when the cursor is on the last line of the display and a linefeed is printed Used to control where the display will place the next character if the cursor is at the end of a line continued QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 28 QTERM R77 User s Manual Table C 1 qaBASIC Command Summary Command Description backlight Turns the backlight on or off beep Beeps for the number of seconds specified by x bell Same as beep chrs x Converts the ASCII value of x to a character clear screen Clears the display close x Used to close file number x that was previously opened COM1 Reserved word refers to the primary serial port COM2 Reserved word refers to the secondary serial port if that option is available continue Used in interrupt processing to deactivate an interrupt handling routine contrast Adjusts the display contrast cos x Calculates the Cosine of x cursor Used to change the appearance or location of the cursor dates Returns the date in a string data Used to define data to be read in using read dim x Sets the array size of x else Used with if code following else will be run if the condition is false end Marks the end of program execut
7. approved by QSI could void the user s authority to operate this device FOREWORD The QSI Corporation QTERM RS5 is a BASIC programmable data entry terminal for industrial applications The QTERM R55 is available with several options this manual discusses all versions and their operation The QTERM RSS is a CE certified product It has been assessed against the requirements of EN 50082 1 1992 EN55022 1987 and EN 60950 including Amendments Numbers 1 2 and 3 Based on conformity with these requirements the QTERM RSS5 is deemed in compliance with all applicable CE directives The sections of this manual are as follows Chapter 1 Basic Operation This chapter helps you to quickly get acquainted with the QTERM RS5S Chapter 2 qaBASIC This chapter explains how to write a program in qaBASIC It contains examples of how to use each of the commands then an explanation of the command Chapter 3 QTERM RS55 Hardware This chapter contains the specifications for the QTERM RS5 terminal Included are dimensional drawings interface specifications connector pin assignments and environmental specifica tions Appendix A ASCII Chart This is a true 7 bit ASCII chart along with mnemonic definitions Appendix B QTERM RS55 Character Chart This is a 256 character chart showing how the QTERM RS5 displays ASCII characters The lower half is similar to but not the same as the true ASCII chart in Appendix A Appendix C qaBASIC Command Summary
8. first use This is necessary because qaBASIC needs to know how much memory has to be allocated for the array The dim keyword is used to declare arrays Example 8 uses dim names maxnum to declare a string array Another example would be dim numbers 200 to cre ate a numerical array with 200 elements numbered 0 to 199 More complex tasks may even require multidimensional arrays with more than one index dim matrix 10 10 defines a two dimensional array Up to 10 dimensional arrays are supported by qaBASIC 2 8 Interaction with System Hardware Example 10 print dates times cursor blink cursor at 2 3 aS 12345 a 4 send COM1 a send COM1 a aS recvS COM1 a recv COM1 print COM1 a a led 3 on led 4 off backlight on bell pause 10 This program produces the following output phrases in parentheses describes actions taken by the QTERM RS55 not output to the display 5 28 08 98 13 51 53 cursor set to blink cursor moves to column 2 row 3 str 12345 sent out COM1 num 4 sent out COM1 COM1 input stored into str a COM1 input stored into num a string in str a and number in numa is sent out COM1 LED 3 is turned on LED 4 is turned off backlight is turned on a speaker beep is made execution stops for 10 seconds 2 8 1 Date and Time NOTE The date and time commands are only sup ported for QTERM RS55 terminals with the optional real time clock installed The date out
9. lt alternative instructions gt endif As shown the parentheses around lt condition gt are optional The else lt alternative instructions gt is also optional Note that endif can be written as fi lt condition gt is described below in Conditions section 2 5 2 lt instructions gt and lt alternative instructions gt can be be any series of BASIC statements If lt condition gt evalu ates to TRUE then lt instructions gt is executed If lt condi tion gt evaluates to FALSE lt alternative instructions gt if included is executed 2 5 2 Conditions Numbers or arithmetic expressions can be compared with the usual relational operators equal lt gt not equal lt less than lt less or equal gt greater than and gt greater or equal Strings can be compared with the same set of operators where characters are ordered according to the ASCII char acter set For example a lt b is true because a precedes b within the ASCII character set Likewise a b is false More than one comparison can be combined with parenthe ses and these keywords or and not not has higher precedence than and which in turn has higher precedence than or in the same way as precedes within arithmetic expressions This means that not a gt b or a c and b gt 0 is the same as not a gt b or a c and b gt 0 Finally the enclosing parentheses can be omitted i e if a lt 10 then is a valid
10. qsicorp com Phone 801 466 8770 26 OTERM R2 User s Manual Most Significant Digit hex t hex igi oe 2 amy igni Least S and are on the previous page QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 APPENDIX C QABASIC COMMAND SUMMARY This appendix is an abbreviated summary of all of the available qaBASIC Commands A more detailed descrip tions of the commands are in Chapter 2 Table C 1 qaBASIC Command Summary Command Description x mM mM Mm MM KOKO a aS x strings acos x and asc string asin x atan x atan y x autoscroll autowrap Conditional comparison not equal Conditional comparison less than or equal to Conditional comparison greater than or equal to Conditional comparison equal to or assignment Conditional comparison less than Conditional comparison greater than Add two numbers Subtract two numbers Multiply two numbers Divide two numbers Take x to the y power See Print Can be used in place of at Allows multiple commands to be placed on one line Placed after a print statement to prevent a carriage return and linefeed from being appended to the end of the printed characters An abbreviated form of REM must be the first character on the line An abbreviated form of REM Calculates the ArcCosine of x
11. section 2 8 12 2 9 Printing and Controlling the Screen 2 9 1 Printing Output Printing output at specific locations is helpful for interac tive programs Example 11 clear screen print at 4 0 1 Setup print at 4 1 2 Save print at 4 2 3 Quit input at 0 3 Your choice a 12 This program produces a screen resembling the following layout 1 Setup 2 Save 3 Quit Your choice The clear screen command erases the screen The at clause in print or input statements allows you to move to any location specified by the two arguments of the at clause on your screen This is illustrated by Exam ple 8 Note that at can be written as also and that the row and column addresses are zero based i e the first row is row 0 etc 2 9 2 Autowrap and Autoscroll autowrap and autoscroll are screen display com mands that allow the qaBASIC program to control how the display responds when printing and reaching the end of a line or the bottom of the screen If the autowrap is on when the cursor reaches the end of the screen then the cursor will be placed at the beginning of the next line unless the line is the bottom line and autoscroll is off in which case the cur sor will be placed at the beginning of the bottom line If autoscroll is on when the cursor reaches the bottom line of the display and receives a newline character it will scroll the screen up leaving the cursor in the same h
12. shift out SI shift in SP space DLE data link escape DC1 device control 1 XON DC2 device control 2 DC3 device control 3 XOFF DC4 device control 4 NAK negative acknowledge SYN synchronization ETB end of text block CAN cancel EM end of medium SUB substitute ESC escape FS file separator GS group separator RS record separator US unit separator DEL delete rubout P Ol om AILT NI AA AIIN I e a N K x lt a lt i cial alwn 5 fo ol yud A pa S a Cham om vA om NM pa MD fa lt P OIZA S s e n oami galw gt e MiMi gJ alw pP oS nana aoa NA BR Wl NRK oO QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 24 QTERM R77 User s Manual QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 APPENDIX B QTERM R55 CHARACTER CHART The chart on the next page shows how the QTERM R55 These bytes are always ignored displays each of the 256 possible character values ce This is a space character Where a dot pattern is shown printing the corresponding code will cause the QTERM RSS to display the dot pattern Note that although the left half of this chart is similar to the at the current cursor location ASCII chart in Appendix A there are differences Numbers in circles refer to these notes QSI Corporation Fax 801 466 8792 Web www
13. this chapter was derived from the documentation that is included with the YABASIC distri bution YABASIC is distributed under the terms of the GNU Public License which allows modification and redis tribution of the software provided that the same license applies to the modified version Source code for the YABASIC modification may be obtained from QSI upon request Contact QSI for details Refer to the LICENSE file included on the distribution disk for more information on the GNU Public License The QTERM RSS also uses uC OS the Real Time Kernel by Jean Labrosse 2 1 Syntax 2 1 1 Case Commands can be entered in any case input is the same as INPUT and even as InPUt This applies to every command in qaBASIC 2 1 1 1 Variables Variable names are case sensitive i e types of variables a and AS are different and can be of any length There are two sorts of variables 2 1 1 2 String Variables String variables always have a dollar sign as the last character of their names e g a b12 or VeryLong Names and may contain strings of any length String vari ables can contain any characters except the NULL character ASCII 0 2 1 1 3 Numerical Variables a c3po or ThisTsAnEvenLongerName are examples of numerical variables and can contain real numbers like 1 3 2 15 3e44 or 0 Variables with the exception of arrays need not be declared their initial values are for string variables and 0 0 for numerical var
14. whenever any communication parameters are changed The port state may be toggled by pressing the button in the Port State box D 4 2 Send to R55 Enter text in this box and press the Transmit button This feature is useful for sending short strings to the QTERM R55 to test application programs D 4 3 Clear Box Pressing this button erases the contents of the Download Results box D 4 4 Preprocessor Settings The R55 Downloader contains a preprocessor for qaBASIC see Preprocessor Directives section D 5 The settings of this preprocessor can be changed with the Preprocessor Set tings button Pressing this button will bring up a dialog box listing the various options Select Preprocess application files before downloading to control whether the preproces sor runs on an application file When the preprocessor runs it parses all of the input files and generates an intermediate file this intermediate file is then downloaded to the QTERM RSS It is often useful to examine the contents of this intermediate file if the terminal reports that an application has errors By default the inter mediate file is R55 tmp qbs and is stored in the directory which contains the application file To change this simply enter a new name in the Save intermediate file as box or browse using the button To automatically delete the intermediate file when the R55 Downloader is closed select Delete intermediate file on exit Note If you use
15. ER 31 Purpose 31 Setup 31 Basic Operation 31 E 3 1 Using the R55 Downloader 31 E 3 2 Selecting the file to download 31 E 3 3 Selecting the serial port 31 E 3 4 Setting the communication parameters 31 E 3 5 Downloading the application 31 OTERM User s Manual QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM User s Manual E 3 6 Cancel 31 E 4 Advanced Features 32 E 4 1 Port State 32 E 4 2 Send to R55 32 E 4 3 Clear Box 32 E 4 4 Preprocessor Settings 32 E 5 Preprocessor Directives 32 E 5 1 Overview 32 E 5 2 Include 32 E 5 3 Define 32 QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM User s Manual QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 CHAPTER 1 BASIC OPERATION There are only four steps required to communicate with the QTERM RSS euse Power On Setup to set the display contrast baud rate and data format e connect to your host transmit receive and ground lines e apply power e download application to the QTERM R55 1 1 Power On Setup The Power On Setup menu is used to configure the QTERM RS55 s display contrast baud rate and data format This feature is also used to download new terminal firm ware and to download the BASIC program file to the termi nal Normally when power is applied to the unit it will perform a few self diagnostics and then check for a missing or bad program file If the
16. OTERM R227 USER S MANUAL REVISION 6 QSI CORPORATION 2212 South West Temple 50 Salt Lake City Utah 84115 2648 USA Phone 801 466 8770 Fax 801 466 8792 Email info qsicorp com Web www qsicorp com MO01 012 00 Rev 6 31725E0 Printed in USA Copyright QSI Corporation 1999 2009 QTERM QTERM RS5 and QABASIC are trademarks of QSI Corporation Manual Updated 15 October 2009 FCC COMPLIANCE STATEMENT This device complies with part 15 of the FCC Rules Operation is subject to the following two conditions 1 This device may not cause harmful interference and 2 this device must accept any interference received including interference that may cause undesired operation This equipment has been tested and found to comply with the limits for a Class A digital device pursuant to part 15 of the FCC Rules These limits are designed to provide reasonable protection against harmful interference when the equipment is operated in a commercial environment This equipment generates uses and can radiate radio frequency energy and if not installed and used in accordance with the instruction manual may cause harmful interference to radio communications Operation of this equipment in a residential area is likely to cause harmful interference in which case the user will be required to correct the interference at his own expense Any modification to this device including any changes to the recommended antenna configuration that are not expressly
17. This is an abbreviated summary of the qaBASIC commands Appendix D Using the R55 Downloader This chapter describes how to use the R55 Downloader program QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R2 User s Manual QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 CHAPTER 1 BASIC OPERATION 1 1 1 1 2 1 3 1 4 5 Power On Setup 1 Connect the Communications Lines 2 Apply Power 3 Running the R55 Downloader 3 CHAPTER 2 QABASIC 5 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 Syntax 5 2 1 1 Case5 2 1 1 1 Variables 5 2 1 1 2 String Variables 5 2 1 1 3 Numerical Variables 5 2 1 1 4 Multiple Commands on One Line 5 Introduction to qaBASIC 5 2 2 1 REM6 2 2 2 Input 6 2 2 3 Print 6 Arithmetic 6 2 3 1 Operations 6 2 3 2 Functions 6 2 3 2 1 Trigonometric Functions 6 2 3 2 2 Exponentiation 6 2 3 2 3 Integer and Fractional Parts 7 2 3 2 4 Remainder 7 2 3 2 5 Minimum and Maximum 7 2 3 2 6 Square Root 7 String Operations 7 2 4 1 Length of a String 7 2 4 2 Extracting Parts of a String 7 2 4 3 Strings to Numbers and Numbers to Strings 7 2 4 4 Finding Strings in Strings 8 2 4 5 Changing the Case of Strings 8 2 4 6 Removing Spaces 8 2 4 7 The ASCII Character Set Functions 9 2 4 8 Escape Sequences 9 Conditions and Flow Control 9 2 5 1 The if Statement 10 2 5 2 Conditions 10 2 5 3 Marking Locations in a Program 10 2 5 4 Jumping Around in a Program 10 2 5 5
18. al to the Precision otherwise use f Trailing zeros and deci mals are not printed QTERM R77 User s Manual More examples are listed in Table 2 0 Further information can be found in any textbook on the C programming language The val function converts its string argument to a num ber see conversion of 23 in the Example 3 Note that e2 is converted to 0 because this string is not a valid number Table 2 0 More Examples Using the str Function Output Print Statements i Produced print str 12 12345 08 3f 0012 123 print print strs 12 12345 8 2f 12 12 print u print strs 12 12345 6 2f 12 12 print 2 4 4 Finding Strings in Strings The instr function returns the position of its second string argument within the first instr returns zero if the string cannot be found instr Hallo al in Example 3 returns 2 because al appears at position 2 within Hallo instr Hallo Al1 returns 0 because Al is not contained in Hallo the case doesn t match 2 4 5 Changing the Case of Strings lower and its counterpart upper convert their string argument to all lower or all upper case characters respectively lowers aBcD12f G shown in Example 3 returns abcd12fg as 2 4 6 Removing Spaces ltrim and rtrim are two functions to remove leading or trailing spaces from a string trim removes both leading and trailing s
19. application file is bad or not present the terminal will enter a download mode If the program is present and uncorrupted it is compiled and exe cuted An existing program file may be replaced with another one through the Power On Setup routines Alterna tively when a program ends normally or due to an error the QTERM RS55 will enter download mode To enter the Power On Setup menu follow these steps e Connect the power supply to the QTERM RS5 e Hold down any three keys and apply power to the QTERM RSS you do not need to connect the transmit and receive lines When the words POWER ON SETUP POS appear on the screen release the keys e After a brief pause a menu will appear The asterisk indicates the currently selected menu item The keys used for navigating the Power On Setup menus are located in the upper right corner of the key pad Figure 1 1 shows key locations for the 40 key keypad the keys for the 24 key keypad are in similar locations with respect to the upper right corner of the keypad The up arrow is hereafter referenced as the POS Up key The other marked keys are similarly designated as POS Down POS Left POS Right and POS Enter OUOUWO OVB Figure 1 1 Key Names el POWER 40 k 4 4 key enter gt ceypad 91 i ey Keypad j Ta LED Labels
20. e QTERM R55 Hand held Version ooo a E Plug Jack D0Q 904r3 6 Pin Modular Connector 485 RTx 422 Tx 1 485 RTx 422 Tx 232 Tx 2 o 422 422 Rx 232 Rx 3 i 4 9 Power Ground 5 DB9 Female Figure 3 2 QTERM Connector Pin Assignments QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 18 Table 3 1 Pin Assignments for PC Style COM Ports QTERM R77 User s Manual i site ARE Bene SOU H000 Baca HEA t Figure 3 3 Dimensions of the QTERM R55 Panel Mount Version Connection to the panel mount QTERM R55 is made via a 6 pin 2 mm pitch header which is located on the PCB as shown in Figure 3 5 standard output COM Ports with Male DB25 Connectors COM Ports with Male DB9 Connectors Pin Function Pin Function 2 PC transmit 1 CD 3 PC receive 2 PC receive 4 RTS 3 PC transmit 5 CTS 4 DTR 6 DSR 5 ground 7 ground 6 DSR 8 CD 7 RTS 20 DTR 8 CTS 22 RI 9 RI These lines normally can be left unconnected Some PCs may require that one or more of them be pulled to 5 volts through a pullup resistor about 300 ohms 3 3 QTERM RS55 Large Character Panel Mount Terminal The dimensions of the QTERM R55 large character panel mount terminal are shown in Figure 3 6 This terminal is available with a 24
21. ef statement to define a shifted key string Sets the current state of the shift key Allows battery powered terminals to be turned off by software terminals not powered by a battery treat this command as an end Calculates the Sine of x Specifies the value to increment the variable in a for loop Calculates the square root of x Forces whatever is in the parenthesis to be viewed as a string Calculates the Tangent of x Placed at the end of an if statement to indicate where to start executing code Returns a string containing the current time Used in a for loop to specify the upper bound of the loop Removes spaces from both ends of a string Converts the characters in string to upper case Converts the string string to a number Same as pause line map poke printer reverse select system text textwin transparent window xmap xtick ymap ytick QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 APPENDIX D USING THE R55 DOWNLOADER D 1 Purpose The R55 Downloader is a Windows application that sends qaBASIC program files and QTERM RS55 firmware upgrades out a specified COM port on the PC D 2 Setup To install the R55 Downloader on your PC hard drive fol low these steps e Copy the R55 Downloader exe file from the diskette included with this manual to a directory on your hard drive e Test your installation by running the program From the Start Menu in Windows select Run Type x
22. ent return makes qaBASIC return to the position of the original gosub and proceed from there Note that both goto and gosub can be used as on goto and on gosub see on gosub on goto section 2 5 5 2 5 5 on gosub on goto The on gosub statement is followed by a list of labels sorry one two in Example 9 below Depend ing on the value of the expression number 1 the corre sponding label in the list is chosen for example if number 1 evaluates to 3 the third label three is selected and a gosub to this label is performed A gosub is always performed regardless of the value of the expression More specifically if number 1 gives any thing less or equal to 1 then the first label sorry is cho sen If number 1 evaluates to anything greater or equal to the number of elements in the list which is 7 in Example 9 then the last label Sorry is chosen Therefore the QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R7 User s Manual label sorry is chosen whenever the program cannot con vert the given number Note that the on construct can also be used as on goto 2 5 6 End of Program The end statement ends your program immediately see Example 9 below Note that this will cause the QTERM R55 to enter download mode and wait for a new application program to be sent via the serial port 2 6 Loops Example 7 input Please enter a word a for a len a to 1 step 1 print mid a
23. esistant ABS and is col ored black The housing is not waterproof but it can be subjected to moderate rain or splash without harm The QTERM RS55 handheld terminal uses a 6 pin modular jack exiting from the bottom of the housing If desired the modular jack can easily be switched to exit from the top of the QTERM RS55 housing The pin assignments for the connectors for each of the available interfaces are shown in Table 3 2 Figure 3 2 shows the pin numbering for the connectors used on the QTERM RS55 For reference Table 3 1 shows the pin assignments used by the COM ports on PC style computers for both DB25 and DB9 connectors 3 2 QTERM RS55 Panel Mount Terminal The panel mount QTERM R55 is mounted directly onto your instrument or enclosure Figure 3 3 shows the dimen sions of the panel mount QTERM RS55 along with the stan dard keypad legend for the 24 key keypad The QTERM RS55 is mounted to the panel by placing the terminal into the panel cutout and attaching the rear shell behind the panel with the four self tapping screws A mounting gasket is provided in order to seal the front edge of the terminal Figure 3 4 shows the assembly diagram along with the panel cutout dimensions required for mount ing Le 105 9 33 2 E e N i QTERM R55 CEBHE 194 9 ggo ggo B800 OOOO OOOO HOBOS D00 904r3 noa Handheld Figure 3 1 Dimensions of th
24. ffer for that interface Peeking at ostick returns the number of operating system time ticks since the unit was powered on The time interval between ticks is 20 milliseconds The syntax is peek lt keyword gt where lt keyword gt is one of the following columns rows numkeys cursorx cursory COM1 COM2 ostick 13 The numeric return value contains the requested informa tion 2 8 4 Serial Communication The program may send characters or strings to the serial port with these commands send COM1 string send COM1 num strings recvS COM1 num recv COM1 In a string context send outputs string string to the port In a numeric context send outputs a character whose ASCII value is contained in num truncated to an integer modulo 255 In a string context recv will grab everything in the serial input buffer up to 100 characters and put it into string strings If no characters are available this function returns an empty string NOTE As explained in section 2 1 1 2 string variables may not contain NULL characters Therefore if the serial stream might contain NULL characters recv must be used in a numeric context In a numeric context recv pulls one character from the serial port and puts its ASCII value into variable num If no character is available this function returns the value 256 print and input also work with the serial port by inserting the serial port identifier print COM1 strin
25. g num input COM1 a Example 10 illustrates the serial communications com mands Programming serial communications for the EIA 485 inter face requires special attention See section 3 4 3 for more information 2 8 5 Keypad LEDs The LEDs may be turned on and off with the following commands led lt lednum gt on led lt lednum gt off lt lednum gt is an expression yielding an integer from to 6 See Figure 2 1 QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 14 Example 10 program illustrates the Led commands 2 8 6 Display Contrast The display contrast may be adjusted with the contrast commands see Example 10 contrast up contrast down The new contrast setting persists until the terminal is pow ered down To permanently adjust the contrast of the dis play use the Power On Setup facility see section 1 1 2 8 7 Display Backlight The display backlight may be turned on and off with the backlight commands see Example 10 backlight on backlight off 2 8 8 Key Click If enabled the Key Click feature causes the terminal speaker to emit a short beep whenever a key on the keypad is pressed This feature may be turned on and off with the following commands keyclick on keyclick off The Key Click setting persists until the terminal is powered down The default setting when the terminal is powered on can be selected in the Power On Setup facility see sec tion 1 1 2 8
26. he characters that are printed on the standard legend see Fig ure 2 1 However as the QTERM R55 legends are com pletely customizable a qaBASIC facility has been created to allow for redefinition of the characters that are returned by input functions when keys are pressed The command to accomplish this is described below keydef release shift lt col gt lt row gt lt string gt This command redefines the key at location col row where col and row are the one based column and row of the key on the keypad For example the upper left key on the 40 key keypad is key 1 1 and the lower right key is key 5 8 The string is sent to the BASIC input functions when the key is pressed The optional release and shift modifiers change the definition for a key release event and or a shifted key event QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R9 User s Manual Columns Rows Figure 2 2 Key Locations Key release events can be enabled with the keyrelease on command The keyrelease off command disables them The default is disabled 2 8 13 Shift State The state of the shift key on or off may be altered with the shiftstate commands shiftstate on shiftstate off The shift state is toggled automatically when the shift key is pressed See Figure 2 1 When the shift state is on the shifted key definition is used to determine the key input seeDefining the Keyboard
27. iables 2 1 1 4 Multiple Commands on One Line More than one command can appear on one line The com mands must be separated with colons 2 2 Introduction to gqaBASIC Example 1 REM this is the first R55 BASIC program input Enter two numbers a b print a b a b print Please enter your Name INPUT a print Hello as This program produces the following output user input is displayed using this typeface Enter two numbers 2 3 2 3 5 Please enter your Name Bill Hello Bill QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 6 2 2 1 REM The REM statement introduces comments Everything after REM up to the end of the line is ignored The apostrophe is an abbreviated replacement for REM 2 2 2 Input This statement reads one or more variables from the user The syntax for this command is input prompt vari var2 The optional prompt string after the input statement Enter two numbers is printed on the terminal prior to reading any input If the prompt string is omitted the terminal uses the character to prompt the user Note that there is no semicolon or comma after this prompt string If multiple variables are requested they are listed after the prompt string separated by commas The default input source is the keypad This command may also be used to read input from a serial port or the non vol atile file store See Serial Communication sect
28. ines Connect your DC power supply to the appropriate two pins WARNING Power supplied to the QTERM R55 must be from a SELV power source and should have a current limit on its output of 5 Amperes The supply to the QTERM R55 must provide 3 a minimum of 8 volts DC and be limited to a maximum of 32 volts DC Limiting may be inherent to the supply or may be provided by supplementary overcurrent devices If the QTERM RS55 does not respond or exhibits abnormal behavior on power up disconnect power and contact QSI for technical support 1 4 Running the R55 Downloader See Appendix D for information about the R55 Down loader for Windows QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 QTERM R77 User s Manual QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 CHAPTER 2 QABASIC The QTERM RSS is a user programmable operator inter face terminal for industrial applications The terminal is programmed using qaBASIC a dialect of the common and simple BASIC programming language The BASIC pro gram can be written using any computer text editor and then downloaded into the terminal and stored in non vola tile memory This program is executed after power is applied to the system The program may be updated through the Power On Setup menu see section 1 1 qaBASIC is a modified version of YABASIC a BASIC compiler and runtime execution engine written by Marc Oliver Ulm Much of
29. ion endif Marks the end of an if statement eof Used to determine if the end of a file has been reached error Used in an on error statement to implement non fatal error handling euler The value of e exp x Calculates e ET Same functionality as endif for Used to perform a loop a certain number of times frac x Returns the decimal part of x goint Used to identify the label for the code used as an interrupt handler gosub Branches program execution to another part of the program goto Branches program execution to another part of the program if Used to perform conditional tests inkeys Gets a key from the keypad input Reads the users input input at Places the cursor at a specific location on the screen and receives input instr string chars int x iskeypressed keyclick Searches string for chars Returns the integer part of x Used to get the key string for any key that may have been pressed returns empty if no key has been pressed Turns the keyclick feature on or off continued QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R2 User s Manual 29 Table C 1 qaBASIC Command Summary Command Description keydef Defines the keystring for a key keyrelease Used for enabling or disabling key release strings label Used to place a marker in the code for use with gotos and gosubs led Used to turn the terminal LEDs on or off lefts string x len string log x lowbat l
30. ion 2 8 4 and Nonvolatile Storage of Data section 2 10 for details 2 2 3 Print The print statement writes all its arguments to the dis play After writing its last argument print advances the cursor to the next line asin print Hello as To do this the QTERM RS5S inserts a carriage return character OxOD and a linefeed character OxOA after the string To avoid this behavior place a semicolon after the last argument asin print Please enter your Name Note that print can be abbreviated with a single question mark If you want to print or input at a specific loca tion refer to Printing and Controlling the Screen section 2 9 The default output destination is the display This com mand may also be used to send output to a serial port or the non volatile file store See Serial Communication section 2 8 4 and Nonvolatile Storage of Data section 2 10 for details 2 3 Arithmetic Example 2 print 14 2 2 3 4 2 2 3 print sin 1 0 cos pi tan 3 print asin 0 5 acos 0 7 OTERM R2 User s Manual print atan 2 atan 1 2 print exp 1 log 2 log euler print int 2 34 frac 2 34 mod 11 4 print min 2 3 max 2 3 print sqrt 2 This program produces the following output 3 6 2 83 0 841471 1 0 142547 0 523599 0 795399 1 10715 0 463648 2 71828 0 693147 1 2 0 34 3 2 1 3 241421 2 3 1 Operations qaBASIC has five arithmetic operators addition subtraction multi
31. key or a 40 key keypad The housing is made from rugged glass fiber filled nylon plastic and is colored black The housing is not waterproof but it can be subjected to moderate rain or splash without harm The QTERM RS5 is mounted directly onto your instrument or enclosure panel Figure 3 7 shows the mounting cutout required to install the terminal The QTERM R55 is mounted to the panel via four angle brackets that attach to the terminal with self tapping screws that insert from the rear of the bracket and screw into the bosses on the QTERM RS55 enclosure These brackets are designed so they can be attached before inserting the terminal into the panel Once the brackets have been installed the terminal is inserted into the panel and the brackets are slid outward Then the screws are tightened and the brackets hold the ter minal in place Screws and brackets are included with the QTERM RSS these are usable with panels up to about 10 mm thick A gasket is provided to seal the outside edges of the terminal where it presses against the panel Connection to the large character panel mount QTERM RS55 is made via the DB9 connector which is accessible on the back of the terminal The connector pin numbering is shown in Table 3 2 QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R 7 User s Manual Table 3 2 QTERM Pin Assignments 3 4 Interfaces 3 4 1 EIA 232 Interface With proper cab
32. les and good grounding the EIA 232 inter face on the QTERM RS55 can communicate up to about 15 meters Handshaking between the host computer and the QTERM R55 is optional This is done using software flow control XON XOFF or the EIA 232 modem control lines such QTERM Handheld EIA 232 QTERM QTERM 6 pin 6x1 DB9 5VB EIA 422 EIA 485 Modular 2mm Female Function Function Function 1 1 3 receive receive RTx 2 2 6 RTS receive RTx 3 3 2 transmit transmit no connect 4 4 1 CTS transmit no connect 5 5 9 power power power 6 6 5 ground ground ground if the hardware flow control option is enabled as RTS and CTS Note the non standard pinout for the RTS and CTS lines on the DB9 connector 3 4 2 EIA 422 Interface With proper cables and grounding the EIA 422 interface can communicate up to a distance of about 1 000 meters The EIA 422 version of the QTERM R55 uses four com munication lines and two power lines T Panel Cutout Figure 3 4 QTERM R55 Assembly and Panel Cutout Dimensions QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 20 QTERM R77 User s Manual R55 CPU PCB syg NE ape l ooo Auxilliary Output E A Nauti gore Stan d a rd O utput 232 422 485 a a 2mm Function Function Function Wee J 232 422 485 1 Rx Rxt RTX z PAE 2m
33. lt directory gt R55 Downloader exe including the quotes where x is the drive and lt directory gt is the directory where you copied the R55 Down loader exe file You may wish to create a shortcut to launch this program Refer to your operating system documentation for details e A dialog box will appear with all the options that you need to configure the R55 Downloader to communi cate with the QTERM RSS D 3 Basic Operation D 3 1 Using the R55 Downloader Launch the program as described above in Setup section D 2 You may optionally specify the qaBASIC file that you wish to download on the command line after R55 Donwloader exe D 3 2 Selecting the file to download Use the Filename field at the top of the dialog box to spec ify the name of the file to download To browse for a file press the button If a file with a bin extension is entered the download type is automatically set to Firmware Upgrade If a file with a qbs or bas extension is selected the download type is automatically set to Application Download D 3 3 Selecting the serial port Select the COM port which is attached to the QTERM R55 from the COM Port box D 3 4 Setting the communication parameters Select the baud rate parity and flow control to match the communication settings of the primary COM port of the QTERM R55 It is possible to use the R55 Downloader with a QTERM R55 that has been configured with EIA 485 on the primary in
34. m Function Function Function 2 RTS Rx RIxt ee ae 7 RX xt RIx 3 Tx Txt F R 3 2 RTS Rx RTx 4 CTS Tx G lt A mp 3 Tx Txt 5 5VDCOut 5VDC Out 5VDC Out Emit a inl aa 7 n a 6 Ground Ground Ground Ea ma A 5 8 32VDC In 8 32VDC In 8 32VDC In Dn C 3 6 Ground Ground Ground nonce agus Battery Back N 2mm Function 1 Ground 2 N C 3 5VDC Out 4 BATSLP 5 LowBAT 6 Ground Output Wiring Detail Figure 3 5 QTERM R55 Panel Mount Output Wiring 3 4 3 EIA 485 Interface cabling and termination up to 32 EIA 485 devices can be connected across a cable of up to 1000 meters in length The EIA 485 interface is similar to EIA 422 but was The EIA 485 interface on the QTERM R55 uses two com designed as a half duplex multidrop interface With proper munication lines and two power lines gt 31 197 7 EER E gt C2200 Auxillary Port a Mounting Bracket 1 of 4 184 r A 23 For discrete wires l i DB9 P Me z Z Optional E Stop Switch 2 Gasket is included Front View Side View Back View Figure 3 6 Dimensions of the QTERM R55 Large Character Panel Mount Terminal QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R2 User s Manual 183 4 mm max radius 4 places Cut Out This Hole
35. more than one different intermediate file in one session only the last file is deleted when the R55 Downloader is closed OTERM R2 User s Manual D 5 Preprocessor Directives D 5 1 Overview The R55 supports a few simple preprocessor directives These directives are useful shortcuts to help speed applica tion development Each preprocessor directive is preceded with the percent symbol Each directive should be the last command on a line i e don t try to use to add more commands after the directive as they will be interpreted as part of the directive D 5 2 Include Use the include directive to include the contents of another file at that location of the current file The syntax is as fol lows include filename Example Setup the custom keypad include KeypadLayout qbh In this example the contents of KeypadLayout qgbh are copied into the application file D 5 3 Define The define directive is a macro substitution directive that redefines a symbol as something else A symbol can be any string of characters Symbols within quoted strings are not substituted The syntax is define lt symbol gt lt definition gt Example Shortcut to print out the serial port define PC1 print COM1 The directive in this example will cause every occurrence of PC1 except within quoted strings to be replaced with print COM1 QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770
36. nd will evaluate lt expression gt to a positive integer n dropping fractions and will position a file pointer at the beginning of the nth line in the specified file Subsequent input command will read the file at this location A line is defined as any sequence of bytes ending in the newline character seek lt 1 9 gt lt expression gt lines is similar to the seek command above except that it positions the file pointer relative to the current file pointer location rather than to an absolute line number This command evaluates lt expression gt to a positive or negative integer n drop ping fractions and positions the file pointer to the begin ning of the nth following line for positive n relative to the current file pointer location in the specified file Subse quent input command will read the file at this location Print command can only be used to write to a file if it has been opened for appending and the current file pointer loca tion is at the end of the file QTERM R77 User s Manual Note that the print and input commands automatically position the file pointer to the beginning of the following line after reading writing the file 2 11 Error Handling There are two types of error handling statements that can be used on error goint lt label gt on lowbat goint lt label gt The first statement sets the terminal so that if it encounters a non fatal error it will begin execution of a special sub routine starti
37. ng Regulator The standard QTERM R55 uses a switching regulator which allows the terminal to be powered from a 8 volt to 32 volt DC source QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 22 3 8 QTERM Specifications 3 8 1 Environmental Characteristics Environmental and power specifications are listed in Table 3 3 Table 3 3 Environmental and Power Specifications QTERM R77 User s Manual 3 8 2 Electrical Characteristics Typical current consumption is listed in Table 3 4 Table 3 4 QTERM RS55 Current Consumption Parameter Limits Standard Backlit Display usable 10 to 60 C temperature range Wide temperature Display usable 20 to 70 C temperature range Storage temperature all 40 to 85 C components Maximum humidity range all 0 to 95 components non condensing Operating voltage range 8 to 32 volts DC Battery Back Option Battery life 60 hours Battery life backlight on 24 hours Version oe ea a oe EJA 232 88 33 Add for backlight 30 9 Add for each LED 4 2 QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 APPENDIX A ASCII CHART Most Significant Digit hex NUL blank SOH start of header 1 3 5 6 STX start of text ETX end of text EOT end of transmission ENQ enquiry ACK acknowledge BEL bell BS backspace HT horizontal tab LF line feed VT vertical tab FF form feed CR carriage return SO
38. ng at the location given by the label rather than sending the error description to the primary serial port and aborting the program Any subsequent errors encountered while handling that error however will not call the error handler but a description will be sent to the primary serial port The error that caused the interrupt may be found in the error handling routine by using the command peek error The resulting string of this function will contain the error information The lowbat handling routine will also call a subroutine starting at the location given by the label assuming the unit is designed for battery operation If there is no error han dler and the unit s battery is getting low it will beep peri odically instead IMPORTANT NOTE While in these interrupt handlers one should not attempt to perform any type of input pro cessing from the keypad or communications port that sus pends program flow Interrupt handlers should be simple and quick and should return with a gosub at the end of the routine subroutine calls are allowed inside the handler and will be handled appropriately QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 CHAPTER 3 QTERM R55 HARDWARE 3 1 QTERM RS55 Handheld Terminal The dimensions of the QTERM RS55 handheld terminal are shown in Figure 3 1 This figure also shows the standard keypad legend for the keys on the 40 key keypad The housing is made from impact r
39. on gosub on goto 10 2 5 6 End of Program 11 Loops 11 Data and Arrays 11 2 7 1 Reading Data 11 2 7 2 Arrays 11 Interaction with System Hardware 12 2 8 1 Date and Time 12 2 8 2 Cursor Appearance 13 2 8 3 Peek 13 2 8 4 Serial Communication 13 2 8 5 Keypad LEDs 13 QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 2 9 2 10 2 11 17 2 8 6 Display Contrast 14 2 8 7 Display Backlight 14 2 8 8 Key Click 14 2 8 9 Keypad Backlight 14 2 8 10 Speaker 14 2 8 11 Pause Execution 14 2 8 12 Defining the Keyboard 14 2 8 13 Shift State 15 Printing and Controlling the Screen 15 2 9 1 Printing Output 15 2 9 2 Autowrap and Autoscroll 15 Nonvolatile Storage of Data 15 Error Handling 16 CHAPTER 3 QTERM R55 HARDWARE 17 3 1 3 2 3 3 3 4 3 5 3 7 3 8 23 APPENDIX APPENDIX B 25 APPENDIX C 27 APPENDIX D 31 APPENDIX E E 1 E 2 E 3 QTERM RS55 Handheld Terminal 17 QTERM RS5 Panel Mount Terminal 17 QTERM RS55 Large Character Panel Mount Terminal 18 Interfaces 19 3 4 1 EJA 232 Interface 19 3 4 2 EJA 422 Interface 19 3 4 3 EJA 485 Interface 20 LCD Display 21 Keypad 21 Other Options 21 3 7 1 Speaker Option 21 3 7 2 Real Time Clock Option 21 3 7 3 Switching Regulator 21 QTERM Specifications 22 3 8 1 Environmental Characteristics 22 3 8 2 Electrical Characteristics 22 ASCII CHART 23 23 QTERM RS55 CHARACTER CHART 25 QABASIC COMMAND SUMMARY 27 USING THE R55 DOWNLOAD
40. orizontal position The following syntax is used for autowrap and autoscroll statements autowrap on autowrap off autoscroll on autoscroll off 2 10 Nonvolatile Storage of Data The following commands were added to allow for a limited file system Although one may read and append a file can t be overwritten because of the nature of flash memory The entire file space must be erased in order to rewrite a file The command to erase is given as a system command described below Up to nine files may be used for storage of data open lt 1 9 gt r or a opens a file for read ing r or appending a append is default Example open 1 r QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 16 print lt 1 9 gt lt str gt prints str writes to the end of a currently open file input lt 1 9 gt lt str gt reads from a currently open file until it reaches a newline character eof lt 1 9 gt determines if the end of a file has been reached when reading close lt 1 9 gt closes a currently open file system erase filespace or system erase filespace erases the filespace system avail filespace or system avail filespace is a pessimistic indication of how much free area exists for writing more data seek lt 1 9 gt to line lt expression gt allows random access to an open file in the filespace This com ma
41. ower string ltrims string max x y mids string x y min x y mod x y next x normal not off on on x gosub on x goto open x or pause x peek x pi or PI print print at ran x read recv recvs release rem restore return Returns the left x characters from string Returns the length of string Calculates the logarithim of x Used in the on lowbat statement that define a handler for the low battery inter rupt Converts the characters in string to lower case Removes any spaces from the left side of the string Returns the higher of the x and y values Returns the middle y characters from string starting at position x Returns the lower of the x and y values Returns the remainder when dividing x by y Increments x and goes to the start of the for loop Used in the cursor normal statement to return the cursor mode to normal Returns the inverse of whatever is after it Used in other commands to turn something off Used in other commands to turn something on Performs a gosub to the label in the variable x Performs a goto to the label in the variable x Open file x Used to combine two conditional statements Delays program execution for x seconds Used to read QTERM RSS internal variables legal values of x are rows col umns numkeys cursorX cursorY COM1 COM2 ostick The value of pi 3 141592653589793 in 32 bit ANSI TEEE 754 1985 format Prints whatever is after it to the dis
42. paces ltrim foo returns foo see Example 3 and rtrim foo returns foo trims foo returns foo QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R7 User s Manual 2 4 7 The ASCII Character Set Functions qaBASIC offers two functions to work with the ASCII character set asc converts a specific character to its ASCII value print asc e returns 101 as a result see Example 3 because the character e has position 101 within the ASCII character set Appendix A contains a complete 7 bit ASCII chart Likewise the function chr returns the ASCII character for a given position within the character set e g chrs 98 returns b 2 4 8 Escape Sequences The most important non printable characters can be con structed using escape sequences with the character The sequence n might be used instead of chr 10 for the newline character Table 2 1 lists all escape sequences of qaBASIC these are similar to the sequences used by the C language Table 2 1 Escape Sequences for qaBASIC Escape Resulting ASCII Sequence Character Value n newline 10 t tabulator 9 b vertical tabulator 11 v backspace 8 r carriage return 13 form feed 12 a alert 7 backslash 92 single quote 39 Nae double quote 34 These escape sequences are replaced within every pair of double quotes i e within literal strings User input read with the input s
43. play Works the same as print but outputs to a specified location Returns a random number between 0 and x Reads one data item at a time from the data lines in the program Receives input from the serial port and stores it as a number Receives input from the serial port and stores it as a string Used in a keydef statement to define a key release string Signals a comment the line is not executed Used to specify the location that read gets its data from Used at the end of a gosub to return to the next line in the main program flow continued QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 30 QTERM R77 User s Manual Table C 1 qaBASIC Command Summary Command Description right string x rtrims strings seek x to line y seek x y lines send shift shiftstate shutdown sin x step sqrt x str tan x then times to trims string uppers strings val strings wait x x and y represent numbers string represents a string Other reserved keywords that currently do nothing but are not legal for variable names are arrow break bitmap circle dot draw erase font frame interrupt inverse Returns the right x number of characters from string Removes the white spaces on the right side of the string Sets file pointer to line y in file x Sets file pointer y lines away from current position Sends data over the serial port Used ina keyd
44. ple 2 int drops the fractional portion of the argument and returns an integer frac returns just the fractional portion of the argument 2 3 2 4 Remainder To get the remainder of a division use the mod function As Example 2 shows mod 11 4 produces 3 because 11 4 2 with a remainder of 3 NOTE Arithmetic operations using large numbers may cause fractional inconsistencies in your answer For exam ple 12000000 300000 may yield 40 00000001 This is inherent in floating point arithmetic 2 3 2 5 Minimum and Maximum The functions min and max return the lower and higher value of their two arguments respectively see Example 2 2 3 2 6 Square Root The square root is calculated by the sqrt function see Example 2 2 4 String Operations BASIC has always been simple and strong in string pro cessing qaBASIC also maintains this feature Example 3 aS 123456 print len a print left a 2 print mid a 2 3 print right a 3 left a 2 abcd print a print str 12 print str 12 123455 08 5f print 2 val 23 print val e2 instr Hallo al lower aBcD12 G ltrim foo print asc e t ct ct This program produces the following output 6 12 234 456 ab3456 a 12 12346 25 0 2 abcdl2fg n foo 101 2 4 1 Length of a String The len function returns the length of the string see Example 3 2 4 2 Extracting Parts of a String The
45. plication division and power they all behave as expected as in Example 2 Note that the power operator handles fractional powers 8 1 3 returns 2 as a result 2 3 2 Functions This section demonstrates and explains the arithmetic func tions of qaBASIC 2 3 2 1 Trigonometric Functions Example 2 illustrates the six supported trigonometric func tions qaBASIC can calculate sine cosine tangent and their inverses All these functions expect their argument in radi ans to facilitate the transformation from degrees to radians radian degree pi 180 there is a predefined vari able named pi or PI which has an initial value of 3 14159 The atan function has two forms Called with a single argument e g atan 2 atan returns a value between pi 2 pi 2 Called with two arguments e g atan 2 1 atan returns a value between pi and pi This can be useful when transforming from cartesian to polar coordi nates 2 3 2 2 Exponentiation The exp functions comes with its inverse the log function log and exp operate with the base e QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R7 User s Manual 2 71828 which comes as a predefined variable named euler The exponentiation functions are illustrated by the second qaBASIC example 2 3 2 3 Integer and Fractional Parts The functions int and frac split their argument at the decimal point see Exam
46. port baud rate and data format for the Primary Port or the Secondary Port if the QTERM RS55 was purchased with the auxiliary serial port option The baud rate is adjusted up and down with the POS Up and POS Down keys press POS Enter when the desired baud rate is displayed Select data format to adjust the num OTERM R2 User s Manual ber of data bits parity and number of stop bits for the serial port Selecting Back Save from the menu saves these parameters and returns to the main POS menu The Clock menu is used to set the Real Time Clock If the QTERM R55 was not purchased with the Real Time Clock option Clock will not be displayed on the main POS menu The Defaults menu restores all settings including contrast baud rate and data format to their default values No submenu exists for this item The Download menu allows new terminal firmware and BASIC programs to be downloaded to the termi nal Select Firmware to upgrade the terminal firm ware The terminal will enter its bootloader routine and await receipt of the new firmware via the primary serial port Selecting Application will enter a BASIC program download routine The terminal is now ready to receive your BASIC program via the primary serial port Back will return to the main POS menu without receiving any files e If the QTERM RS5 is configured with the 1 0 Mbyte flash memory option the additional memory may be reserved for application storage i e the qaBASIC
47. pro gram is stored in this space or user file space Choos ing Application will display a menu to select how much memory is assigned to each of these tasks Assign the memory by pressing POS Left and POS Right then accept the settings by pressing POS Enter The terminal will now enter the BASIC pro gram download routine The default partition 128 kbytes for application space and 640 kbytes for the file system is usually appropriate unless your application is very large 1 2 Connect the Communications Lines The EIA 232 device has one transmit and one receive line while the EIA 422 device has two transmit and two receive lines The EIA 485 device has two bidirectional transmit receive lines Table 3 2 in Chapter 3 shows the connector pin assign ments for all versions The receive and transmit directions shown in the table are relative to the QTERM RSS Refer to this table to connect your host communications lines to the correct pins Figure 1 2 shows the pin numbering of the 6 QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R7 User s Manual pin modular connector both jack and plug The panel mount interface plug also uses this pinout If you are using an IBM style PC you cannot connect an EIA 422 or EIA 485 QTERM RS5 directly to the com puter s COM port you must provide an interface device 1 3 Apply Power Table 3 2 in Chapter 3 shows the pin assignments for the power and ground l
48. put string has four fields see Example 10 5 is the day of the week 1 7 1 is Sunday 7 is Saturday 28 is the day of the month 01 31 08 is the month 01 12 and 98 is the year QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 OTERM R7 User s Manual The time output string has three fields 13 is the hour 00 23 51 is the minute 00 59 and 53 is the second 00 59 All fields of date and times except the last field within time are fixed length thus it is easy to extract fields with the midg function see Extracting Parts of a String section 2 4 2 2 8 2 Cursor Appearance The following cursor commands control the appearance of the cursor cursor normal cursor blink cursor off Normal is the standard underscore cursor default The cursor may be positioned with the at command as fol lows cursor at X Y where X and Y are the column and row of the desired cur sor location respectively The at command can also be used with the print command see section 2 9 1 These commands are illustrated in Example 10 2 8 3 Peek The peek function is handy for obtaining certain infor mation about the QTERM R55 hardware This command can be used to get the number of character rows and col umns on the QTERM R55 display the number of keys on the keypad and the current cursor position X or Y Peek ing at COM or COM2 returns the number of characters available in the receive bu
49. r the timeout period for the slave response has expired 3 If broadcast queries which require a response from multiple slaves must be sup ported the slaves should respond sequen tially or otherwise resolve the response traffic to avoid contention 3 5 LCD Display The QTERM RS55 display is a 4 line by 20 character supertwist LCD unit The entire 128 byte ASCII character set can be displayed also many Greek letters katakana characters non English alphabetic characters and math symbols can also be displayed Appendix B is a chart which shows how the QTERM R55 will display each 8 bit value Note that the ASCII portion of the chart the first 128 characters is similar but not identical to the true ASCII chart shown in Appendix A If you ordered the backlight the qaBASIC commands listed in Chapter 2 will allow you to turn the backlight on and off Without the backlight these commands have no effect 3 6 Keypad The QTERM RSS is available with a 24 key or a 40 key keypad The Power On Setup menus allow you to control both key click on or off and key repeat on or off delay and rate 3 7 Other Options 3 7 1 Speaker Option The QTERM RS5 includes an audio speaker which is used for key beeps and for beeping in response to a beep or bell command 3 7 2 Real Time Clock Option If you order the real time clock option the QTERM R55 includes hardware support for the date and times qaBASIC commands 3 7 3 Switchi
50. re are three functions which return parts of a string left lt string gt lt length gt right lt string gt lt length gt mids lt string gt lt position gt lt length gt left returns the leftmost lt length gt characters of lt string gt right returns the rightmost lt length gt char acters of lt string gt and midg cuts in the middle return ing lt length gt number of characters starting at lt position gt characters from the left end of lt string gt The first character of a string is at position 1 Furthermore left and its associated functions can even be used to selectively change parts of a string by assigning a string to the function Example 3 shows that only the two leftmost characters are changed even though the string abcd contains four characters The same can be done with mid or right 2 4 3 Strings to Numbers and Numbers to Strings The str converts its numeric argument to a string see conversion of 12 in Example 3 Formatting of the number is optionally specified by a sec ond argument 08 5 in Example 3 The second argu ment is essentially a format string as used by the printf function in the C programming language A subset of this function is supported by the QTERM RS55 Format str value Flagfieldwidth PrecisionArgument QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 Value Flag Fieldwidth period
51. rt number end label one print l one return label two print 2 two return label three print 3 three return label four print 4 four return label five print 5 five return These programs produces the following output Please enter a number 2 2 two Please enter a number 3 3 three Please enter a number 12 Sorry can t convert 12 2 7 1 Reading Data Example 8 program converts numbers to their textual repre sentation For this purpose it needs to know the numbers from 1 to 9 as text This information is stored with the data lines at the bottom of the program The program uses the read command to get one piece of data after the other If you want to deviate from the linear ordering while read ing the data statements you may use the restore state ment In the example above restore names makes sure that the next read statement reads its data after the label names 2 7 2 Arrays In Example 8 the words one nine are stored within the string array names QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 12 QTERM R77 User s Manual Binjajaja Sasoe Figure 2 1 QTERM R55 Keypad LEDs LED 1 LED 2 LED 3 LED 4 e e e e OOOO pana eal BGs ane Sole Arrays can be used to process large quantities of data There are numerical arrays as well as string arrays Both need to be declared prior to their
52. statement 2 5 3 Marking Locations in a Program The first line in the Example 6 program label loop is a label QTERM R77 User s Manual qaBASIC does not require line numbers thus labels are necessary to mark a specific location within your program however see the following paragraph You can compose labels out of letters and digits The keyword label is required and the label itself should be unique within your program qaBASIC allows for line numbering This feature makes qaBASIC more compatible with traditional versions of BASIC Line numbers are just special types of labels with the following properties Line numbers can appear only at the beginning of a line e Not every line needs a number and line numbers need not be consecutive 2 5 4 Jumping Around in a Program A label by itself causes no special action Only in conjunc tion with the goto statement or gosub or restore does a label have any function If qaBASIC encounters a goto statement in the Example 6 goto loop then it searches for the matching label label loop and pro ceeds to execute at the position of the label Note that you can even leave and enter a for next loop see section 2 6 with goto Closely related to the goto command is the gosub com mand If qaBASIC encounters a gosub statement it searches for the matching label label thanx in Exam ple 6 and proceeds with execution at the position of the label until it finds a return statem
53. tatement is not affected in any way 2 5 Conditions and Flow Control Example 4 input Please enter a number a if a gt 10 then print Hello QSI Corporation Fax 801 466 8792 This print Your number is bigger than 10 else print Byebye print Your number is less or equal 10 endif program produces the following output Please enter a number 2 Byebye Your number is less or equal 10 Alternatively Please enter a number 11 Hello Your number is bigger than 10 Example 5 input Please enter a number a if a gt 10 and a lt 20 then rem parentheses are optional print bigger than 10 print but less than 20 fi This program produces the following output Please enter a number 11 bigger than 10 but less than 20 Alternatively Please enter a number 10 Example 6 label loop Enter a string containing R55 input a This if instr upper a R55 lt gt 0 then gosub thanx else print No please try again endif goto loop label thanx print Thanks a lot return program produces the following output Enter a string containing R55 thequickbrownfox No please try again Enter a string containing R55 jumpedR55overthelazydog Thanks a lot Web www qsicorp com Phone 801 466 8770 10 2 5 1 The if Statement The if then statement is necessary for making deci sions The syntax is as follows if lt condition gt then lt instructions gt else
54. terface This requires a QCOM 4 serial interface device available from QSI Corporation Check the box labeled This terminal is attached to a QCOM 4 using EIA 485 communications Other EIA 485 interface adapters may or may not work with the R55 Downloader Contact QSI Techical Support D 3 5 Downloading the application Prepare the QTERM R55 to receive the application file or firmware upgrade via Power On Setup see Power On Setup section 1 1 Press the Download button to send the file to the terminal A status bar will track the progress of the download To stop sending data to the terminal press Cancel After the download is complete the results of the download as well as any error messages will be displayed in the Download Results box D 3 6 Cancel If the R55 Downloader is transmitting an application file or a firmware upgrade this button terminates the transmis sion At all other times pressing this button closes the R55 Downloader QSI Corporation Fax 801 466 8792 Web www qsicorp com Phone 801 466 8770 32 D 4 Advanced Features D 4 1 Port State This Button indicates whether the serial port on the PC is open or closed If the button is red the port is closed The button is green when the port is open Other programs will not be able to access the serial port while R55 Downloader has it open Normally the R55 Downloader opens the port automatically whenever it tries to send data to the serial port and closes the port

Download Pdf Manuals

image

Related Search

Related Contents

Philips HTS3021 User's Manual  INSTALLATION AND OPERATION INSTRUCTIONS FOR Liberty US  Cullmann Madrid Maxima 325+  TC electronic SDN BHD PowerCore User's Manual  VOL.10 シミュレーター    Samsung 27" Curved Monitor SE510 Bruksanvisning  

Copyright © All rights reserved.
Failed to retrieve file