Omron C500-ASC04 Operation Manual

Ascii unit

Advertisement

Quick Links

C500-ASC04 ASCII Unit
Operation Manual
Revised February 2001

Advertisement

Table of Contents
loading

Summary of Contents for Omron C500-ASC04

  • Page 1 C500-ASC04 ASCII Unit Operation Manual Revised February 2001...
  • Page 2 WHETHER SUCH CLAIM IS BASED ON CONTRACT, WARRANTY, NEGLIGENCE, OR STRICT LIABILITY. In no event shall the responsibility of OMRON for any act exceed the individual price of the product on which liability is asserted. IN NO EVENT SHALL OMRON BE RESPONSIBLE FOR WARRANTY, REPAIR, OR OTHER CLAIMS...
  • Page 3 Application Considerations SUITABILITY FOR USE OMRON shall not be responsible for conformity with any standards, codes, or regulations that apply to the combination of products in the customer's application or use of the products. At the customer's request, OMRON will provide applicable third party certification documents identifying ratings and limitations of use that apply to the products.
  • Page 4 Performance data given in this manual is provided as a guide for the user in determining suitability and does not constitute a warranty. It may represent the result of OMRON's test conditions, and the users must correlate it to actual application requirements. Actual performance is subject to the OMRON Warranty and Limitations of Liability.
  • Page 6 OMRON. No patent liability is assumed with respect to the use of the information contained herein. Moreover, because OMRON is constantly striving to improve its high-quality products, the information contained in this manual is subject to change without notice.
  • Page 8: Table Of Contents

    TABLE OF CONTENTS PRECAUTIONS ....... . . 1 Intended Audience ............2 General Precautions .
  • Page 9 C500, C1000H, C2000H, or CV-series PC to control ASCII data I/O through a BASIC program stored in the ASCII Unit. The C500-ASC04 must be used with a PC that supports the I/O READ and I/O WRITE instructions (READ(88) and WRIT(87) or READ(190) and WRIT(191)).
  • Page 10 PRECAUTIONS This section provides general precautions for using the Programmable Controller (PC) and related devices. The information contained in this section is important for the safe and reliable application of the PC. You must read this section and understand the information contained before attempting to set up or operate a PC system. 1 Intended Audience .
  • Page 11: Intended Audience

    It is extreme important that a PC and all PC Units be used for the specified purpose and under the specified conditions, especially in applications that can directly or indirectly affect human life. You must consult with your OMRON representative before applying a PC System to the abovementioned applications.
  • Page 12: Application Precautions

    Application Precautions Locations subject to corrosive or flammable gases. Locations subject to dust (especially iron dust) or salts. Locations subject to exposure to water, oil, or chemicals. Locations subject to shock or vibration. Caution Take appropriate and sufficient countermeasures when installing systems in the following locations: Locations subject to static electricity or other forms of noise.
  • Page 13 Application Precautions Do not apply voltages to the Input Units in excess of the rated input voltage. Excess voltages may result in burning. Do not apply voltages or connect loads to the Output Units in excess of the maximum switching capacity. Excess voltage or loads may result in burning. Disconnect the functional ground terminal when performing withstand voltage tests.
  • Page 14: Hardware

    SECTION 1 Hardware This section describes the external hardware of the ASCII Unit. The front and back panels of the ASCII Unit contain switches, buttons, connectors, and indicators which enable the user to setup, control, and monitor ASCII Unit operations. The ASCII Unit’s internal configuration as well as a typical system configuration are also illustrated.
  • Page 15: Front Panel

    Section 1-1 Front Panel Front Panel On the front panel of the ASCII Unit, there are six indicator lights, the reset switch, the START/STOP switch, two RS-232C connectors, and a battery com- partment. In addition, behind the LED Display Panel, is an 8-pin DIP switch used for setting various control parameters.
  • Page 16 Section 1-1 Front Panel Note When a reception buffer overflows or transmission error occurs, the red indicator is lit and will not be turned off even if the transmission error or reception buffer overflow is corrected, because the error log must be kept. To turn off the indica- tor, execute the CLOSE instruction or stop the program.
  • Page 17 Section 1-1 Front Panel DIP Switch Settings 1 2 3 4 5 6 7 8 Start mode Screen size Pin No. Function Pin No. Screen Size Manual start mode Setting Setting 40 columns x 7 lines In this mode, the BASIC program is 40 columns x 8 lines not started upon power application.
  • Page 18: Back Panel

    Section 1-2 Back Panel Back Panel The back panel of the ASCII Unit houses the PC connector and an 8-pin DIP switch used for setting the communication parameters. Back Panel Mounting Screw For mounting the ASCII Unit to the PC Rack Connector Connects the ASCII Unit to the PC...
  • Page 19: Ascii Unit Internal Configuration

    Section 1-3 ASCII Unit Internal Configuration ASCII Unit Internal Configuration The Common Memory can be accessed using the ASCII Unit’s PC READ or PC WRITE statements. It can also be accessed using the PC’s WRIT(87/191) and READ(88/190) instructions. I/O data can be accessed using the ASCII Unit’s PC GET, PC PUT, and ON PC statements.
  • Page 20: System Configuration

    Section 1-5 Mounting System Configuration The ASCII Unit can be mounted to any slot on the CPU Backplane. Before mounting the ASCII Unit, the DIP switches must be set. Make sure that the pow- er supply to the PC is turned OFF during installation of the ASCII Unit. A personal computer used for entering the BASIC program should be connected to Port 1 and other peripheral I/O devices such as a printer or a display terminal can be connected to Port 2 (refer to the following diagram).
  • Page 21: Data Allocations

    SECTION 2 Data Allocations This section explains the words of the PC used to communicate with the ASCII Unit. Bits and Words ............Data Configuration .
  • Page 22: Bits And Words

    Section 2-2 Data Configuration Bits and Words The PC’s memory is divided up into many sections, each of which has its own unique name and purpose. The ASCII Unit can access any of these memory areas using the BASIC READ and WRITE statements (this is explained in more detail in Section 4 BASIC Programming ).
  • Page 23 Section 2-2 Data Configuration in parentheses are reserved for use by WRIT(87/191)/READ(88/190) and are not available for general programming application. Word Function Description (00) PC busy Reserved for WRIT(87/191)/READ(88/190) (01) PC WRITE complete (02) PC READ complete Restart The ASCII Unit is activated when this bit goes OFF 04 to 07 Not Used 08 to 15...
  • Page 24 Section 2-2 Data Configuration there is a time difference between when common memory data is set and when I/O data is set. This time difference must be taken into consideration when pre- paring both the ASCII Unit and PC programs. 1 cycle I/O refresh MOV(21/030) WRIT(87/191)
  • Page 25 Section 2-2 Data Configuration and n+3 are used for input. In this case, input and output are from the point of view of the PC. Word n (OUT) Word n+1 (OUT) Word n+2 (IN) Word n+3 (IN) Write Data 00 PC busy Read Data 00 ASCII busy...
  • Page 26 Section 2-2 Data Configuration Bit Definitions Word Function Description 00 to 15 Write data bits Data that will be written to the common memory from the PC by the MOV(21/030) 00 to 15 and read with the PC READ statement. PC busy Set by the PC program when the PC accesses common memory, and cleared when memory access is terminated.
  • Page 27 Section 2-2 Data Configuration Program Execution The following diagram illustrates how the words and bits allocated to the ASCII Unit relate to program execution. MOV(21/030) Write data in n ASCII Unit PC READ Common Memory MOV(21/030) Read data in n+2 Application BASIC Program...
  • Page 28: Programming And Communications

    SECTION 3 Programming and Communications The first part of this section explains how the ASCII Unit and the PC exchange information. The second part of this section explains how to transfer programs from one device to another. The ASCII Unit’s BASIC pro- gram is written on a personal computer.
  • Page 29: Programs

    Section 3-2 Program Transfer Programs To use the ASCII Unit in conjunction with the PC, an ASCII Unit program written in BASIC is needed. A data exchange routine must also be incorporated into the PC program. The PC data exchange routine must set the number of words to be transferred, the base address, and the specific memory area.
  • Page 30 Section 3-2 Program Transfer Transfer The ASCII Unit’s BASIC or assembly language program must be written on a personal computer which is connected to port 1 of the ASCII Unit through an RS-232C interface. A program can be transferred to the ASCII Unit from the per- sonal computer or any other storage device connected to one of the communi- cation ports with the BASIC LOAD command or the S and L commands.
  • Page 31: Running The Basic Program

    Section 3-4 Assembly Routines Running the BASIC Program The ASCII Unit can store and access three separate BASIC programs. Each program has an associated program number. The user can specify which pro- gram is to be used by setting pins 3 and 4 of the front panel DIP switch. This must be done before the Unit is activated.
  • Page 32: Basic Programming

    SECTION 4 BASIC Programming This section contains an explanation of the terminology, components, structure, and use of the BASIC programming language on the ASCII Unit. Even those familiar with BASIC should study this section carefully as many of the ASCII Unit BASIC commands, statements, and functions are non-standard, especially those that control I/O operations.
  • Page 33: Program Configuration

    Section 4-1 Program Configuration Program Configuration A BASIC program consists of commands, statements, and functions. General statement Statement Device control statement BASIC Language Command Arithmetic operation function Function Character string function Special function Basic Statements designate and control the flow of programs and are generally used in program lines within a program.
  • Page 34 Section 4-1 Program Configuration Constants Character Decimal Numeric Integer Octal Hexadecimal Single-precision Real Number Double-precision Character Constants A character constant is a character string enclosed by double quotation marks (”). It can be up to 255 characters long. If it has no character, it is called an “empty character string”...
  • Page 35 Section 4-1 Program Configuration ! Single-precision real: Uses 4 bytes per variable. # Double-precision real: Uses 8 bytes per variable. $ Character: Uses a maximum of 255 characters. There is a second way to declare variable types. The BASIC statements DE- FINT, DEFSTR, DEFSNG, and DEFDBL may be used to declare the types for certain variable names.
  • Page 36 Section 4-1 Program Configuration Relational Logical Character Of these, the first three produce numeric values as a result, and are thus called, “numeric expressions.” The last type is called a “character expression.” Arithmetic Operators An arithmetic expression is made up of constants, variables, and functions com- bined using arithmetic operators.
  • Page 37 Section 4-1 Program Configuration as shown in the following table. The operators are listed in the order of prece- dence. Logical Operator Description, Example, and Result NOT A NOT (negation) A AND B AND (logical product) A OR B OR (logical sum) A XOR B XOR (exclusive-OR) A IMP B...
  • Page 38: Commands, Statements, And Functions

    Section 4-2 Commands, Statements, and Functions Calculation Examples of Logical Expressions NOT (negation) A =1= 0000000000000001 NOT 1 = 1111111111111110 = –2 NOT A = –2 AND (logical product) A = 5 = 0000000000000101 B = 6 = 0000000000000110 A AND B = 0000000000000100 = 4 OR (logical sum) A = 4 = 0000000000000100 B = 3 = 0000000000000011...
  • Page 39 Section 4-2 Commands, Statements, and Functions Remarks: Explain in detail how to use the instruction Examples: Show sample code to demonstrate the use of the instruction 4-2-2 Commands This section describes all of the BASIC commands for the ASCII Unit. AUTO Command Purpose: To automatically generate line numbers for each line of the pro-...
  • Page 40 Section 4-2 Commands, Statements, and Functions Remarks: A period may be used in place of the line number to indicate the current line. EDIT Command Purpose: To Edit one line of the program Format: EDIT <line> <line> is the line number to be edited. Remarks: The EDIT Command is used to display a specified line and to position the cursor at the beginning of that line.
  • Page 41 Section 4-2 Commands, Statements, and Functions Purpose: To load a program sent from an RS-232C device to the current program area Format: LOAD #<port>,“COMU:[<spec>,<vsl>] <port> is either port 1 or port 2. <spec>: see OPEN statement tables. <vsl>: valid signal line––refer to the OPEN statement tables. Example: LOAD #1,”COMU:(43) Remarks:...
  • Page 42 Section 4-2 Commands, Statements, and Functions This diagram illustrates the PC memory map before and after the MSET com- mand is executed. Under normal conditions When MSET is executed &H0000 &H0000 I/O Area I/O Area &H0020 &H0020 System area System area &H2000 &H2000 Ç...
  • Page 43 Section 4-2 Commands, Statements, and Functions If <arg> is not specified, information on the area currently being used is dis- played. If ALL is specified, information on all three program areas will be displayed. PNAME Command Purpose: To assign a name to a program stored in the area specified with the PGEN command or to cancel a previously assigned program name Format:...
  • Page 44 Section 4-2 Commands, Statements, and Functions SAVE Command Purpose: To write the program area to the EEPROM Format: SAVE Remarks: The contents of the BASIC program area and the assembly language program area reserved with the MSET command are written to the EEPROM. If the START/STOP switch is pressed during execution of the SAVE command, the process will be aborted.
  • Page 45 Section 4-2 Commands, Statements, and Functions Remarks: This command initializes numeric variables to zero and character strings to empty. It also clears all user functions defined by the DEF FN statement. This statement must be executed before the ON ERROR GOTO statement. <size>...
  • Page 46 Section 4-2 Commands, Statements, and Functions may be thought of as one continuous list of items, regardless of how many items are on a line or where the lines are placed in the program. DATA statements are non-executable and can be placed anywhere in a pro- gram.
  • Page 47 Section 4-2 Commands, Statements, and Functions Example: DEFINT A-D, X All variables beginning with A, B, C, D, and X will be integer variables. DEF USER Statement Purpose: To specify the starting address of an assembly language subrou- tine that will be called via the USR function Format: DEF USR [<digit>] = <offset>...
  • Page 48 Section 4-2 Commands, Statements, and Functions ERROR Statement Purpose: To simulate the occurrence of an error, or to allow error codes to be defined by the user Format: ERROR <n> <n> is the error code to be simulated. Remarks: Error code numbers 1 to 255 are predefined and reserved by BASIC. Higher numbers can be used for user-defined error code messages.
  • Page 49 Section 4-2 Commands, Statements, and Functions GOSUB and RETURN Statements Purpose: To branch to and return from a subroutine Format: GOSUB <line> <line> is the first line number of the subroutine. Remarks: A subroutine may be called any number of times in a program, and a subroutine may be called from within another subroutine.
  • Page 50 Section 4-2 Commands, Statements, and Functions Remarks: If the result of <expression> is not zero, the THEN or GOTO clause will be ex- ecuted (GOTO is always followed by a line number). THEN may be followed by either a line number for branching or one or more statements to be executed. If the result of <expression>...
  • Page 51 Section 4-2 Commands, Statements, and Functions Remarks: The KEY ON statement enables an interrupt invoked by keyboard input. After this statement has been executed, an interrupt will be triggered each time the specified key is input. Program execution then branches to an interrupt service routine defined with the ON KEY GOTO or ON KEY GOSUB statements.
  • Page 52 Section 4-2 Commands, Statements, and Functions Remarks: All of the characters input from the end of the prompt to the carriage return are assigned to the character variable as a series of data. (Comas and colons are also treated as character data.) A question mark is not displayed unless it is part of the prompt string.
  • Page 53 Section 4-2 Commands, Statements, and Functions If zero is specified as the branch line number, it is assumed that the COM OFF statement has been executed. If the port number is omitted, port 1 is selected. The ON COM GOTO statement is enabled with the COM ON statement and dis- abled with the COM OFF statement.
  • Page 54 Section 4-2 Commands, Statements, and Functions If the value of <expression> is zero or greater than the number of items in the list, execution continues with the next executable statement. If the value of <expres- sion> is negative or greater than 255, an error message will be displayed. ON KEY GOSUB Statement Purpose: Defines an interrupt service subroutine to handle specific key-...
  • Page 55 Section 4-2 Commands, Statements, and Functions Example: ON KEY 1 GOTO 1000 Remarks: If a statement specified by the branch line number is non-executable, execution will begin with the first executable statement following the branch line number. If zero is specified as the branch line number, it is assumed that the KEY OFF statement has been executed.
  • Page 56 Section 4-2 Commands, Statements, and Functions The ON PC GOSUB statement is enabled with the PC ON statement and dis- abled with the PC OFF statement. Program Example: ON PC 1 GOSUB 100 ON PC 2 GOSUB 200 PC ON GOTO 40 PC READ “H4,I2”;I, J PRINT I, J...
  • Page 57 Section 4-2 Commands, Statements, and Functions number is not specified, the routine closest to the end of the program or at the highest line number will be executed regardless of which interrupt is invoked. After the ON PC GOSUB statement is executed, PC ON becomes valid. Refer to the following example.
  • Page 58 Section 4-2 Commands, Statements, and Functions PC WRITE Statement Purpose: To write data to the PC Format: PC WRITE “<format>[,<format> ...]”;<exp1> [,<exp2>, ...] Note For parameter definitions, refer to the PC READ instruction. Examples: PC WRITE “H4, A2, I3, O4”; 1234, “AB”, K, L Remarks: If the data of the previous PC WRITE statement has not been read by the PC, the next PC WRITE statement cannot be executed until the previous one is com-...
  • Page 59 Section 4-2 Commands, Statements, and Functions is output immediately after the preceding value. When the expressions are sep- arated with comas, the values are output at intervals of nine characters. If the list of expressions is not terminated with a semicolon, a carriage return is appended after the last expression.
  • Page 60 Section 4-2 Commands, Statements, and Functions Example: RANDOM 5649 Remarks: The value of <exp> should be from -32768 to 32767. If the expression is omitted, a message requesting the random number seed will be displayed. If the random number generator is not reseeded, the RND function returns the same sequence of random numbers each time the program is run.
  • Page 61 Section 4-2 Commands, Statements, and Functions Remarks: This statement causes the next READ statement to read the first element in the first DATA statement that exists in the program. If <line> is specified, the next READ statement accesses the first item in the specified DATA statement. RESUME Statement Purpose: To resume program execution after an error handling procedure...
  • Page 62 Section 4-2 Commands, Statements, and Functions Program Example: WAIT “10.0”, 100 PC READ “3I4”; A, B, C, PRINT A, B, C PRINT “PC ERR” GOTO 40 Program Remarks: This example will display the message “PC ERR” if the PC READ statement is not executed within 10 seconds.
  • Page 63 Section 4-2 Commands, Statements, and Functions The following three tables define the communication parameters for the OPEN Statement. Peripheral Device Name Output from Input to ASCII ASCII Unit Unit Terminal TERM: Keyboard KYBD: Display SCRN: Printer LPRT: RS-232C device COMU: Note TERM cannot be used with port 2.
  • Page 64 Section 4-2 Commands, Statements, and Functions If the communication specification and the valid signal line are omitted, their de- faults are: Peripheral Device Communication Valid Signal Line Conditions Terminal Keyboard Display RS-232C device Printer Ports already open cannot be opened again. When the OPEN and CLOSE statements are used, port 1 is assumed to be for a terminal and port 2 is as- sumed to be for a printer.
  • Page 65 Section 4-2 Commands, Statements, and Functions Arithmetic Operation Functions 4-2-5 ABS Function Purpose: To return the absolute value of the numeric expression specified by the argument Format: ABS(<x>) Example: A = ABS (-1.5) ACOS Function Purpose: To return the arc cosine of the numeric expression given by the argument Format: ACOS(<x>)
  • Page 66 Section 4-2 Commands, Statements, and Functions CSNG Function Purpose: To convert a numeric value into a single-precision real number Format: CSNG(<x>) Example: B = CSNG(C#) FIX Function Purpose: To return the integer part of the expression specified by the argu- ment Format: FIX(<x>)
  • Page 67 Section 4-2 Commands, Statements, and Functions SIN Function Purpose: To return the sine of the numeric value given by the argument Format: SIN(<x>) <x> is an expression in radian units. Example: A = SIN(pi) TAN Function Purpose: To return the tangent of the numeric value given by the argument Format: TAN(<x>) <x>...
  • Page 68 Section 4-2 Commands, Statements, and Functions Example: A = INSTR(5,B$,“BASIC”) Remarks: If <i> is omitted, the search begins with the first character in <x$>. If the data cannot be found, 0 is returned as the function value. If <y$> is an empty string, INSTR returns <i> or 1. LEFT$ Function Purpose: To return the specified number of characters beginning from the...
  • Page 69 Section 4-2 Commands, Statements, and Functions Remarks: If the value of <x> includes a decimal point, the INT function is internally ex- ecuted to round it off. RIGHT$ Function Purpose: To return the specified number of characters from the rightmost character of the character string Format: RIGHT$(<x$>,<i>)
  • Page 70 Section 4-2 Commands, Statements, and Functions <i> is the cursor position counting from the leftmost side of the display. Example: PRINT “CF” TAB (10) “BASIC” Remarks: The “column position” must be from 1 to 255. If the current print position is already beyond <i>, the cursor moves to the <i>th position on the next line.
  • Page 71 Section 4-2 Commands, Statements, and Functions EOF Function Purpose: To check whether the specified port buffer is empty Format: EOF (<port#>) Example: IF EOF (2) THEN CLOSE#1 ELSE GOTO 100 Remarks: This function returns true (-1) if the specified port is empty. If not, it returns false (0).
  • Page 72 Section 4-2 Commands, Statements, and Functions <port> is the port number (1 or 2). Example: A$ = INPUT$(10,#1) Remarks: All characters except CTRL+X can be read, including CR and LF: CR and LF cannot be read with the LINE INPUT statement. The BASIC LED indicator on the ASCII Unit will blink indicating that the unit is waiting for input.
  • Page 73 Section 4-2 Commands, Statements, and Functions Example: TIME$ = “09:10:00” PRINT TIME$ Remarks: In the form <y$> = TIME$, TIME$ returns an eight character string in the form: hh:mm:ss. If <x$> is not a valid string, an error message will be displayed. USR Function Purpose: To call a user-written assembly language program.
  • Page 74 Section 4-2 Commands, Statements, and Functions Integer Type Character Type Length of character string Address storing argument (higher) Higher 8 bits Address storing argument (lower) Lower 8 bits Single-Precision, Real Double-Precision, Real Number Type Number Type Exponent Exponent (MSB is always 1.) (MSB is always 1.) Higher 8 bits of mantissa Higher 8 bits of mantissa...
  • Page 75 Section 4-2 Commands, Statements, and Functions Format: <x> = VARPTR(<variable>) <variable> is a number, string, or array variable. Example: B = VARPTR (A) Remarks: The VARPTR function returns the address of the first byte of data identified with the variable. A value must be assigned to the variable prior to the call to VARPTR or an error will result.
  • Page 76 Section 4-2 Commands, Statements, and Functions Integer Array Type Character Array Type 0010 Variable name length -1 0011 Variable name length -1 Variable name Variable name Higher 8 bits of total data length Higher 8 bits of total data length Lower 8 bits of total data length Lower 8 bits of total data length Number of subscripts...
  • Page 77: Assembly Programming

    SECTION 5 Assembly Programming This section explains how to create, edit, transfer, and use an assembly language program. Assembly programs are faster and use memory more efficiently than higher level programs such as BASIC. In certain situations it is advantageous to use assem- bly routines instead of BASIC to perform specialized functions.
  • Page 78: Assembly Language Programming

    Section 5-1 Assembly Language Programming Assembly Language Programming The Hitachi HD6303X CPU is incorporated into the ASCII Unit. Mnemonics used are those found in the HD6303X operation manual. Memory Area Special memory space for assembly language programs must be reserved with the MSET command.
  • Page 79: Terminology And Formatting

    Section 5-3 Monitor Mode Commands Monitor Mode To enter monitor mode from BASIC mode, key in “mon” followed by a carriage return when the message “READY” is displayed on the console: READY When in monitor mode a “ ” is displayed on the left-side of the screen. Also, when in monitor mode, the BASIC LED on the ASCII Unit front panel is unlit.
  • Page 80 Section 5-3 Monitor Mode Commands Page Command Purpose address Displays/changes memory contents at the specified address. Transfers memory contents. Compares memory contents. Displays/changes register contents. Sets/displays break points. Clears break points. Disassembler Outputs data to a port. Loads data from a port. Verifies data.
  • Page 81 Section 5-3 Monitor Mode Commands 4. Enter: *.3000 Displayed: 401B–78 If the “dot” address format is used and the entered address is lower than the base address, the contents of the specified address will not be dis- played. The contents of the base address will be displayed instead. 5.
  • Page 82 Section 5-3 Monitor Mode Commands Destination Source start address address Source end Destination Source start address address address Source end address Proper Data Movement In this example, the source start address is smaller than the destination address and Source start the destination address is equal to or address smaller than the source end address.
  • Page 83 Section 5-3 Monitor Mode Commands Remarks: If R is entered by itself, all of the registers and their contents will be displayed. Examples: 1. Enter: Displayed: C–C0 A–00 B–01 X–ABCD S–2EFF P–5000 The contents of all the registers are displayed. 2.
  • Page 84 Section 5-3 Monitor Mode Commands Examples: 1. Enter: *I 3000 Displayed: 3000–CE 10 00 LDX #$1000 3003–FF 40 00 STX $4000 3006–86 80 LDAA #$80 3030–81 12 CMPA #$12 Disassembles and displays 20 lines of code starting from the specified address.
  • Page 85 Section 5-3 Monitor Mode Commands offset. Data transfer will not start until the ASCII Unit START/STOP switch is pressed. Verify Command Purpose: To verify whether data sent through port 1 is the same as data stored in the specified memory locations Format: V[(offset)] Example:...
  • Page 86 Section 5-3 Monitor Mode Commands Remarks: When (address) is specified, the instruction stored starting at (address) is ex- ecuted. If (address) is not specified, the instruction stored at the address indi- cated by the program counter is executed. To execute several program steps, execute the Step command as many times as required.
  • Page 87: Program Examples

    SECTION 6 Program Examples In order for the PC and the ASCII Unit to communicate with each other, both an ASCII Unit program written in BASIC and a PC program must be prepared. These two programs work with each other to coordinate the timing of communications and data transfer between the two devices.
  • Page 88: Timing Considerations

    Section 6-1 Timing Considerations Timing Considerations READ(88/190) is the I/O READ instruction and WRIT(87/191) is I/O WRITE in- struction. These are PC commands and are executed from within the PC ladder diagram program. READ(88/190) and WRIT(87/191) give the PC the ability to transfer large blocks of data during one cycle time: up to 255 words at a time.
  • Page 89 Section 6-1 Timing Considerations Timing Between PC and ASCII Unit Instructions READ(88/190) PC WRITE, WRIT(87/191) PC READ 1 cycle 1 cycle 1 cycle 1 cycle Refresh Refresh Refresh Refresh Execution Execution Execution Execution EXECUTABLE READ(88/190) READ(88/190) READ(88/190) READ(88/190) WRIT(87/191) WRIT(87/191) WRIT(87/191) WRIT(87/191) Common Memory EQ=1...
  • Page 90: Programs In Two-Word Mode

    Section 6-2 Programs in Two-word Mode Programs in Two-word Mode The following programs are executed with the ASCII Unit set in two-word mode. For all of the following examples: printer is connected to port 2 8 bits/ no parity/ 2 stop bits Example 1 Purpose: To write data from the PC using WRIT(87/191) and to the...
  • Page 91 Section 6-2 Programs in Two-word Mode Example 3 Purpose: To enter characters from the keyboard and write them to using WRITE statement READ(88/190). PC Program ASCII Unit Program READ(88/190) #0002 OPEN #2, “KYBD:” DM020 Equals Flag INPUT #2, A$ To next process PC WRITE “2A2”;...
  • Page 92 Section 6-2 Programs in Two-word Mode PC Program ASCII Unit Program 0108 10 OPEN #2,“LPRT:(47)” DIFU 3200 20 A$ = “00:00” 30 B$ = MID$ (TIME$, 4, 5) 3200 40 IF B$ <:> A$ GOTO 30 WRIT(87/191) 50 PC PUT 1 #0001 60 PC READ, “I4”...
  • Page 93 Section 6-2 Programs in Two-word Mode Example 8 Purpose: To retrieve and print several types of data from the PC us- ing the PC GET statement and WRIT(87/191) PC Program ASCII Unit Program 10 OPEN #2, “LPRT : (47)” MOV(21/030) 20 PC READ “2I4”...
  • Page 94 Section 6-2 Programs in Two-word Mode Example 9 Purpose: To use PC interrupts to direct execution of the ASCII Unit PC Program ASCII Unit Program Start 1 Start 2 Start 3 10 OPEN #2, “LPRT: (47)” WRIT(87/191) 20 ON PC 1 GOSUB 100 30 ON PC 2 GOSUB 200 #0002 40 ON PC 3 GOSUB 300...
  • Page 95 Section 6-2 Programs in Two-word Mode DM0000 Lot size DM0010 Lot size DM0100 Lot size DM0011 Lot size DM0101 Lot size DM0102 Lot size Example 10 Purpose: To print PC data and the time of data transfer ASCII Unit Program PC Program Start condition WRIT(87/191)
  • Page 96 Section 6-2 Programs in Two-word Mode PC Program ASCII Unit Program READ(88/190) #0005 10 OPEN #2, “COMU:(22)” 20 A$ = INPUT$ (1, #2) DM000 Equals Flag 30 IF A$ = CHR$(2) GOTO 50 To next process 40 GOTO 20 50 B$ = INPUT$(11, #2) #0005: Number of words to be transferred 60 IF CHR$(3) = RIGHT$ (B$, 1)
  • Page 97 Section 6-2 Programs in Two-word Mode 4. PC: When execution of WRIT(87/191) is complete, the Equals Flag is turned ON and the self-holding bit is turned OFF. 5. ASCII: The data is read from the PC using PC READ 6. ASCII: Turns OFF bit 0108 using the PC PUT 0 statement 7.
  • Page 98 Section 6-2 Programs in Two-word Mode Example 14 Purpose: To transfer data from the PC to the ASCII Unit with the PC maintaining control. PC Program ASCII Unit Program Start Input 10 ON PC 1 GOSUB 100 DIFU(13/013) 3300 20 PC 1 ON 3300 3302 90 GOTO 20...
  • Page 99 Section 6-2 Programs in Two-word Mode Example 15 Purpose: To transfer data from the ASCII Unit to the PC with the PC maintaining control. PC Program ASCII Unit Program Start Input DIFU(13/013) 3500 3500 3502 3501 100 PC GET I, J 3501 110 K = J AND 2 120 IF K <>...
  • Page 100 Section 6-2 Programs in Two-word Mode PC Program ASCII Unit Program 100 PC GET J, K Start Input 110 L = K AND 1 DIFU(13/013) 3200 120 IF L=1 THEN GOSUB 1000 ( other processing ) 3200 0108 990 GOTO 100 0008 1000 SUBROUTINE 0008...
  • Page 101 Section 6-2 Programs in Two-word Mode 13.PC: Turns Equals Flag after execution READ(88/190) has been completed and then turns OFF the self-holding bit. Example 17 Purpose: To transfer data input through the ASCII Unit keyboard to the PC and then back to the ASCII Unit after computations have been performed by the PC.
  • Page 102 Section 6-2 Programs in Two-word Mode 7. PC: Turns ON the Equals Flag when execution of WRIT(87/191) has been completed and then turns OFF the self-holding bit (3202). 8. ASCII: Data is read at line 130 and the results are assigned to the variables B1 through B4 and then displayed.
  • Page 103: Programs In Four-Word Mode

    Section 6-3 Programs in Four-word Mode Remarks: In this example, a terminal is connected to port 1 and an RS-232C communica- tion device is connected to port 2. Initially, all the interrupts are disabled. The pro- gram will wait for one of two inputs from the keyboard –– KEY 1 or KEY 2, each of which will direct the program to process subsequent interrupts in a unique way.
  • Page 104 Section 6-3 Programs in Four-word Mode PC Program ASCII Unit Program Condition 1 PC GET I, J 0008 K = J AND 3 IF K = 1 GOTO 100 Condition 3 IF K = 2 GOTO 200 IF K = 3 GOTO 300 GOTO 10 Condition 2 0009...
  • Page 105 Section 6-3 Programs in Four-word Mode Example 4 Purpose: To print out production data every hour from DM000. PC Program ASCII Unit Program ’ DM PRINTING PROGRAM 0308 OPEN #2, “LPRT: (47)” MOV(21/030) A$ = 00 : 00” DM000 B$ = MID$(TIME$, 4, 5) IF B$ <>...
  • Page 106 Section 6-3 Programs in Four-word Mode 2000 B = LOC(2) 2010 IF B<>0 THEN B$ = B$+INPUT$(B,#2) 2020 RETURN Example 7 Purpose: To transfer multi-word data from the ASCII Unit to the PC in four-word mode by using the PC WRITE statement contin- uously.
  • Page 107 Section 6-3 Programs in Four-word Mode PC Program (PC PUT data) 00315 Transfer starts DIFU(13) 01000 01000 MOV(21) Pointer initialization #0000 (ASCII write complete) DM0100 00315 00302 DIFU(13) 01001 Detects ASCII write complete 01001 DIFD(14) 01002 1 cycle delay PC READ complete 00102 (at falling edge) 01002...
  • Page 108 Section 6-3 Programs in Four-word Mode 1 cycle A$ =” (1)(2)(3)(4)(5)(6)(7)..” Data length 0000 00315 0001 0002 01000 Data 0003 First cycle Second cycle 0004 00302 0005 01001 00102 Pointer DM0100 01002 00101 01003 Example 8 Purpose: To transfer multi-word data from the PC to the ASCII Unit in four-word mode by using the PC READ statement continu- ously.
  • Page 109 Section 6-3 Programs in Four-word Mode PC GET H, I ’Check bit 15 of Wd(n+1). IF I AND 128 = 128 GOTO 920 ’Completion of transfer? PC Program Start Input 01015 DIFU(13) 01004 01004 Pointer initialization MOV(21) #0100 DM0200 Counter preset MOV(21) DM1010 DM0201...
  • Page 110: Assembly Language Examples

    Section 6-4 Assembly Language Examples 1 cycle A$ =” (1)(2)(3)(4)(5)(6)(7)” Data length 0100 01015 0101 0102 01004 Data 0103 0104 00115 First cycle Second cycle Data transfer Pointer + 1 PC write complete Counter – 1 Data length = 0 01007 ASCII write complete Pointer...
  • Page 111 Section 6-4 Assembly Language Examples Assembly Program Assembly language program operation: The numbers and characters are separated and stored in the number storage buffer and the character storage buffer, respectively. Then numeric strings and character strings are restored as the original character variables. This program has no practical application;...
  • Page 112 Section 6-4 Assembly Language Examples 130 ’ ***** ***** $2000 to $2005. CDX$=”13426285903581693417” ’Original character string for comparison CDX$. CDY$=”57201674337291551930” ’Original character string for comparison CDY$. ANS$=”00000000000000000000” ’Result storage character string ANS$. DEF USR0=&H2170 ’Storage address definition of assembly language function. CX%=VARPTR(CDY$)+1 ’Calculation of the storage address of CDX$.
  • Page 113 Section 6-4 Assembly Language Examples 21A0 STAA $00, X ’Writes the larger character string to ANS$. 21A2 21A3 $2004 21A6 DECB 21A7 $2187 ’Complete? 21A9 Work Area $2000 Storage address memory area of parameter SDX$. $2001 $2002 Storage address memory area of parameter SDY$. $2003 $2004 Storage address memory area of parameter ANS$.
  • Page 114 Section 6-4 Assembly Language Examples IF LEN(FCS$)=1 THEN FCS$=”0”+FCS$ ANS$=DA$+FCS$ PRINT ANS$ As seen above, there is a program which is calculated using BASIC instructions in lines 500 to 640 for purposes of comparison. The execution times required by the assembly language functions and BASIC instructions are as follows: Assembly language functions (lines 140 to 220): 29 ms BASIC instructions (lines 540 to 630):...
  • Page 115: A Standard Models

    Appendix A Standard Models Item Description Model No. ASCII Unit EEPROM C500-ASC04 Battery Set Backup battery for C500 only C500-BAT08...
  • Page 116 Appendix B Specifications Item Specifications Communication mode Half duplex Synchronization Start-stop Baud rate Port 1: 300/600/1,200/2,400/4,800/9,600 bps Port 2: 300/600/1,200/2,400/4,800/9,600/19,200 bps (switch selectable) Transmission mode Point-to-point Transmission distance 15 m max. Interface Conforms to RS-232C. Two ports (D-sub 25P connectors) Memory capacity BASIC program area and BASIC data area: 24K bytes (RAM) (memory is protected by built-in battery backup)
  • Page 117 Appendix B Specifications RS-232 Interface The ASCII Unit is connected to peripheral devices through two RS-232C interfaces. To connect peripheral devices to the ASCII Unit, use the included connectors. The following figure shows the RS-232C connectors on the ASCII Unit. The electrical characteristics of these con- nectors conform to the EIA-RS-232C standards.
  • Page 118 Appendix B Specifications Connections to Peripheral Devices ASCII Unit Printer (Shielded cable) ASCII Unit Display Terminal (Shielded cable) ASCII Unit Personal Computer (Shielded cable) ASCII Unit Bar-code Reader (Shielded cable)
  • Page 119 Appendix B Specifications Interface Signal Timing Before using any port after the ASCII Unit is turned on or restarted, Port 1 is assigned to the peripheral device TERM and Port 2 is assigned to LPRT. When there is an input or output at a port, the RTS, STS, DTR, and DSR signals are treated as described below.
  • Page 120 Appendix B Specifications The following timing chart applies when the peripheral devices are SCRN and LPRT when the OPEN instruction is executed. Port 1 Port 2 DTR (output) Always ON Always ON RTS (output) Normally OFF Normally OFF DSR (input) Check Check CTS (input)
  • Page 121 Appendix B Specifications Difference in Output According to Opened Peripheral Device The following table shows the difference in instruction output, such as the PRINT instruction output, among the peripheral devices designated by the OPEN instruction. After RESET, Port 1 is assigned to TERM and Port 2 is assigned to LPRT automatically.
  • Page 122 Appendix B Specifications 3. If the LPRT receives the &H0A (LF), &H0B (HM), &H0C (CL), or &H0D (CR) code. &H0A (LF) will be added to the code and output. Any other code will be stored in the buffer and when the number of charac- ters of the stored codes reaches 80, &H0A (LD) will be added to each of the codes and output.
  • Page 123 Appendix C PC Statements and Refresh Timing Instructions and Refresh Timing Data transfer between the ASCII Unit and the PC is executed during PC I/O refresh. I/O Refresh I/O Refresh Cycle Time C500 CPU Instruction Execution Instruction Execution Data Transfer Data Transfer ASCII Unit Processing in BASIC program...
  • Page 124 Appendix C PC Statements and Refresh Timing PC READ In four-word mode, when the PC’s WRITE flag is set, the base address is transferred. By the next I/O refresh the data is read. I/O Refresh I/O Refresh I/O Refresh I/O Refresh Instruction Execution C500 CPU Instruction Execution...
  • Page 125 Appendix C PC Statements and Refresh Timing ON PC GOSUB After the ON PC GOSUB statement is executed, the PC’s categorized number allocation is written in. When the Write flag is set, the GOSUB statement is executed. Only when the WRITE flag is set will the ON PC GOSUB statement be executed.
  • Page 126 Appendix C PC Statements and Refresh Timing PC STOP After the ON PC GOSUB statement is executed, the PC’s categorized number allocation is written in. When the Write flag is set, the ASCII Unit busy flag is set for one cycle time, but the GOSUB statement is not executed. Only after the PC ON statement is executed will the ON PC GOSUB statement be executed.
  • Page 127 Appendix D Formatting and Data Conversion Format Meaning Name Indicates the nth byte of m decimal words I format Indicates the nth byte of m hexadecimal words H format Indicates the nth byte of m octal words O format Indicates the nth bit of of m binary words B format Indicates the nth byte of m ASCII words A format...
  • Page 128 Appendix D Formatting and Data Conversion m: number of words O: octal format designator n: the nth byte of the word Digit n 15 14 13 12 11 10 Example: 4O2 ... Indicates four octal words of two digits each B Format (mBn) This format is used for binary numbers (0 to 1): m: number of words...
  • Page 129 Appendix D Formatting and Data Conversion Example: 5B14... Indicates five binary words of 14 bits each. A Format (mAn) This format is used for ASCII characters: m: number of words A: ASCII format designator n: the nth byte of the word Digit n 15 14 13 12 11 10 ASCII code...
  • Page 130 Appendix D Formatting and Data Conversion PC READ “ I 1 ” ; J J = 4 PC READ “ I 2 ” ; J J = 3 4 Integer variable PC READ “ I 3 ” ; J J = 2 3 4 PC READ “...
  • Page 131 Appendix D Formatting and Data Conversion Contents of PC word PC READ “ 2 A 1 ” ; A $ A $ = “ R T ” PC READ “ 2 A 2 ” ; A $ A $ = “ Q S ” Character variable PC READ “...
  • Page 132 Appendix D Formatting and Data Conversion H Format Contents of PC word PC WRITE “ H 1 ” ; J PC WRITE “ H 2 ” ; J J = – 3 0 2 9 3 = & H 8 9 A B Integer variable PC WRITE “...
  • Page 133 Appendix D Formatting and Data Conversion B Format Contents of PC word PC WRITE “ B 0 ” ; J PC WRITE “ B 1 ” ; J J = – 3 2 7 4 9 = & H 8 0 1 3 Integer variable PC WRITE “...
  • Page 134 Appendix D Formatting and Data Conversion Execution Times Command Execution Time (ms) µ PC READ “ I 4 ” ; A PC READ “ 5 I 4 ” ; A, B, C, D, E PC READ “ 1 0 I 4 ” ; A, B, C, D, E, G, H, I, J PC READ “...
  • Page 135 Appendix E Memory Map This appendix provides the memory map of the ASCII Unit. Memory Area Base Remarks Address I/O area 1 &H0000 This area is for internal ports of the microprocessor 63B03. System work area &H0020 This area is used by the system. Assembly language program area &H2000 Stores assembly language program.
  • Page 136 Appendix E Memory Map Communication Flags Communication Input Flags ____ ___ ___ ___ ___ ___ Address START $0015 ____ CTS1 DSR2 DSR1 IRQ2 IRQ1 STOP Port for interrupts from ACIA and PTM Port for interrupts from START/STOP switch and PC 0 when START/STOP switch is ON Normally 1 1 when battery voltage drops...
  • Page 137 Appendix E Memory Map Devices Address Contents System Remarks Default Value $9800 None Control registers #1 and #3 Writes to #3 $9801 Status register None Control register #2 $9802 Higher byte of timer #1 counter None Higher byte (MSB) of buffer register None $9803 Lower byte (LSB) of buffer register...
  • Page 138 Appendix E Memory Map Address Contents $0145 Port 1 Port storage pointer (reception) $0146 Data extraction pointer (reception) $0147 Data storage pointer (transfer) $0148 Reception buffer, 256 bytes $024B Port 2 Data storage pointer (reception) $024C Data extraction pointer (reception) $024D Data storage pointer (transfer) $024E...
  • Page 139 Appendix F Troubleshooting Error Message Format When an error occurs during BASIC program execution, the error messages shown in the following tables are output to the screen of the terminal. If a device other than a terminal is connected to port 1, the program stops, and the messages are reserved until the terminal is attached and CTRL+X is keyed in.
  • Page 140 Appendix F Troubleshooting Error Message Error Explanation Code PROM ERROR EEPROM is malfunctioning, or nothing is written in the EEPROM. PROTECTED PROGRAM ERROR Program is protected. To change program, delete name with PNAME command. RESUME WITHOUT ERROR RESUME statement is executed when no error exists. RETURN WITHOUT GOSUB ERROR RETURN statement is encountered before execution of GOSUB statement.
  • Page 141 4. Replace the battery storage cover. Notes on Handling Turning off the power to the PC before replacing the ASCII Unit. When returning a defective unit to OMRON, inform us of the abnormal symptoms in as much detail as possible.
  • Page 142 Appendix G BASIC Commands, Statements, and Functions The following tables list the BASIC commands, statements, and functions alphabetically. The characters in the Command, Statement, and, Function columns denote the following: Gen: General statement Char: Character String function Dev: Device Control statement Spec: Special function Arith: Arithmetic Operation function Comm: Command...
  • Page 143 Appendix G BASIC Commands, Statements, and Functions Item Description Command Statement Function Page ERL/ERR Returns the error code and the line number where Spec the error has occurred ERROR Simulates an error and allows error codes to be defined Returns the integer part of a number Arith FOR...TO...
  • Page 144 Appendix G BASIC Commands, Statements, and Functions Item Description Command Statement Function Page ON KEY GOTO Causes branching to the specified line when the 43, 43 ON KEY specified key is input GOSUB ON PC GOSUB Defines an interrupt number and its associated subroutine branch line number OPEN Opens a port...
  • Page 145 Appendix G BASIC Commands, Statements, and Functions Item Description Command Statement Function Page Converts a character string into a numeric value Char VERIFY Verifies the program and the EEPROM contents Comm VARPTR Returns the memory address where the variable is Spec stored WAIT...
  • Page 146 Appendix G BASIC Commands, Statements, and Functions Assembly Language Example Example Description Page Classification of characters Use of more than one parameter FCS calculation...
  • Page 147 Glossary accumulator register The arithmetic hardware register of the microprocessor. ASCII Unit program The BASIC program that runs the ASCII Unit and communicates with the PC program. Backplane A rack of hardware slots sharing a common bus line to which the CPU and all of its I/O Units are connected.
  • Page 148 Glossary automatic, the boot program will be loaded to the RAM from the EPROM upon power up or reset. Programs can be read from and written to the EPROM with the LOAD and SAVE commands, respectively. execution sequence The order of operation in which the PC and ASCII Unit hardware execute their respective programs.
  • Page 149 Glossary tion or format, or supplies a memory address where data can be stored. Similar to a parameter and sometimes used interchangeably is the term “argument”. Where a parameter usually supplies some type of control information to the function or command, an argument is usually a variable that supplies needed data.
  • Page 150 Glossary watchdog timer A clock on the PC that measures the time it takes the PC program to complete one cycle. If the cycle time is longer than 100 ms, a warning is issued. If the cycle time is longer than 130 ms, the PC will suspend operation. The watchdog timer is reset at the beginning of each cycle.
  • Page 151 Index format, functions, operator priority, applications, precautions, operators, statements, ASCII Unit general, internal configuration, type conversion, system configuration, variables, Assembly language BASIC program Accumulator, execution, base address, storage, DEF USR statement, transfer, format, battery case, Index register, LOAD command, battery life, monitor commands baud rate, Compare,...
  • Page 152 Index DIP switches personal computer, communication settings, back panel, physical dimensions, front panel, port address assignments, ports, F–M precautions, applications, front panel operating environment, contains . . ., safety, DIP switch diagram, program transfer, DIP switch settings, Indicator LEDs, refresh timing Indicator LEDs, BASIC statements, ON PC GOSUB statement,...
  • Page 153 Revision History A manual revision code appears as a suffix to the catalog number on the front cover of the manual. Cat. No. W186-E1-4 Revision code The following table outlines the changes made to the manual during each revision. Page numbers refer to the previous version.
  • Page 154 Revision History Revision code Date Revised content July 1996 Section of precautions added before section 1 and adjustments made to signal words for precautions. Scan time changed to cycle time throughout the manual. Page 3: Extra indication for T/R added to the table. Note added. Page 7: Reference changed.

Table of Contents