30i/300i/300is - Model A Users manual Page 737

Users manual
Event Function
-----------------------+------------------------------
Time os_sync_tim(), os_wait_tim()
Event flag os_wait_flg()
Semaphore os_wait_sem()
Status of serial port rs_wait()
This type of task management is called "event driven" task management.
+-------------------+ +-----
auxiliary task ----+ (run) +- (wait for event)-+
+------------------+
main task - - - - - (wait) - - - - -+ (run) + - -
^ ^
system start Event happens
5.1.4 Data access between tasks
To exchange data between tasks, the inter-task common variable is to be used.
The variables defined in the special source files, dramver.c and sramver.c, are
located in the inter-task common memory as the common variables.
When defining the common variables in the files, dramver.c or sramver.c,
specify the attribute "volatile" for the variables in the definition statement.
Memory address space
+--------------------------------+
│ common variable (sramver.c) │
│ │---+
+--------------------------------+ │
│ common variable(dramver.c) │
+---------------------------------+
v ^ v ^ v ^
+----------+ +----------+ +----------+
│ │ │ │ │ │
│ Main │ │ Alarm │ │Communica-│
│ task │ │ task │ │tion task │
│ │ │ │ │ │ +-----------------+
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
+----------+ +----------+ +----------+ │ │
v ^ v ^ v ^ │ CNC control │
+------------------------------------+ │ software │
│ C Executor library(interface) │ │ │
+------------------------------------+ │ │
v ^ │ │
+------------------------------------+ │ │
│ C Executor library(kernel) │ -> │ │
│ │ <- │ │
+------------------------------------+ +-----------------+
Data cannot be accessed between memory address spaces which are not
connected by arrows in above figure.

Contents Summary of 30i/300i/300is - Model A Users manual

  • Page 1C Language Executor OPERATOR’S MANUAL B-63944EN-3/01
  • Page 2• No part of this manual may be reproduced in any form. • All specifications and designs are subject to change without notice. The export of this product is subject to the authorization of the government of the country from where the product is exported. In this manual we have tried as much as possi
  • Page 3Introduction This is a description of C Executor function specification for following FANUC CNC. Applied CNC ------------------------------------------------------ MODEL Abbreviated name ------------------------------------------------------ FANUC Series 30i-MODEL A 30i-A or Series 30i Notes - It is
  • Page 4
  • Page 5B-63944EN-3/01 TABLE OF CONTENTS TABLE OF CONTENTS I. SPECIFICATION ...................................................................... 1 1. Overview ...............................................................................................3 1.1 Feature ......................................
  • Page 6TABLE OF CONTENTS B-63944EN-3/01 2.6 Using compiler libraries................................................................................66 2.7 Describing 2-byte characters in source-codes .............................................66 2.8 Remarks ...............................................
  • Page 7B-63944EN-3/01 TABLE OF CONTENTS 5.6 Conforming O8-digits program number .....................................................744 5.7 Window task ..............................................................................................745 5.7.1 Overview..........................................
  • Page 8
  • Page 9I. SPECIFICATIO
  • Page 10
  • Page 111. Overview FANUC Series 30i C Executor enables to add the Machine Tool Builder's original screen into FANUC Series 30i and to customize screen displaying and operation interface of CNC software. It is possible to replace arbitrary screens of CNC with user application's screen. The user application
  • Page 121.1 Feature (1) Low-cost customization No addtional hardware is required to use C Executor and application program on FANUC Series 30i. (*) The user application program can be built in your Series 30i as it is. (*) It may be necessary to increase flash ROM or DRAM capacity. (2) Application program d
  • Page 13(6) Using with Macro Executor C Executor can be used with Macro Executor (Execution Macro and also Conversational Macro) of Series 30i-A. The screen displaying part of macro program which has been developed by the Machine Tool Builder can be replaced with C program, therefore, existing software prop
  • Page 142. System components The system components that C Executor and the user application program are shown below. +--------------------------------+ +----+ +-------------+ │ │ │ <- │ │ │ User │ │ │ CNC window │ -> │ │ <- │ application │ │ │ │ *3 │ │ -> │ program │ │ CNC software │---------------│ │ │ *1
  • Page 152.2 C library C library provides following functions. (1) Input/output between peripheral equipments (LCD and MDI key) C library executes input/output operations, which are called by the user application program, such as character displaying to screen by "printf" function, reading MDI key by "getch"
  • Page 162.3 Application program (1) Program structure Application program consists of three independent tasks. +- USER APPLICATION -------------------------+ │ +========================================+ │ │ │ │ │ │ │ (A)MAIN TASK │ │ │ │ │ │ │ +========================================+ │ │ +- AUXILIARY TASK
  • Page 17(*1) The same file cannot be accessed by two or more tasks simulta- neously. It is necessary to control exclusively in application program. (*2) Simultaneous access with MAIN TASK causes BUSY ERROR. (*3) It is necessary to control communication port and F-ROM reading exclusively by the application p
  • Page 18(3) Example of application program For example, the program which consists of only Main task has following structures. ++---------------++ ││ main function ││ ++-------+-------++ │ +----------+----------+ │ Initialization │ +----------+----------+ │ +----------+----------+ │ Setting of user │ │ scre
  • Page 192.4 The hardwares of CNC which are used in C Executor ITEM SPECIFICATION REMARKS ======================================================================== CPU PowerPC compatible processor It is common with CNC software. ------------------------------------------------------------------------ DRAM MAX
  • Page 20ITEM SPECIFICATION REMARKS ======================================================================== DISPLAY DEVICE 10.4-inch color LCD (*2) 10.4-inch color LCD with touch-panel (*2) - Alphanumeric character (80x25(*3)) - Kanji character (40x25(*3)) - 16-grayscale, reverse, blink, background color, f
  • Page 21ITEM SPECIFICATION REMARKS ======================================================================== WINDOW DISPLAY - Max 8 windows on user screen (overlapping only character) - Max 2 windows on arbitrary screen (overlapping both character and graphics) (*4) ------------------------------------------
  • Page 223. Application program development environment Application program of C Executor is developed by the Machine Tool Builder. - General PC(personal computer) is used to develop (edit and compile) appli- cation program. - Only execution of application program is possible on CNC unit. - Debugging of appl
  • Page 23Software of the Machine Tool Builder +----------+ │ │ │ │ │ +------+ │ ----+ │ │ │ │ │ │ │ │ │ │ +----------+ +-+------+-+ │ │ │ │ │ │ +--- ( LINK ) ---> │ +------+ │ FANUC library │ │ │ │ │ +----------+ │ │ │ │ │ │ │ │ +-+------+-+ │ │ │ │ │ +------+ │ ----+ │ │ │ │ │ │ │ │ │ │ │ +-+------+-+ │ v +
  • Page 243.2 Development procedure The development procedure of software for C Executor is as follows. +---------------+ --+ │ SPECIFICATION │ │ │ DESIGN │ │ +-------+-------+ │ │ │ +-------+-------+ │ │ FUNCTION │ │ │ DESIGN │ │ +-------+-------+ │ │ │ +-------+-------+ │ │ PROGRAMIMIG │ │ │ CODING, │ +-- w
  • Page 25(3) Completing program for C Executor After module level testing on PC, you develop entire application with FANUC library. If any error occured in this step, you confirm usage of C language library. You use makefile which is provided from FANUC to compile, link and make memory card file. (4) Install
  • Page 264. C language library function list 4.1 ANSI C standard library The following ANSI C language standard functions are provided. (1) Diagnostics assert (2) Character handling isalnum islower isxdigit isalpha isprint tolower iscntrl ispunct toupper isdigit isspace isgraph isupper (3) Non-local jumps se
  • Page 27(5) Input/output remove sscanf ungetc rename vfprintf fread tmpnam vprintf fwrite fclose vsprintf fgetpos fflush fgetc fseek fopen fgets fsetpos freopen fputc ftell setbuf fputs rewind setvbuf getc clearerr fprintf getchar feof fscanf gets ferror printf putc perror scanf putchar sprintf puts (6) Gen
  • Page 28(9) Mathematics acos fabs pow asin floor sin atan fmod sinh atan2 frexp sqrt ceil ldexp tan cos log tanh cosh log10 exp modf
  • Page 294.2 MS-C extended C standard library The following MS-C extended functions are provided. _chdrive _fstrpbrk kbhit _dos_findfirst _fstrrchr lseek _dos_findnext _fstrrev ltoa _dos_getdiskfree _fstrset memicmp _expand _fstrspn mkdir _fcalloc _fstrstr open _fexpand _fstrtok read _ffree _fstrupr rmdir _f
  • Page 304.3 Graphic library (1) MS-C compatible graphic functions The following MS-C graphic functions are provided. However, some detail specifications of functions may be different between PC and CNC because both hardwares are not compatible completely. _arc _getvideoconfig _setbkcolor _clearscreen _getvi
  • Page 31(2) Original graphic functions These functions are C Executor original graphic functions. NAME FUCNTION -------------------------------------------------------------------------- gr_displaychar Draw a standard size character gr_displayfourlarge Draw a quad size character gr_displaysixlarge Draw a he
  • Page 324.4 CNC/PMC window library The following functions which are used to input/output data between CNC /PMC are provided. (1) CNC window NAME FUCNTION -------------------------------------------------------------------------- cnc_sysinfo Read CNC system information cnc_dwnstart Start output of NC progra
  • Page 33NAME FUNCTION -------------------------------------------------------------------------- cnc_rdparam Read parameter cnc_wrparam Write parameter cnc_rdparar Read parameters (range specified) cnc_wrparas Write parameters (multiple output) cnc_rdset Read setting parameter cnc_wrset Write setting parame
  • Page 344.5 Other libraries (1) MDI operation library These funcitons are used to control key input from CNC's MDI panel. NAME FUNCTION -------------------------------------------------------------------------- aux_mdi_getmatrix Get MDI key matrix aux_mdi_putmatrix Put MDI key matrix aux_mdi_rstmatrix Reset
  • Page 35NAME FUNCTION -------------------------------------------------------------------------- crt_getcncpalette Get color palette of CNC screen crt_fstr Output character string by FANUC character code. crt_gettextimg Get text data from VRAM. crt_puttextimg Put text data into VRAM. crt_setgraphpage Select
  • Page 36(4) Serial communication library These functions are used to communicate with peripherals via reader/ puncher interface(RS-232C). NAME FUNCTION -------------------------------------------------------------------------- rs_open Initialize communication device rs_close Terminate communication rs_putc
  • Page 37(6) FCA library These are the functions which communicate with FCA (FANUC CASSETTE ADAPTOR) or FANUC Handy File. NAME FUNCTION -------------------------------------------------------------------------- fca_setparam Initialize communication line fca_bye Close communication line fca_open Open a binary
  • Page 38
  • Page 39II. PROGRAMMIN
  • Page 40
  • Page 41- This manual is intended to explain the C executor for the FANUC Series 30i. - Do not use the manual for any purpose other than creation of applications for the FS30i C executor. - Some descriptions in the manual include JIS ruled lines and half-size katakana characters. If your PC environment cann
  • Page 42Description of CNC name, etc. C Executor works on the following CNC equipments. FS30i In this document, the CNC names are described as the following abbreviated names. Abbreviation CNC -----------------------+-------------------------------------------- FANUC Series 30i The generic name of all FS30i
  • Page 430. INDEX Filename Contents ---------------+---------------------------------------------------- 00index.man 0. INDEX 01soft.man 0.1 Required software for application development 10functn.man 1. List of Functions 20mkapp.man 2. How to make application program 30fref.man 3. Function References 31ansi_
  • Page 44Update history 2003. 4. 1 1st edition.
  • Page 450.1 Required software for application development ================================================= The following softwares are required for development of the C Executor application program. Please purchase each package softwares on the market by yourself. (1) C Compiler. Use the WindRiver Diab C/C
  • Page 461. List of Functions ==================== (abbreviation) CExe : C Executor ANSI : American National Standards Institute MS-C : Microsoft Corp. MS-C Ver 6.0, Ver 7.0 or Ver 8.0 (mark) x : available blank : not available M : available only on Main task MA : available on Main task and Alarm task MAC :
  • Page 47(4) Mathematics ( math.h ) ----------------------------------- ----------------------------------- Name CExe ANSI MS-C Name CExe ANSI MS-C -------------------+----+----+----- -------------------+----+----+----- acos MAC x x frexp MAC x x asin MAC x x ldexp MAC x x atan MAC x x log MAC x x atan2 MAC
  • Page 48(8) Input/output ( stdio.h ) ----------------------------------- ----------------------------------- Name CExe ANSI MS-C Name CExe ANSI MS-C -------------------+----+----+----- -------------------+----+----+----- remove MAC x x fputc MAC x x rename MAC x x fputs MAC x x tmpfile x x getc M x x tmpnam
  • Page 49(10) String handling ( string.h ) ----------------------------------- ----------------------------------- Name CExe ANSI MS-C Name CExe ANSI MS-C -------------------+----+----+----- -------------------+----+----+----- memcpy MAC x x memchr MAC x x memmove MAC x x strchr MAC x x strcpy MAC x x strcsp
  • Page 501.2 MS-C extended C standard library Compatible functions with extended library of Microsoft C Compiler (MS-C Ver 6.0). ----------------------------------- ----------------------------------- Name CExe ANSI MS-C Name CExe ANSI MS-C -------------------+----+----+----- -------------------+----+----+--
  • Page 51----------------------------------- ----------------------------------- Name CExe ANSI MS-C Name CExe ANSI MS-C -------------------+----+----+----- -------------------+----+----+----- _fstrchr MAC x _nmsize x _fstrcmp MAC x _nrealloc x _fstrcpy MAC x _nstrdup x _fstrcspn MAC x _pclose x _fstrdup x _
  • Page 52----------------------------------- ----------------------------------- Name CExe ANSI MS-C Name CExe ANSI MS-C -------------------+----+----+----- -------------------+----+----+----- eof MAC x iskana MAC x execl x iskanji MAC x execle x iskanji2 MAC x execlp x iskmoji MAC x execlpe x iskpun MAC x e
  • Page 53----------------------------------- ----------------------------------- Name CExe ANSI MS-C Name CExe ANSI MS-C -------------------+----+----+----- -------------------+----+----+----- jtoupper MAC x spawnlpe x kbhit M x spawnv x ldexpl x spawnve x lfind x spawnvp x locking x spawnvpe x logl x sqrtl
  • Page 541.3 Graphic library (1) MS-C compatible graphic functions Compatible functions with a part of graphic library of Microsoft C Compiler (MS-C Ver 6.0). --------------------------------------------------------------------------- Name CExe Function ---------------------+----+----------------------------
  • Page 55--------------------------------------------------------------------------- Name CExe Function ---------------------+----+------------------------------------------------ _setgtextvector M Set the current output vector of text. _setlinestyle M Set the current line style. _setpixel M Draw a pixel. _s
  • Page 561.4 CNC/PMC window library Functions whish are used to input/output data between CNC/PMC. (1) CNC window library --------------------------------------------------------------------------- Name CExe Function ---------------------+----+------------------------------------------------ cnc_sysinfo MA R
  • Page 57--------------------------------------------------------------------------- Name CExe Function ---------------------+----+------------------------------------------------ cnc_wrzofsr MA Write work origin offset (range specified). cnc_rdparam MA Read parameter. cnc_wrparam MA Write parameter. cnc_rdp
  • Page 58--------------------------------------------------------------------------- Name CExe Function ---------------------+----+------------------------------------------------ cnc_settime MA Set calendar timer of CNC. cnc_rdspload MA Read load information of serial spindle. cnc_rdexecprog MA Read executi
  • Page 591.5 Other libraries (1) MDI operation library These are the functions which customize key-input from MDI panel, alter key code, enable key repeating and generate key code by the application program. --------------------------------------------------------------------------- Name CExe Function ------
  • Page 60(2) CRT operation library These are the functions which control CRT display and multiple window display. --------------------------------------------------------------------------- Name CExe Function ---------------------+----+------------------------------------------------ crt_getcurscrn MA Get cu
  • Page 61--------------------------------------------------------------------------- Name CExe Function ---------------------+----+------------------------------------------------ vwin_show M Show VGA window. vwin_hide M Hide VGA window. vwin_info M Get VGA window information. -------------------------------
  • Page 62(3) File operation library These are the functions which maintain file device. --------------------------------------------------------------------------- Name CExe Function ---------------------+----+------------------------------------------------ aux_file_format M Format specified drive. aux_file
  • Page 63(5) Task control library These are the functions which control task execution. --------------------------------------------------------------------------- Name CExe Function ---------------------+----+------------------------------------------------ os_show_tim MAC Read timer. os_set_tim MAC Set tim
  • Page 64(7) F-ROM library These are the functions which read C Executor data stored in the flash ROM module. --------------------------------------------------------------------------- Name CExe Function ---------------------+----+------------------------------------------------ aux_from_open MAC Open the s
  • Page 65Japanese(Multi-byte character) functions Jananese character/string functions (Multi-byte character functions) included in "MS-C extended C standard library" are not available for Series 30i C Executor. Functions not available on FANUC Series 30i (FS30i) C Executor The following functions are availab
  • Page 66CNC window library cnc_windowma() : Call CNC window. CNC window library for punch-press cnc_rd1punchtl() : Read punch-press tool data. (by registration number) cnc_rd2punchtl() : Read punch-press tool data. (by tool number) cnc_wrpunchtl() : Write punch-press tool data. Serial Library rs_dma() : Sel
  • Page 672. How to make application program ================================== Table of contents 2.1 Outline 2.2 Special files 2.3 MAKEFILE 2.4 Installing the Diab C/C++ Power-PC compiler 2.5 Compatibility related to variables of type 'int' 2.6 Using compiler libraries 2.7 Describing 2-byte characters in sou
  • Page 68(3) Editing the source files. Make the source files ( *.c and *.h files ) of the application program in the working directory. Use an arbitrary text editor to edit the files. You may name the file as you like. Here, we assume that the following source files are made. Main task main.c sub1.c sub2.c A
  • Page 69#------------------------------------------------------------------------------ # .O and .C dependency block. #------------------------------------------------------------------------------ main.o : main.c prog1.h sub1.o : sub1.c prog1.h sub2.o : sub2.c prog1.h comm.o : comm.c prog1.h alarm.o : alar
  • Page 702.2 Special files The following files are special files, whose usage is reserved. VERSION.C : Definition file of the user application's version number. (must be required) The user application's version number is defined in this file. For example, version number definition is as follows. char version
  • Page 712.3 MAKEFILE Modify two blocks in MAKEFILE. (1) Task definition block #------------------------------------------------------------------------------ # Task definition block. Modify here for your application. #------------------------------------------------------------------------------ TASK1 = TAS
  • Page 72(2) Dependency block #------------------------------------------------------------------------------ # .O and .C dependency block. #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # End of
  • Page 732.4 Installing the Diab C/C++ Power-PC compiler How to install the Diab C/C++ Power-PC compiler is described below by taking its version 4.3f as an example. Refer to the applicable compiler reference manual for detailed descriptions about individual items. Inserting the Diab C/C++ Power-PC compiler
  • Page 74Note) You may need to set up License Manager (FLEXlm License Manager) depending on the license form. For details, ask the store from which you bought your compiler. 2.5 Compatibility related to variables of type 'int' For the compiler used with the FS30i C Executor, variables of type 'int' are 4-byt
  • Page 752.8 Remarks C Executor uses the different include files from the compiler's default. So, the object files made for the personal computer debugging cannot be used for execution on CNC. Recompile using include files for C Executor. (The include directory is switched by the macro CC in MAKEFILE) Do not
  • Page 763. Function References ====================== The function specifications that C library provides with are described in this function reference with following format. [Example] > ---------------------------------------------------------------------------- > 1. Format specified drive.
    > ------
  • Page 77"[Arguments]" shows meanings of all arguments. "[Return]" shows all possible return values and their types and meanings. "[Description]" shows behavior of this function, concrete values to be specified in arguments and some notices, etc.
  • Page 783.1 ANSI C standard library =========================== Lists of Functions 1. Diagnostics ( assert.h ) -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1.1 assert Abort by assertion. --
  • Page 793. Mathematics ( math.h ) -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 3.1 acos Calculate the arc cosine value. 3.2 asin Calculate the arc sine value. 3.3 atan Calculate the arc tan
  • Page 806. Input/output ( stdio.h ) -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 6.1 remove Delete a file. 6.2 rename Change the name of a file. 6.3 tmpnam Generate a temporary file name. 6
  • Page 817. General utilities ( stdlib.h ) -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 7.1 atoi Convert string to int value. 7.2 atol Convert string to long value. 7.3 strtol Convert string
  • Page 829. Date and time ( time.h ) -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 9.1 clock Get the current time. 9.2 mktime Convert local time to calender time. 9.3 time Get the current tim
  • Page 83Function Reference Refer ANSI C language regulation for detail function specifications. 1. Diagnostics ( assert.h ) ------------------------------------------------------------------------------ 1.1 Abort by assertion.
    --------------------------------------------------------------------------
  • Page 842. Character handling ( ctype.h ) ------------------------------------------------------------------------------ 2.1 Test for alphanumeric character. ------------------------------------------------------------------------------ [Name] isalnum [Syntax] #include int isalnu
  • Page 85------------------------------------------------------------------------------ 2.2 Test for alphabetic character. ------------------------------------------------------------------------------ [Name] isalpha [Syntax] #include int isalpha( int c ) ; [Arguments] c Character
  • Page 86------------------------------------------------------------------------------ 2.3 Test for control character. ------------------------------------------------------------------------------ [Name] iscntrl [Syntax] #include int iscntrl( int c ) ; [Arguments] c Character co
  • Page 87------------------------------------------------------------------------------ 2.4 Test for numeric character. ------------------------------------------------------------------------------ [Name] isdigit [Syntax] #include int isdigit( int c ) ; [Arguments] c Character co
  • Page 88------------------------------------------------------------------------------ 2.5 Test for visible character. ------------------------------------------------------------------------------ [Name] isgraph [Syntax] #include int isgraph( int c ) ; [Arguments] c Character co
  • Page 89------------------------------------------------------------------------------ 2.6 Test for lowercase alphabetic character. ------------------------------------------------------------------------------ [Name] islower [Syntax] #include int islower( int c ) ; [Arguments] c
  • Page 90------------------------------------------------------------------------------ 2.7 Test for printable character. ------------------------------------------------------------------------------ [Name] isprint [Syntax] #include int isprint( int c ) ; [Arguments] c Character
  • Page 91------------------------------------------------------------------------------ 2.8 Test for punctuation character. ------------------------------------------------------------------------------ [Name] ispunct [Syntax] #include int ispunct( int c ) ; [Arguments] c Characte
  • Page 92------------------------------------------------------------------------------ 2.9 Test for whitespace character. ------------------------------------------------------------------------------ [Name] isspace [Syntax] #include int isspace( int c ) ; [Arguments] c Character
  • Page 93------------------------------------------------------------------------------ 2.10 Test for uppercase alphabetic character. ------------------------------------------------------------------------------ [Name] isupper [Syntax] #include int isupper( int c ) ; [Arguments]
  • Page 94------------------------------------------------------------------------------ 2.11 Test for hexadecimal numeric character. ------------------------------------------------------------------------------ [Name] isxdigit [Syntax] #include int isxdigit( int c ) ; [Arguments]
  • Page 95------------------------------------------------------------------------------ 2.12 Convert uppercase to lowercase. ------------------------------------------------------------------------------ [Name] tolower [Syntax] #include int tolower( int c ) ; [Arguments] c Charact
  • Page 96------------------------------------------------------------------------------ 2.13 Convert lowercase to uppercase. ------------------------------------------------------------------------------ [Name] toupper [Syntax] #include int toupper( int c ) ; [Arguments] c Charact
  • Page 973. Mathematics ( math.h ) ------------------------------------------------------------------------------ 3.1 Calculate the arc cosine value. ------------------------------------------------------------------------------ [Name] acos [Syntax] #include double acos( double x )
  • Page 98------------------------------------------------------------------------------ 3.2 Calculate the arc sine value. ------------------------------------------------------------------------------ [Name] asin [Syntax] #include double asin( double x ) ; [Arguments] x A floating
  • Page 99------------------------------------------------------------------------------ 3.3 Calculate the arc tangent value. ------------------------------------------------------------------------------ [Name] atan [Syntax] #include double atan( double x ) ; [Arguments] x A floati
  • Page 100------------------------------------------------------------------------------ 3.4 Calculate the arc tangent value. ------------------------------------------------------------------------------ [Name] atan2 [Syntax] #include double atan2( double y, double x ) ; [Arguments
  • Page 101------------------------------------------------------------------------------ 3.5 Calculate the smallest integer value. ------------------------------------------------------------------------------ [Name] ceil [Syntax] #include double ceil( double x ) ; [Arguments] x A f
  • Page 102------------------------------------------------------------------------------ 3.6 Calculate the cosine value. ------------------------------------------------------------------------------ [Name] cos [Syntax] #include double cos( double x ) ; [Arguments] x A floating poin
  • Page 103------------------------------------------------------------------------------ 3.7 Calculate the hyperbolic cosine value. ------------------------------------------------------------------------------ [Name] cosh [Syntax] #include double cosh( double x ) ; [Arguments] x A
  • Page 104------------------------------------------------------------------------------ 3.8 Calculate the exponential function. ------------------------------------------------------------------------------ [Name] exp [Syntax] #include double exp( double x ) ; [Arguments] x A float
  • Page 105------------------------------------------------------------------------------ 3.9 Calculate the absolute value. ------------------------------------------------------------------------------ [Name] fabs [Syntax] #include double fabs( double x ) ; [Arguments] x A floating
  • Page 106------------------------------------------------------------------------------ 3.10 Calculate the largest integer value. ------------------------------------------------------------------------------ [Name] floor [Syntax] #include double floor( double x ) ; [Arguments] x A
  • Page 107------------------------------------------------------------------------------ 3.11 Calculate the floating point remainder value. ------------------------------------------------------------------------------ [Name] fmod [Syntax] #include double fmod( double x, double y )
  • Page 108------------------------------------------------------------------------------ 3.12 Calculate the mantissa value. ------------------------------------------------------------------------------ [Name] frexp [Syntax] #include double frexp( double value, int *exp ) ; [Argumen
  • Page 109------------------------------------------------------------------------------ 3.13 Calculate the value multiplied by the power of 2. ------------------------------------------------------------------------------ [Name] ldexp [Syntax] #include double ldexp( double x, int e
  • Page 110------------------------------------------------------------------------------ 3.14 Calculate the natural (base-e) logarithm value. ------------------------------------------------------------------------------ [Name] log [Syntax] #include double log( double x ) ; [Argumen
  • Page 111------------------------------------------------------------------------------ 3.15 Calculate the base-10 logarithm value. ------------------------------------------------------------------------------ [Name] log10 [Syntax] #include double log10( double x ) ; [Arguments] x
  • Page 112------------------------------------------------------------------------------ 3.16 Get the fractional part and the integer part. ------------------------------------------------------------------------------ [Name] modf [Syntax] #include double modf( double value, double
  • Page 113------------------------------------------------------------------------------ 3.17 Calculate the raised value. ------------------------------------------------------------------------------ [Name] pow [Syntax] #include double pow( double x, double y ) ; [Arguments] x A fl
  • Page 114------------------------------------------------------------------------------ 3.18 Calculate the sine value. ------------------------------------------------------------------------------ [Name] sin [Syntax] #include double sin( double x ) ; [Arguments] x A floating point
  • Page 115------------------------------------------------------------------------------ 3.19 Calculate the hyperbolic sine value. ------------------------------------------------------------------------------ [Name] sinh [Syntax] #include double sinh( double x ) ; [Arguments] x A f
  • Page 116------------------------------------------------------------------------------ 3.20 Calculate the square root value. ------------------------------------------------------------------------------ [Name] sqrt [Syntax] #include double sqrt( double x ) ; [Arguments] x A float
  • Page 117------------------------------------------------------------------------------ 3.21 Calculate the tangent value. ------------------------------------------------------------------------------ [Name] tan [Syntax] #include double tan( double x ) ; [Arguments] x A floating po
  • Page 118------------------------------------------------------------------------------ 3.22 Calculate the hyperbolic tangent value. ------------------------------------------------------------------------------ [Name] tanh [Syntax] #include double tanh( double x ) ; [Arguments] x
  • Page 1194. Non-local jumps ( setjmp.h ) ------------------------------------------------------------------------------ 4.1 Save current environment for non-local jump. ------------------------------------------------------------------------------ [Name] setjmp [Syntax] #include
  • Page 120------------------------------------------------------------------------------ 4.2 Execute a non-local jump. ------------------------------------------------------------------------------ [Name] longjmp [Syntax] #include void longjmp( jmp_buf env, int value ) ; [Argument
  • Page 1215. Variable arguments ( stdarg.h ) ------------------------------------------------------------------------------ 5.1 Initialize arg_ptr. ------------------------------------------------------------------------------ [Name] va_start [Syntax] #include void va_start( va_li
  • Page 122------------------------------------------------------------------------------ 5.2 Get a next argument. ------------------------------------------------------------------------------ [Name] va_arg [Syntax] #include type va_arg( va_list arg_ptr, type ) ; [Arguments] arg_p
  • Page 123------------------------------------------------------------------------------ 5.3 Reset arg_ptr. ------------------------------------------------------------------------------ [Name] va_end [Syntax] #include void va_end( va_list arg_ptr ) ; [Arguments] arg_ptr Pointer t
  • Page 1246. Input/output ( stdio.h ) ------------------------------------------------------------------------------ 6.1 Delete a file. ------------------------------------------------------------------------------ [Name] remove [Syntax] #include int remove( const char *path ) ; [A
  • Page 125------------------------------------------------------------------------------ 6.2 Change the name of a file. ------------------------------------------------------------------------------ [Name] rename [Syntax] #include int rename( const char *oldname, const char *newnam
  • Page 126------------------------------------------------------------------------------ 6.3 Generate a temporary file name. ------------------------------------------------------------------------------ [Name] tmpnam [Syntax] #include char *tmpnam( char *string ) ; [Arguments] str
  • Page 127------------------------------------------------------------------------------ 6.4 Close a stream. ------------------------------------------------------------------------------ [Name] fclose [Syntax] #include int fclose( FILE *stream ) ; [Arguments] stream Pointer to a F
  • Page 128------------------------------------------------------------------------------ 6.5 Flush a stream buffer. ------------------------------------------------------------------------------ [Name] fflush [Syntax] #include int fflush( FILE *stream ) ; [Arguments] stream Pointer
  • Page 129------------------------------------------------------------------------------ 6.6 Open a stream. ------------------------------------------------------------------------------ [Name] fopen [Syntax] #include FILE *fopen( const char *filename, const char *mode ) ; [Argumen
  • Page 130------------------------------------------------------------------------------ 6.7 Re-open a same stream. ------------------------------------------------------------------------------ [Name] freopen [Syntax] #include FILE *freopen( const char *filename, const char *mode,
  • Page 131Addtionally, the following open mode can also be specified as additional character in the above list. Mode Meaning -----------+----------------------------------------------------- t Opens the file in text mode.(default) In this mode, line feed characters are converted as follows. Input CR+LF --> LF
  • Page 132------------------------------------------------------------------------------ 6.8 Set a buffer for stream. ------------------------------------------------------------------------------ [Name] setbuf [Syntax] #include void setbuf( FILE *stream, char *buffer ) ; [Argument
  • Page 133------------------------------------------------------------------------------ 6.9 Control a buffer for stream. ------------------------------------------------------------------------------ [Name] setvbuf [Syntax] #include int setvbuf( FILE *stream, char *buffer, int mod
  • Page 134------------------------------------------------------------------------------ 6.10 Print formatted data to a stream. ------------------------------------------------------------------------------ [Name] fprintf [Syntax] #include int fprintf( FILE *stream, const char *for
  • Page 135------------------------------------------------------------------------------ 6.11 Read formatted data from a stream. ------------------------------------------------------------------------------ [Name] fscanf [Syntax] #include int fscanf( FILE *stream, const char *form
  • Page 136------------------------------------------------------------------------------ 6.12 Print formatted data to standard output.
    ------------------------------------------------------------------------------ [Name] printf [Syntax] #include int printf( const char *format [, argument]...
  • Page 1371) Format specification format. % [flags] [width] [.precision] [{h│l│L}] type type : Type of argument, character, strings or numeric value. flags : Justification, sign, space, decimal point, prefix of octal/hexadecimal number. width : Minimum width of output column. precision : Maximum number of cha
  • Page 138------------------------------------------------------------------------------ 6.13 Read formatted data from standard input.
    ------------------------------------------------------------------------------ [Name] scanf [Syntax] #include int scanf( const char *format [, argument]... )
  • Page 1391) Format specification format % [*] [width] [{h│l}] type type : Type of input argument, character, strings or numeric value. width : Maximum number of characters input from standard input. (positive decimal number) More characters than "width" are not converted, and not stored in the argument. When
  • Page 140------------------------------------------------------------------------------ 6.14 Print formatted data to memory. ------------------------------------------------------------------------------ [Name] sprintf [Syntax] #include int sprintf( char *buffer, const char *forma
  • Page 141------------------------------------------------------------------------------ 6.15 Read formatted data from memory. ------------------------------------------------------------------------------ [Name] sscanf [Syntax] #include int sscanf( const char *buffer, const char *
  • Page 142------------------------------------------------------------------------------ 6.16 Print formatted data to a file using variable arguments. ------------------------------------------------------------------------------ [Name] vfprintf [Syntax] #include #include
  • Page 143------------------------------------------------------------------------------ 6.17 Print formatted data to standard output using variable arguments.
    ------------------------------------------------------------------------------ [Name] vprintf [Syntax] #include #include i
  • Page 144------------------------------------------------------------------------------ 6.18 Print formatted data to memory using variable arguments. ------------------------------------------------------------------------------ [Name] vsprintf [Syntax] #include #include
  • Page 145------------------------------------------------------------------------------ 6.19 Read a character from a stream. ------------------------------------------------------------------------------ [Name] fgetc [Syntax] #include int fgetc( FILE *stream ) ; [Arguments] stream
  • Page 146------------------------------------------------------------------------------ 6.20 Read a strings from a stream. ------------------------------------------------------------------------------ [Name] fgets [Syntax] #include char *fgets( char *string, int n, FILE *stream )
  • Page 147------------------------------------------------------------------------------ 6.21 Write a character to a stream. ------------------------------------------------------------------------------ [Name] fputc [Syntax] #include int putc( int c, FILE *stream ) ; [Arguments] c
  • Page 148------------------------------------------------------------------------------ 6.22 Write a string to a stream. ------------------------------------------------------------------------------ [Name] fputs [Syntax] #include int fputs( const char *string, FILE *stream ) ; [A
  • Page 149------------------------------------------------------------------------------ 6.23 Read a character from a stream.
    ------------------------------------------------------------------------------ [Name] getc [Syntax] #include int getc( FILE *stream ) ; [Arguments] stream Current stre
  • Page 150------------------------------------------------------------------------------ 6.24 Read a character from standard input.
    ------------------------------------------------------------------------------ [Name] getchar [Syntax] #include int getchar( void ) ; [Arguments] ------ [Return]
  • Page 151------------------------------------------------------------------------------ 6.25 Read a line string from standard input.
    ------------------------------------------------------------------------------ [Name] gets [Syntax] #include char *gets( char *buffer ) ; [Arguments] buffer Po
  • Page 152------------------------------------------------------------------------------ 6.26 Write a character to a stream.
    ------------------------------------------------------------------------------ [Name] putc [Syntax] #include int putc( int c, FILE *stream ) ; [Arguments] c Character t
  • Page 153------------------------------------------------------------------------------ 6.27 Write a character to standard output.
    ------------------------------------------------------------------------------ [Name] putchar [Syntax] #include int putchar( int c ) ; [Arguments] c Character to
  • Page 154------------------------------------------------------------------------------ 6.28 Write a string to standard output.
    ------------------------------------------------------------------------------ [Name] puts [Syntax] #include int puts( const char *string ) ; [Arguments] string Str
  • Page 155------------------------------------------------------------------------------ 6.29 Put a character into a steam. ------------------------------------------------------------------------------ [Name] ungetc [Syntax] #include int ungetc( int c, FILE *stream ) ; [Arguments]
  • Page 156------------------------------------------------------------------------------ 6.30 Read data from a stream. ------------------------------------------------------------------------------ [Name] fread [Syntax] #include size_t fread( void *buffer, size_t size, size_t count
  • Page 157------------------------------------------------------------------------------ 6.31 Write data to a stream. ------------------------------------------------------------------------------ [Name] fwrite [Syntax] #include size_t fwrite( void *buffer, size_t size, size_t coun
  • Page 158------------------------------------------------------------------------------ 6.32 Get the current file position of a stream. ------------------------------------------------------------------------------ [Name] fgetpos [Syntax] #include int fgetpos( FILE *stream, fpos_t
  • Page 159------------------------------------------------------------------------------ 6.33 Move the current file pointer. ------------------------------------------------------------------------------ [Name] fseek [Syntax] #include int fseek( FILE *streem, long offset, int orign
  • Page 160------------------------------------------------------------------------------ 6.34 Set the current file position of stream. ------------------------------------------------------------------------------ [Name] fsetpos [Syntax] #include int fsetpos( FILE *stream, fpos_t *
  • Page 161------------------------------------------------------------------------------ 6.35 Get the current file pointer. ------------------------------------------------------------------------------ [Name] ftell [Syntax] #include long ftell( FILE *stream ) ; [Arguments] stream
  • Page 162------------------------------------------------------------------------------ 6.36 Rewind the current file pointer to the top of file. ------------------------------------------------------------------------------ [Name] rewind [Syntax] #include void rewind( FILE *stream
  • Page 163------------------------------------------------------------------------------ 6.37 Reset error indicator of a stream. ------------------------------------------------------------------------------ [Name] clearerr [Syntax] #include void clearerr( FILE *stream ) ; [Argumen
  • Page 164------------------------------------------------------------------------------ 6.38 Test for end-of-file. ------------------------------------------------------------------------------ [Name] feof [Syntax] #include int feof( FILE *stream ) ; [Arguments] stream Pointer to
  • Page 165------------------------------------------------------------------------------ 6.39 Test for error on stream. ------------------------------------------------------------------------------ [Name] ferror [Syntax] #include int ferror( FILE *stream ) ; [Arguments] stream Poi
  • Page 166------------------------------------------------------------------------------ 6.40 Print error message.
    ------------------------------------------------------------------------------ [Name] perror [Syntax] #include void perror( const char *string ) ; [Arguments] string Error messag
  • Page 1677. General utilities ( stdlib.h ) ------------------------------------------------------------------------------ 7.1 Convert string to int value. ------------------------------------------------------------------------------ [Name] atoi [Syntax] #include int atoi( const
  • Page 168------------------------------------------------------------------------------ 7.2 Convert string to long value. ------------------------------------------------------------------------------ [Name] atol [Syntax] #include long atol( const char *nptr ) ; [Arguments] nptr
  • Page 169------------------------------------------------------------------------------ 7.3 Convert string to long value. ------------------------------------------------------------------------------ [Name] strtol [Syntax] #include long strtol( const char *nptr, char **endptr, i
  • Page 170------------------------------------------------------------------------------ 7.4 Convert string to unsigned long value. ------------------------------------------------------------------------------ [Name] strtoul [Syntax] #include unsigned long strtoul( const char *np
  • Page 171------------------------------------------------------------------------------ 7.5 Generate pseudo-random number. ------------------------------------------------------------------------------ [Name] rand [Syntax] #include int rand( void ) ; [Arguments] ------ [Return] R
  • Page 172------------------------------------------------------------------------------ 7.6 Seed pseudo-random number generator. ------------------------------------------------------------------------------ [Name] srand [Syntax] #include void srand( unsigned int seed ) ; [Argume
  • Page 173------------------------------------------------------------------------------ 7.7 Allocate memory block initialized by 0. ------------------------------------------------------------------------------ [Name] calloc [Syntax] #include void *calloc( size_t num, size_t size
  • Page 174------------------------------------------------------------------------------ 7.8 Free memory block. ------------------------------------------------------------------------------ [Name] free [Syntax] #include void free( void *memblock ) ; [Arguments] memblock Memory bl
  • Page 175------------------------------------------------------------------------------ 7.9 Allocate memory block. ------------------------------------------------------------------------------ [Name] malloc [Syntax] #include void *malloc( size_t size ) ; [Arguments] size Byte si
  • Page 176------------------------------------------------------------------------------ 7.10 Reallocate memory block. ------------------------------------------------------------------------------ [Name] realloc [Syntax] #include void *realloc( void *memblock, size_t size ) ; [Ar
  • Page 177------------------------------------------------------------------------------ 7.11 Perform binary search. ------------------------------------------------------------------------------ [Name] bsearch [Syntax] #include void *bsearch( const void *key, const void *base, si
  • Page 178------------------------------------------------------------------------------ 7.12 Perform quick sort. ------------------------------------------------------------------------------ [Name] qsort [Syntax] #include void qsort( const void *base, size_t nmemb, size_t size,
  • Page 179------------------------------------------------------------------------------ 7.13 Get absolute value. ------------------------------------------------------------------------------ [Name] abs [Syntax] #include int abs( int j ) ; [Arguments] j Value which is converted t
  • Page 180------------------------------------------------------------------------------ 7.14 Get quotient and remainder. ------------------------------------------------------------------------------ [Name] div [Syntax] #include struct div_t { int quot ; int rem ; } *div( int num
  • Page 181------------------------------------------------------------------------------ 7.15 Get absolute value. ------------------------------------------------------------------------------ [Name] labs [Syntax] #include long labs( long j ) ; [Arguments] j Value which is convert
  • Page 182------------------------------------------------------------------------------ 7.16 Get quotient and remainder. ------------------------------------------------------------------------------ [Name] ldiv [Syntax] #include struct ldiv_t { long quot ; long rem ; } *ldiv( lo
  • Page 183------------------------------------------------------------------------------ 7.17 Convert string to double value. ------------------------------------------------------------------------------ [Name] atof [Syntax] #include double atof( const char *nptr ) ; [Arguments]
  • Page 184------------------------------------------------------------------------------ 7.18 Convert string to double value. ------------------------------------------------------------------------------ [Name] strtod [Syntax] #include double strtod( const char *nptr, char **endp
  • Page 1858. String handling ( string.h ) ------------------------------------------------------------------------------ 8.1 Copy a memory block. ------------------------------------------------------------------------------ [Name] memcpy [Syntax] #include void *memcpy( void *s1,
  • Page 186------------------------------------------------------------------------------ 8.2 Move a memory block. ------------------------------------------------------------------------------ [Name] memmove [Syntax] #include void *memmove( void *s1, void *s2, size_t n ) ; [Argume
  • Page 187------------------------------------------------------------------------------ 8.3 Copy a string. ------------------------------------------------------------------------------ [Name] strcpy [Syntax] #include char *strcpy( char *s1, const char *s2 ) ; [Arguments] s1 Poin
  • Page 188------------------------------------------------------------------------------ 8.4 Copy a string. ------------------------------------------------------------------------------ [Name] strncpy [Syntax] #include char *strncpy( char *s1, const char *s2, size_t n ) ; [Argume
  • Page 189------------------------------------------------------------------------------ 8.5 Concatenate a string. ------------------------------------------------------------------------------ [Name] strcat [Syntax] #include char *strcat( char *s1, const char *s2 ) ; [Arguments]
  • Page 190------------------------------------------------------------------------------ 8.6 Concatenate a string. ------------------------------------------------------------------------------ [Name] strncat [Syntax] #include char *strncat( char *s1, const char *s2, size_t n ) ;
  • Page 191------------------------------------------------------------------------------ 8.7 Compare two memory blocks. ------------------------------------------------------------------------------ [Name] memcmp [Syntax] #include int memcmp( const void *s1, const void *s2, size_t
  • Page 192------------------------------------------------------------------------------ 8.8 Compare two strings. ------------------------------------------------------------------------------ [Name] strcmp [Syntax] #include int strcmp( const char *s1, const char *s2 ) ; [Argument
  • Page 193------------------------------------------------------------------------------ 8.9 Compare two strings. ------------------------------------------------------------------------------ [Name] strncmp [Syntax] #include int strncmp( const char *s1, const char *s2, size_t n )
  • Page 194------------------------------------------------------------------------------ 8.10 Find a character in a memory block. ------------------------------------------------------------------------------ [Name] memchr [Syntax] #include void *memchr( const void *s, int c, size
  • Page 195------------------------------------------------------------------------------ 8.11 Find a character in a string. ------------------------------------------------------------------------------ [Name] strchr [Syntax] #include char *strchr( const char *s, int c ) ; [Argume
  • Page 196------------------------------------------------------------------------------ 8.12 Get string length which doesn't include a character. ------------------------------------------------------------------------------ [Name] strcspn [Syntax] #include size_t strcspn( const
  • Page 197------------------------------------------------------------------------------ 8.13 Find a character position in a string. ------------------------------------------------------------------------------ [Name] strpbrk [Syntax] #include char *strpbrk( const char *s1, const
  • Page 198------------------------------------------------------------------------------ 8.14 Find the last character in a string. ------------------------------------------------------------------------------ [Name] strrchr [Syntax] #include char *strrchr( const char *s, int c )
  • Page 199------------------------------------------------------------------------------ 8.15 Get string length composed by specified character. ------------------------------------------------------------------------------ [Name] strspn [Syntax] #include size_t strspn( const char
  • Page 200------------------------------------------------------------------------------ 8.16 Find a string in a string. ------------------------------------------------------------------------------ [Name] strstr [Syntax] #include char *strstr( const char *s1, const char *s2 ) ;
  • Page 201------------------------------------------------------------------------------ 8.17 Get a token. ------------------------------------------------------------------------------ [Name] strtok [Syntax] #include char *strtok( char *s1, const char *s2 ) ; [Arguments] s1 Point
  • Page 202------------------------------------------------------------------------------ 8.18 Fill data in a memory block. ------------------------------------------------------------------------------ [Name] memset [Syntax] #include void *memset( void *s, int c, size_t n ) ; [Arg
  • Page 203------------------------------------------------------------------------------ 8.19 Get string length. ------------------------------------------------------------------------------ [Name] strlen [Syntax] #include size_t strlen( const char *s ) ; [Arguments] s Pointer to
  • Page 2049. Date and time ( time.h ) ------------------------------------------------------------------------------ 9.1 Get the current time. ------------------------------------------------------------------------------ [Name] clock [Syntax] #include clock_t clock( void ) ; [Argum
  • Page 205------------------------------------------------------------------------------ 9.2 Convert local time to calender time. ------------------------------------------------------------------------------ [Name] mktime [Syntax] #include time_t mktime( struct tm *timeptr ) ; [Arg
  • Page 206------------------------------------------------------------------------------ 9.3 Get the current time. ------------------------------------------------------------------------------ [Name] time [Syntax] #include time_t time( time_t *timer ) ; [Arguments] timer Pointer to
  • Page 207------------------------------------------------------------------------------ 9.4 Convert time to string. ------------------------------------------------------------------------------ [Name] asctime [Syntax] #include char *asctime( const struct tm *timeptr ) ; [Arguments
  • Page 208------------------------------------------------------------------------------ 9.5 Convert time to string. ------------------------------------------------------------------------------ [Name] ctime [Syntax] #include char *ctime( const time_t *timer ) ; [Arguments] timer P
  • Page 209------------------------------------------------------------------------------ 9.6 Convert time to Greenwich mean time. ------------------------------------------------------------------------------ [Name] gmtime [Syntax] #include struct tm *gmtime( const time_t *timer ) ;
  • Page 210------------------------------------------------------------------------------ 9.7 Convert time to local time. ------------------------------------------------------------------------------ [Name] localtime [Syntax] #include struct tm *localtime( const time_t *timer ) ; [A
  • Page 211------------------------------------------------------------------------------ 9.8 Compute the difference between the two times. ------------------------------------------------------------------------------ [Name] difftime [Syntax] #include double difftime( time_t time1,
  • Page 2123.2 MS-C extended C standard library ==================================== Lists of Functions -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- _chdrive Change the current drive. _dos_fin
  • Page 213-------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- _lrotl Rotate an unsigned long left. _lrotr Rotate an unsigned long right. _msize Get memory block size in heap. _rotl Rotate unsigned i
  • Page 214-------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- isgrkana Determine whether the character of interest is a printable ASCII character (except a half-size space). iskana Determine whether
  • Page 2153.3 Graphic library =================== Usage of graphic functions 1. Kinds of the graphic display device. C Executor for FS30i supports the following graphic display device. (Refer also "36crt.man".) (1) VGA Graphic. This is the display device that is equipped with FS30i. This name is derived from
  • Page 2163. Open and close graphics. Call the crt_opengr function before calling of the other graphic functions in the user application. Call the crt_closegr function after a series of graphic drawings. The flow of the processing is as follows. : if ( crt_opengr() ) { /* open graphics */ /* initialize graphi
  • Page 217Lists of MS-C compatible functions C Executor supports the following MS-C compatible graphic functions. -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1. _arc Draw an arc or an ellipt
  • Page 218-------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 49. _settextposition Set the current output position of text. 50. _settextrows Set the text row number. 51. _settextwindow Set the text
  • Page 219Function Reference In the following section, the differences from the graphic functions of MS-C are mainly explained. Refer the function reference manual of MS-C for the details of each functions. The concrete behaviours of each functions which are not clearly mentioned in the reference manual of MS
  • Page 220------------------------------------------------------------------------------ 2. Clear screen.
    ------------------------------------------------------------------------------ [Name] _clearscreen [Syntax] #include void _clearscreen( short area ) ; [Description] Clears specified regio
  • Page 221------------------------------------------------------------------------------ 3. Draw a circle or an ellipse.
    ------------------------------------------------------------------------------ [Name] _ellipse [Syntax] #include short _ellipse( short fill, short rsx, short rsy, short rex
  • Page 222------------------------------------------------------------------------------ 4. Paint the closed region.
    ------------------------------------------------------------------------------ [Name] _floodfill [Syntax] #include short _floodfill( short sx, short sy, short boundary ) ; [Des
  • Page 223------------------------------------------------------------------------------ 5. Get the current active page number.
    ------------------------------------------------------------------------------ [Name] _getactivepage [Syntax] #include short _getactivepage( void ) ; [Description] G
  • Page 224------------------------------------------------------------------------------ 6. Get the information of the previous arc or pie.
    ------------------------------------------------------------------------------ [Name] _getarcinfo [Syntax] #include short _getarcinfo( struct _xycoord *s
  • Page 225------------------------------------------------------------------------------ 7. Get the current back ground color.
    ------------------------------------------------------------------------------ [Name] _getbkcolor [Syntax] #include long _getbkcolor( void ) ; [Description] Gets the
  • Page 226------------------------------------------------------------------------------ 8. Get the current fore ground color.
    ------------------------------------------------------------------------------ [Name] _getcolor [Syntax] #include short _getcolor( void ) ; [Description] Gets the pal
  • Page 227------------------------------------------------------------------------------ 9. Get the current position in the view coordinate.
    ------------------------------------------------------------------------------ [Name] _getcurrentposition [Syntax] #include struct _xycoord _getcurrentp
  • Page 228------------------------------------------------------------------------------ 10. Get the current fill mask pattern.
    ------------------------------------------------------------------------------ [Name] _getfillmask [Syntax] #include unsigned char *_getfillmask( unsigned char *mask
  • Page 229------------------------------------------------------------------------------ 11. Get the current font information.
    ------------------------------------------------------------------------------ [Name] _getfontinfo [Syntax] #include short _getfontinfo( struct _fontinfo *fontbuffer
  • Page 230------------------------------------------------------------------------------ 12. Get the text extent by pixel unit.
    ------------------------------------------------------------------------------ [Name] _getgtextextent [Syntax] #include short _getgtextextent( unsigned char *text )
  • Page 231------------------------------------------------------------------------------ 13. Get the output vector of text.
    ------------------------------------------------------------------------------ [Name] _getgtextvector [Syntax] #include struct _xycoord _getgtextvector( void ) ; [Descri
  • Page 232------------------------------------------------------------------------------ 14. Get screen image.
    ------------------------------------------------------------------------------ [Name] _getimage [Syntax] #include void _getimage( short rsx, short rsy, short rex, short rey, char *im
  • Page 233------------------------------------------------------------------------------ 15. Get the font pattern of Kanji character.
    ------------------------------------------------------------------------------ [Name] _getkanji [Syntax] #include short _getkanji( unsigned short code, unsigne
  • Page 234------------------------------------------------------------------------------ 16. Get the current line style.
    ------------------------------------------------------------------------------ [Name] _getlinestyle [Syntax] #include unsigned short _getlinestyle( void ) ; [Description] G
  • Page 235------------------------------------------------------------------------------ 17. Convert view coordinate into physical.
    ------------------------------------------------------------------------------ [Name] _getphyscoord [Syntax] #include struct _xycoord _getphyscoord( short x, sho
  • Page 236------------------------------------------------------------------------------ 18. Get color number the pixel.
    ------------------------------------------------------------------------------ [Name] _getpixel [Syntax] #include short _getpixel( short x, short y ) ; [Description] Gets t
  • Page 237------------------------------------------------------------------------------ 19. Get the current output position of text.
    ------------------------------------------------------------------------------ [Name] _gettextposition [Syntax] #include struct _rccoord _gettextposition( void
  • Page 238------------------------------------------------------------------------------ 20. Get the text window border.
    ------------------------------------------------------------------------------ [Name] _gettextwindow [Syntax] #include void _gettextwindow( short *r1, short *c1, short *r2,
  • Page 239------------------------------------------------------------------------------ 21. Get the graphic configuration.
    ------------------------------------------------------------------------------ [Name] _getvideoconfig [Syntax] #include struct videoconfig *_getvideoconfig( struct video
  • Page 240------------------------------------------------------------------------------ 22. Convert physical coordinate into view.
    ------------------------------------------------------------------------------ [Name] _getviewcoord [Syntax] #include struct _xycoord _getviewcoord( short x, sho
  • Page 241------------------------------------------------------------------------------ 23. Get the current visual page number.
    ------------------------------------------------------------------------------ [Name] _getvisualpage [Syntax] #include short _getvisualpage( void ) ; [Description]
  • Page 242------------------------------------------------------------------------------ 24. Get the current writing mode.
    ------------------------------------------------------------------------------ [Name] _getwritemode [Syntax] #include short _getwritemode( void ) ; [Description] Gets the
  • Page 243------------------------------------------------------------------------------ 25. Get the return status of graphic function.
    ------------------------------------------------------------------------------ [Name] _grstatus [Syntax] #include short _grstatus( void ) ; [Description] Get
  • Page 244------------------------------------------------------------------------------ 26. Get image buffer size.
    ------------------------------------------------------------------------------ [Name] _imagesize [Syntax] #include long _imagesize( short rsx, short rsy, short rex, short rey )
  • Page 245------------------------------------------------------------------------------ 27. Get font pattern size of Kanji character.
    ------------------------------------------------------------------------------ [Name] _kanjisize [Syntax] #include short _kanjisize( short code ) ; [Descripti
  • Page 246------------------------------------------------------------------------------ 28. Draw a line.
    ------------------------------------------------------------------------------ [Name] _lineto [Syntax] #include short _lineto( short x, short y ) ; [Description] Draws a line from the cur
  • Page 247------------------------------------------------------------------------------ 29. Move the current graphic output position.
    ------------------------------------------------------------------------------ [Name] _moveto [Syntax] #include struct xycoord _moveto( short x, short y ) ; [
  • Page 248------------------------------------------------------------------------------ 30. Draw a text string using the current font.
    ------------------------------------------------------------------------------ [Name] _outgtext [Syntax] #include void _outgtext( unsigned char *text ) ; [De
  • Page 249------------------------------------------------------------------------------ 31. Draw a text string in a memory.
    ------------------------------------------------------------------------------ [Name] _outmem [Syntax] #include void _outmem( char *text, short length ) ; [Description]
  • Page 250------------------------------------------------------------------------------ 32. Output a text string on the current position.
    ------------------------------------------------------------------------------ [Name] _outtext [Syntax] #include void _outtext( char *text ) ; [Descriptio
  • Page 251------------------------------------------------------------------------------ 33. Draw a pie figure.
    ------------------------------------------------------------------------------ [Name] _pie [Syntax] #include short _pie( short fill, short rsx, short rsy, short rex, short rey, shor
  • Page 252------------------------------------------------------------------------------ 34. Draw a polygon.
    ------------------------------------------------------------------------------ [Name] _polygon [Syntax] #include short _polygon( short fill, struct xycoord *points, short numpoints ) ;
  • Page 253------------------------------------------------------------------------------ 35. Put image data on the screen.
    ------------------------------------------------------------------------------ [Name] _putimage [Syntax] #include void _putimage( short sx, short sy, char *image, short a
  • Page 254------------------------------------------------------------------------------ 36. Draw a rectangle.
    ------------------------------------------------------------------------------ [Name] _rectangle [Syntax] #include short _rectangle( short fill, short rsx, short rsy, short rex, shor
  • Page 255------------------------------------------------------------------------------ 37. Register font file.
    ------------------------------------------------------------------------------ [Name] _registerfonts [Syntax] #include short _registerfonts( unsigned char *pathname ) ; [Descriptio
  • Page 256------------------------------------------------------------------------------ 38. Map colors into all color palette.
    ------------------------------------------------------------------------------ [Name] _remapallpalette [Syntax] #include short _remapallpalette( long *colors ) ; [De
  • Page 257------------------------------------------------------------------------------ 39. Map a color into a color palette.
    ------------------------------------------------------------------------------ [Name] _remappalette [Syntax] #include long _remappalette( short index, long color ) ;
  • Page 258------------------------------------------------------------------------------ 40. Set the current active page number.
    ------------------------------------------------------------------------------ [Name] _setactivepage [Syntax] #include short _setactivepage( short page ) ; [Descrip
  • Page 259------------------------------------------------------------------------------ 41. Set the current back ground color.
    ------------------------------------------------------------------------------ [Name] _setbkcolor [Syntax] #include long _setbkcolor( long color ) ; [Description] Se
  • Page 260------------------------------------------------------------------------------ 42. Set the clipping region.
    ------------------------------------------------------------------------------ [Name] _setcliprgn [Syntax] #include void _setcliprgn( short rsx, short rsy, short rex, short re
  • Page 261------------------------------------------------------------------------------ 43. Set the current fore ground color.
    ------------------------------------------------------------------------------ [Name] _setcolor [Syntax] #include short _setcolor( short color ) ; [Description] Sets
  • Page 262------------------------------------------------------------------------------ 44. Set the current fill mask pattern.
    ------------------------------------------------------------------------------ [Name] _setfillmask [Syntax] #include void _setfillmask( unsigned char *mask ) ; [Desc
  • Page 263------------------------------------------------------------------------------ 45. Set the current font.
    ------------------------------------------------------------------------------ [Name] _setfont [Syntax] #include short _setfont( unsigned char *options ) ; [Description] Sets the
  • Page 264------------------------------------------------------------------------------ 46. Set the current output vector of text.
    ------------------------------------------------------------------------------ [Name] _setgtextvector [Syntax] #include struct _xycoord _setgtextvector( short x,
  • Page 265------------------------------------------------------------------------------ 47. Set the current line style.
    ------------------------------------------------------------------------------ [Name] _setlinestyle [Syntax] #include void _setlinestyle( unsigned short mask ) ; [Descripti
  • Page 266------------------------------------------------------------------------------ 48. Draw a pixel.
    ------------------------------------------------------------------------------ [Name] _setpixel [Syntax] #include short _setpixel( short x, short y ) ; [Description] Draws a pixel in spe
  • Page 267------------------------------------------------------------------------------ 49. Set the current output position of text.
    ------------------------------------------------------------------------------ [Name] _settextposition [Syntax] #include struct _rccoord _settextposition( shor
  • Page 268------------------------------------------------------------------------------ 50. Set the text row number.
    ------------------------------------------------------------------------------ [Name] _settextrows [Syntax] #include short _settextrows( short rows ) ; [Description] Sets the
  • Page 269------------------------------------------------------------------------------ 51. Set the text window.
    ------------------------------------------------------------------------------ [Name] _settextwindow [Syntax] #include void _settextwindow( short r1, short c1, short r2, short c2
  • Page 270------------------------------------------------------------------------------ 52. Set the screen video mode.
    ------------------------------------------------------------------------------ [Name] _setvideomode [Syntax] #include short _setvideomode( short mode ) ; [Description] Selec
  • Page 271(2) Use "_CEXERES16COLOR" mode for arbitrary plane size and text mode. Symbol "_CEXERES16COLOR" is definded in "graph.h". For the setting of this mode, the function syntax is changed as follows. #include #include short _setvideomode( _CEXERES16COLOR, short origin, short height, sho
  • Page 272------------------------------------------------------------------------------ 53. Set the screen video mode and text row number.
    ------------------------------------------------------------------------------ [Name] _setvideomoderows [Syntax] #include short _setvideomoderows( short
  • Page 273------------------------------------------------------------------------------ 54. Set the origin of the view port.
    ------------------------------------------------------------------------------ [Name] _setvieworg [Syntax] #include struct xycoord _setvieworg( short x, short y ) ; [D
  • Page 274------------------------------------------------------------------------------ 55. Set the clipping region and the view coordinate.
    ------------------------------------------------------------------------------ [Name] _setviewport [Syntax] #include void _setviewport( short rsx, shor
  • Page 275------------------------------------------------------------------------------ 56. Set the current visual page number.
    ------------------------------------------------------------------------------ [Name] _setvisualpage [Syntax] #include short _setvisualpage( short page ) ; [Descrip
  • Page 276------------------------------------------------------------------------------ 57. Set the current writing mode.
    ------------------------------------------------------------------------------ [Name] _setwritemode [Syntax] #include short _setwritemode( short action ) ; [Description]
  • Page 277------------------------------------------------------------------------------ 58. Delete registered font file.
    ------------------------------------------------------------------------------ [Name] _unregisterfonts [Syntax] #include void _unregisterfonts( void ) ; [Description] Dele
  • Page 278------------------------------------------------------------------------------ 59. Enable/disable line wrapping.
    ------------------------------------------------------------------------------ [Name] _wrapon [Syntax] #include short _wrapon( short option ) ; [Description] Enable or di
  • Page 279MS-C graphic function compatibility list "x" mark: Available Blank: NOT available C-Card : Character-card ---------------------------------------------------------------------------- Name Function VGA C-Card ---------------------------------------------------------------+----+------- _arc Draw an ar
  • Page 280---------------------------------------------------------------------------- Name Function VGA C-Card ---------------------------------------------------------------+----+------- _setcolor Set the current fore ground color. x _setfillmask Set the current fill mask pattern. x _setfont Set the current
  • Page 281Lists of C Executor original graphic functions C Executor graphic library supports the following original graphic functions in addition to MS-C compatible functions. -------------------------------------------------------------------------- Name Function ---------------------------------------------
  • Page 282Function Reference ------------------------------------------------------------------------------ 1. Draw a standard size character.
    ------------------------------------------------------------------------------ [Name] gr_displaychar [Syntax] #include void gr_displaychar( int code,
  • Page 283------------------------------------------------------------------------------ 2. Draw a quad size character.
    ------------------------------------------------------------------------------ [Name] gr_displayfourlarge [Syntax] #include void gr_displayfourlarge( int code, short cx, sho
  • Page 284------------------------------------------------------------------------------ 3. Draw a hex size character.
    ------------------------------------------------------------------------------ [Name] gr_displaysixlarge [Syntax] #include void gr_displaysixlarge( int code, short cx, short
  • Page 285------------------------------------------------------------------------------ 4. Put monochrome image data.
    ------------------------------------------------------------------------------ [Name] _putpattern [Syntax] #include void _putpattern( short x, short y, void *image, short act
  • Page 286[Example] The following monochrome image data (19x8 dots) is drawn. The leading 2-word data in the buffer are the height and the width of the image pattern data. +---- 19 dots -----+ │ │ fedcba9876543210 765 0 ................ ... -+ 1 .####..####..#.. .#. │ 2 .#...#.#...#.##. ##. │ 3 .#...#.#...#.#
  • Page 287------------------------------------------------------------------------------ 5. Get monochrome image data.
    ------------------------------------------------------------------------------ [Name] _getpattern [Syntax] #include void _getpattern( short rsx, short rsy, short rex, short r
  • Page 288[Example] The following program displays a cursor. #include #include void example( short rsx, short rsy, short ch_num, short OldColor, short ForColor, short BakColor ) { char *image ; long image_size ; short w, h ; w = ch_num*8 ; h = 16 ; image_size = ( w+15 ) / 16 * 2 * h + 4 ;
  • Page 289------------------------------------------------------------------------------ 6. Draw a standard size string.
    ------------------------------------------------------------------------------ [Name] gr_dispstr [Syntax] #include void gr_dispstr( char *str, short cx, short cy, short fg,
  • Page 290------------------------------------------------------------------------------ 7. Draw a hex size string.
    ------------------------------------------------------------------------------ [Name] gr_disp6str [Syntax] #include void gr_disp6str( char *str, short cx, short cy, short fg, sh
  • Page 291------------------------------------------------------------------------------ 8. Copy image data.
    ------------------------------------------------------------------------------ [Name] gr_bitblt [Syntax] #include void gr_bitblt( short rsx, short rsy, short rex, short rey, short cx,
  • Page 292------------------------------------------------------------------------------ 9. Draw a quad size string.
    ------------------------------------------------------------------------------ [Name] gr_disp4str [Syntax] #include void gr_disp4str( char *str, short cx, short cy, short fg, s
  • Page 293------------------------------------------------------------------------------ 10. Draw a small size character.
    ------------------------------------------------------------------------------ [Name] gr_displaysmlchar [Syntax] #include void gr_displaysmlchar( int code, short cx, short
  • Page 294------------------------------------------------------------------------------ 11. Draw a small size string.
    ------------------------------------------------------------------------------ [Name] gr_dispsstr [Syntax] #include void gr_dispsstr( char *str, short cx, short cy, short fg,
  • Page 295------------------------------------------------------------------------------ 12. Draw a FANUC character.
    ------------------------------------------------------------------------------ [Name] gr_displayfchar [Syntax] #include void gr_displayfchar( unsigned int code, short cx, short
  • Page 296------------------------------------------------------------------------------ 13. Draw a FANUC character string.
    ------------------------------------------------------------------------------ [Name] gr_dispfstr [Syntax] #include void gr_dispfstr( unsigned int *code, unsigned int le
  • Page 297------------------------------------------------------------------------------ 14. Draw 9-inch font character.
    ------------------------------------------------------------------------------ [Name] gr_disp9ifchar [Syntax] #include void gr_disp9ifchar( int code, short cx, short cy, sh
  • Page 298------------------------------------------------------------------------------ 15. Draw 9-inch font character string.
    ------------------------------------------------------------------------------ [Name] gr_disp9ifstr [Syntax] #include void gr_disp9ifstr( unsigned char *str, short c
  • Page 299------------------------------------------------------------------------------ 16. Draw a line between specified two points.
    ------------------------------------------------------------------------------ [Name] mmc_line_b [Syntax] #include short mmc_line_b( short x1, short y1, shor
  • Page 300------------------------------------------------------------------------------ 17. Draw a polyline.
    ------------------------------------------------------------------------------ [Name] mmc_polyline [Syntax] #include void mmc_polyline( const struct _xycoord *points, short numpoints
  • Page 301------------------------------------------------------------------------------ 18. Draw a circle.
    ------------------------------------------------------------------------------ [Name] mmc_circle_b [Syntax] #include short mmc_circle_b( short control, short xc, short yc, short r ) ;
  • Page 302------------------------------------------------------------------------------ 19. Draw an ellipse.
    ------------------------------------------------------------------------------ [Name] mmc_ellipse_b [Syntax] #include short mmc_ellipse_b( short control, short xc, short yc, short xr
  • Page 303------------------------------------------------------------------------------ 20. Draw a pie figure.
    ------------------------------------------------------------------------------ [Name] mmc_pie_b [Syntax] #include short mmc_pie_b( short control, short xc, short yc, short xr, shor
  • Page 304------------------------------------------------------------------------------ 21. Draw an arc.
    ------------------------------------------------------------------------------ [Name] mmc_arc_b [Syntax] #include short mmc_arc_b( short xc, short yc, short xr, short yr, short d1, short
  • Page 305------------------------------------------------------------------------------ 22. Get character in the specified area.
    ------------------------------------------------------------------------------ [Name] mmc_gettext [Syntax] #include short mmc_gettext( short x1, short y1, short x
  • Page 306[Description] Reads characters in the specified screen area to the memory. Specify screen area to read as left-upper point of screen (Home position) is (1,1). The first character is read at the start point (left-upper position), and continuously reads rightward, jumps to the next line at the right e
  • Page 307------------------------------------------------------------------------------ 23. Put character data on memory to text screen.
    ------------------------------------------------------------------------------ [Name] mmc_puttext [Syntax] #include short mmc_puttext( short x, short y, _
  • Page 308------------------------------------------------------------------------------ 24. Get required byte size for getting character.
    ------------------------------------------------------------------------------ [Name] mmc_textsize [Syntax] #include short mmc_textsize( short x1, short
  • Page 3093.4 CNC/PMC window library ========================== Lists of Functions 1. CNC window library -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1.1 cnc_sysinfo Read CNC system informati
  • Page 310-------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1.42 cnc_rdparam Read parameter. 1.43 cnc_wrparam Write parameter. 1.44 cnc_rdparar Read parameters (range specified). 1.45 cnc_wrparas
  • Page 311Function Reference 1. CNC window library ------------------------------------------------------------------------------ 1.1 Read CNC system information. ------------------------------------------------------------------------------ [Name] cnc_sysinfo [Syntax] #include #include
  • Page 312[Example] The following informations are gotten by execution of this function on FS30 (G001-01) system with 4 servo axes. buf.cnc_type = "30" buf.mt_type = " M" buf.series = "G001" buf.version = "0001" buf.axes = "4 "
  • Page 313------------------------------------------------------------------------------ 1.2 Start output of NC program to be registered. ------------------------------------------------------------------------------ [Name] cnc_dwnstart [Syntax] #include #include short cnc_dw
  • Page 314------------------------------------------------------------------------------ 1.3 Output NC program to be registered. ------------------------------------------------------------------------------ [Name] cnc_download [Syntax] #include #include short cnc_download( c
  • Page 315NC program format NC program to be registered to CNC is a string composed of ASCII characters as following format. LF Oxxxx LF Block1 LF Block2 LF ... LF Mxx LF % LF 0x0A ('¥n'). Oxxxx Program number. Mxx M code at the end of the program (M02,M30, etc.). 'LF' must be placed at the top of the whole p
  • Page 316[Example] The following program registers the next NC program to CNC. O1234 ; M3 S1200 ; G0 Z0 ; G0 X0 Y0 ; G1 F500 X120. Y-30. ; M30 ; #include #include short example( void ) { char *prg[] = { "¥n", "O1234¥n", "M3 S1200¥n", "G0 Z0¥n", "G0 X0 Y0¥n", "G1 F500 X120. Y-30.¥n", "M30
  • Page 317------------------------------------------------------------------------------ 1.4 Stop output NC program to be registered. ------------------------------------------------------------------------------ [Name] cnc_dwnend [Syntax] #include #include short cnc_dwnend(
  • Page 318------------------------------------------------------------------------------ 1.5 Start output NC program to be compared. ------------------------------------------------------------------------------ [Name] cnc_vrfstart [Syntax] #include #include short cnc_vrfstar
  • Page 319------------------------------------------------------------------------------ 1.6 Output NC program to be compared. ------------------------------------------------------------------------------ [Name] cnc_verify [Syntax] #include #include short cnc_verify( char *d
  • Page 320There is one buffer (256 bytes) between CNC and C library. It is used as a ring. Buffer size = 256 bytes +--------------------------------------------------+ +-->│ 1st output │ 2nd output │ ... │ │ --+ │ +--------------------------------------------------+ │ │ │ +------------------------------------
  • Page 321------------------------------------------------------------------------------ 1.7 Stop output NC program to be compared. ------------------------------------------------------------------------------ [Name] cnc_vrfend [Syntax] #include #include short cnc_vrfend( vo
  • Page 322------------------------------------------------------------------------------ 1.8 Start output NC program to be executed. ------------------------------------------------------------------------------ [Name] cnc_dncstart [Syntax] #include #include short cnc_dncstar
  • Page 323[Description] It is possible to get CNC software to run a NC program (NC command data), which is made by the application program, directly (DNC operation). This is DNC operation, which is ordinarily executed via RS-232C, via CNC window from C language application. The application program requests CN
  • Page 324------------------------------------------------------------------------------ 1.9 Output NC program to be executed. ------------------------------------------------------------------------------ [Name] cnc_dnc [Syntax] #include #include short cnc_dnc( char *data, s
  • Page 325Format of NC command data to be executed NC command data to be executed to CNC is a string composed of ASCII characters as following format. LF Oxxxx LF Block1 LF Block2 LF ... LF Mxx LF % LF NC command1 LF NC command2 LF ... LF Mxx LF % LF 0x0A ('¥n'). Mxx M code at the end of the DNC operation (M0
  • Page 326There is one buffer (256 bytes) between CNC and C library. It is used as a ring. Buffer size = 256 bytes +--------------------------------------------------+ +-->│ 1st output │ 2nd output │ ... │ │ --+ │ +--------------------------------------------------+ │ │ │ +------------------------------------
  • Page 327[Example] The following program executes the next NC commands by DNC operation. M3 S1500 ; G28 U0 W0 ; T0101 ; G0 X35. Z-10. ; M30 ; #include #include short example( void ) { char *prg[] = { "¥n", "M3S1500¥n", "G28U0W0¥n", "T0101¥n", "G0X35.Z-10.¥n", "M30¥n", "%" } ; short ret,
  • Page 328------------------------------------------------------------------------------ 1.10 Stop output NC program to be executed. ------------------------------------------------------------------------------ [Name] cnc_dncend [Syntax] #include #include short cnc_dncend( v
  • Page 329------------------------------------------------------------------------------ 1.11 Start input NC program. ------------------------------------------------------------------------------ [Name] cnc_upstart [Syntax] #include #include short cnc_upstart( long number )
  • Page 330------------------------------------------------------------------------------ 1.12 Input NC program. ------------------------------------------------------------------------------ [Name] cnc_upload [Syntax] #include #include short cnc_upload( struct odbup *buf, sho
  • Page 331Format of input data NC program which is read from CNC is a string composed of ASCII characters as following format. % LF Oxxxx LF Block1 LF Block2 LF ... LF Mxx LF % LF 0x0A ('¥n'). Oxxxx Program number. Mxx M code at the end of the program (M02,M30, etc.). A null character ('¥x00') is not added at
  • Page 332[Example] The following program reads the specified NC program registered in CNC, and displays its contents on the screen. #include #include #include #define BUFSIZE 40 /* prgnum is NC program number to be read. */ short example( long prgnum ) { char buf[BUFSIZE+4] ; s
  • Page 333------------------------------------------------------------------------------ 1.13 Stop input NC program. ------------------------------------------------------------------------------ [Name] cnc_upend [Syntax] #include #include short cnc_upend( void ) ; [Arguments
  • Page 334------------------------------------------------------------------------------ 1.14 Search specified program. ------------------------------------------------------------------------------ [Name] cnc_search [Syntax] #include #include short cnc_search( long number )
  • Page 335[Example] The following program searches the program whose program number is same as specified one, and displays the result. #include #include #include /* num is program number to be searched. */ void example( long num ) { short ret ; ret = cnc_search( num ) ; switch (
  • Page 336------------------------------------------------------------------------------ 1.15 Delete all programs. ------------------------------------------------------------------------------ [Name] cnc_delall [Syntax] #include #include short cnc_delall( void ) ; [Arguments
  • Page 337[Example] The following program deletes all programs and displays the result. #include #include #include void example( void ) { short ret ; ret = cnc_delall() ; switch ( ret ) { case 0: printf( "ALL PROGRAMS has been deleted.¥n", num ) ; break ; case 7: printf( "PROTEC
  • Page 338------------------------------------------------------------------------------ 1.16 Delete specified program. ------------------------------------------------------------------------------ [Name] cnc_delete [Syntax] #include #include short cnc_delete( long number )
  • Page 339[Example] The following program deletes the program whose program number is same as specified one, and displays the result. #include #include #include /* num is program number to be deleted. */ void example( long num ) { short ret ; ret = cnc_delete( num ) ; switch ( r
  • Page 340------------------------------------------------------------------------------ 1.17 Read program directory. ------------------------------------------------------------------------------ [Name] cnc_rdprogdir [Syntax] #include #include short cnc_rdprogdir( short type
  • Page 341[Description] Reads the list of program numbers (program directory) of all NC programs registered in CNC. Program numbers, comments and character numbers of programs included in specified program number range are read with ASCII string format. Specify the start program number to be read in "datano_s
  • Page 342For example, when the next programs are registered in CNC, the result of this function, in case that datano_s=1 and datano_e=9999, is as follows. Program number (COMMENT) Character number -------------------------------+---------------- O0012 (TEST) ; 420 O0200 (WORK1) ; 352 O0201 ; 537 O9001 (SUB-P
  • Page 343------------------------------------------------------------------------------ 1.18 Read program information. ------------------------------------------------------------------------------ [Name] cnc_rdproginfo [Syntax] #include #include short cnc_rdproginfo( short
  • Page 344Format of input data - type=0 Each data are stored in each members of the structure with binary format. - type=1 ASCII strings are stored in "buf.u.asc" with following format. % LF d1 LF d2 LF d3 LF d4 LF % LF 0x0A ('¥n'). d1 Amount of registered programs. d2 Amount of available programs. d3 Charact
  • Page 345------------------------------------------------------------------------------ 1.19 Read program number in executing. ------------------------------------------------------------------------------ [Name] cnc_rdprgnum [Syntax] #include #include short cnc_rdprgnum( st
  • Page 346[Example] The next program displays "CURRENT(O9876) MAIN(O1234)" while the block "O9876/N210" of the following NC program is being executed. #include #include #include void example( void ) { struct odbpro buf ; cnc_rdprgnum( &buf ) ; printf( "CURRENT(O%d) MAIN(O%d)¥n",
  • Page 347------------------------------------------------------------------------------ 1.20 Read sequence number in executing. ------------------------------------------------------------------------------ [Name] cnc_rdseqnum [Syntax] #include #include short cnc_rdseqnum( s
  • Page 348[Example] The following program displays "CURRENT N30" while the block "O1234/N30" of the following NC program is being executed. #include #include #include void example( void ) { struct odbact buf ; cnc_rdseqnum( &buf ) ; printf( "CURRENT N%ld¥n", buf.data ) ; } O1234
  • Page 349------------------------------------------------------------------------------ 1.21 Read actual feed rate of controlled axes. ------------------------------------------------------------------------------ [Name] cnc_actf [Syntax] #include #include short cnc_actf( st
  • Page 350[Example] The message "CURRENT F=1200" is displayed if the following program is executed while the O1234/N20 block in the following NC program is being executed (on the assumption that the lathe is running in the metric input mode). #include #include #include void exam
  • Page 351------------------------------------------------------------------------------ 1.22 Read actual spindle speed. ------------------------------------------------------------------------------ [Name] cnc_acts [Syntax] #include #include short cnc_acts( struct odbact *bu
  • Page 352------------------------------------------------------------------------------ 1.23 Read absolute position. ------------------------------------------------------------------------------ [Name] cnc_absolute [Syntax] #include #include short cnc_absolute( short axis,
  • Page 353[Description] Reads the absolute position data of the controlled axis of CNC. This absolute position data is identical to that in the absolute coordinate system displayed on the current position display screen of the CNC. This function is used for displaying the absolute positions of the controlled
  • Page 354------------------------------------------------------------------------------ 1.24 Read machine position. ------------------------------------------------------------------------------ [Name] cnc_machine [Syntax] #include #include short cnc_machine( short axis, sho
  • Page 355[Description] Reads the machine position data of the controlled axis of CNC. This machine position data is identical to that in the machine coordinate system displayed on the current position display screen of the CNC. This function is used for displaying the machine positions of the controlled axes
  • Page 356------------------------------------------------------------------------------ 1.25 Read relative position. ------------------------------------------------------------------------------ [Name] cnc_relative [Syntax] #include #include short cnc_relative( short axis,
  • Page 357[Description] Reads the relative position data of the controlled axis of CNC. This relative position data is identical to that in the relative coordinate system displayed on the current position display screen of the CNC. This function is used for displaying the relative positions of the controlled
  • Page 358------------------------------------------------------------------------------ 1.26 Read distance to go. ------------------------------------------------------------------------------ [Name] cnc_distance [Syntax] #include #include short cnc_distance( short axis, sho
  • Page 359------------------------------------------------------------------------------ 1.27 Read skipped position. ------------------------------------------------------------------------------ [Name] cnc_skip [Syntax] #include #include short cnc_skip( short axis, short len
  • Page 360[Description] Reads the absolute position data of the controlled axis at the position where the machine has stopped by "ON" of the skip signal during the CNC was executing the skip command (G31) block. It is possible to make the application program which tool length measurement by the application pr
  • Page 361------------------------------------------------------------------------------ 1.28 Read servo delay amount. ------------------------------------------------------------------------------ [Name] cnc_srvdelay [Syntax] #include #include short cnc_srvdelay( short axis,
  • Page 362[Example] The following program displays the servo delay amount of all axes (amount of axes = MAX). #include #include #include void example( void ) { struct iodbaxis buf ; unsigned int idx ; cnc_srvdelay( -1, 4+4*MAX, &buf ) ; for ( idx = 0 ; idx < MAX ; idx++ ) printf
  • Page 363------------------------------------------------------------------------------ 1.29 Read acceleration/deceleration delay amount. ------------------------------------------------------------------------------ [Name] cnc_accdecdly [Syntax] #include #include short cnc_
  • Page 364[Description] Reads the difference between the position commanded by the program and the one processed by acceleration/deceleration procedure of the CNC's controlled axis, i.e. the acceleration/deceleration delay amount. Specify one of (1,..,amount of controlled axes) for each axis or -1 for all axe
  • Page 365------------------------------------------------------------------------------ 1.30 Read dynamic data. ------------------------------------------------------------------------------ [Name] cnc_rddynamic [Syntax] #include #include short cnc_rddynamic( short axis, sho
  • Page 366[Arguments] axis Axis number ( =(1,..,amount of controlled axes),or -1 ). (This is effective to only data who have axis attribute.) length Data block length ( =22+4*4*(Number of axes for which data is to be read) ). buf Buffer in which the dynamic data are stored. [Return] EW_OK( 0) Successful. EW_L
  • Page 367[Example] The following program reads the dynamic data of all axes (amount of axes = MAX) and displays them on the screen. #include #include #include void example( void ) { struct odbdy buf ; unsigned int idx ; cnc_rddynamic( -1, sizeof(buf), &buf ) ; printf( "Current
  • Page 368------------------------------------------------------------------------------ 1.31 Read CNC status information. ------------------------------------------------------------------------------ [Name] cnc_statinfo [Syntax] #include #include short cnc_statinfo( struct
  • Page 369(2) Automatic operation status (run) Value Display Description -------+-------+----------------------------------- 0 **** Reset 1 STOP Automatic operation stopped 2 HOLD Automatic operation suspended 3 STRT Automatic operation started (3) Axis moving/dwelling status (motion) Value Display Descriptio
  • Page 370------------------------------------------------------------------------------ 1.32 Read alarm status. ------------------------------------------------------------------------------ [Name] cnc_alarm [Syntax] #include #include short cnc_alarm( struct odbapb *buf ) ;
  • Page 371------------------------------------------------------------------------------ 1.33 Read alarm information. ------------------------------------------------------------------------------ [Name] cnc_rdalminfo [Syntax] #include #include short cnc_rdalminfo( short type
  • Page 372[Description] Reads the detail informations of currently arising CNC alarms. This function is used for displaying the alarm numbers or messages of the currently arising alarms by the application program, etc. Specify the kind of alarm to be read in "alm_type". alm_type Kind of alarm ---------------+
  • Page 373- type = 1 +-----------------------+ │ Axis information 1 │ <-- buf.u.alm2.alm[0].axis │-----------------------│ │ Alarm number 1 │ <-- buf.u.alm2.alm[0].alm_no │-----------------------│ │ Message length 1 │ <-- buf.u.alm2.alm[0].msg_len │-----------------------│ │ Alarm message 1 │ <-- buf.u.alm2.a
  • Page 374------------------------------------------------------------------------------ 1.34 Read tool offset amount. ------------------------------------------------------------------------------ [Name] cnc_rdtofs [Syntax] #include #include short cnc_rdtofs( short number, s
  • Page 375[Description] Reads the tool offset amount stored in the CNC. Tool wear/geometry offset amounts and cutter radius/tool length offset amounts, etc. can be read. This function is used for the automatic programming function by the application program, for example, which reads the required cutter radius
  • Page 376[Example] The following program reads the wear offset amount for an axis related to each specified tool number. (Lathe series) #include #include #include /* tidx is tool index. */ void example( short tidx ) { struct odbtool buf ; short ret ; ret = cnc_rdtofs( tidx, 0,
  • Page 377------------------------------------------------------------------------------ 1.35 Write tool offset amount. ------------------------------------------------------------------------------ [Name] cnc_wrtofs [Syntax] #include #include short cnc_wrtofs( short number,
  • Page 378[Description] Alters the tool offset amount stored in the CNC. Tool wear/geometry offset amounts and cutter radius/tool length offset amounts, etc. can be written in. This function is used for the preparation of machining or the tool offset measurement by the application program, to write the result
  • Page 379[Example] The following program rewrites an offset amount having a specified number. (Machining center series) #include #include /* tidx is tool index. */ /* offset is new offset value. */ short example( short tidx, long offset ) { short ret ; ret = cnc_wrtofs( tidx, 0, 8, offse
  • Page 380------------------------------------------------------------------------------ 1.36 Read tool offset amount (range specified). ------------------------------------------------------------------------------ [Name] cnc_rdtofsr [Syntax] #include #include short cnc_rdto
  • Page 381[Return] EW_OK( 0) Successful. EW_LENGTH( 2) Incorrect data block length "length". EW_NUMBER( 3) Incorrect offset number "s_number" or "e_number". (This return code is returned in case that any value except 1,..,(maximum number of offset) was specified in offset number "s_number" or "e_number". EW_A
  • Page 382Lathe Series/Tool offset Memory A type length Attribute Offset type Member to be stored in -------+-------+---------------+-----------------------+---------------------- 0 6+2*N individual Virtual tool tip direction buf.u.t_tip[i] 1 6+4*N individual X-axis offset amount buf.u.t_ofs[i] 2 6+4*N indivi
  • Page 383N is number of offset to be read, i = 0,..,(N-1). The offset amounts are stored in "buf.u.xxx[i]" with signed binary format. (The negative value is represented as 2's complement.) The unit of offset amount is as follows. IS-B IS-C -------------------------------+---------------+--------------- Linea
  • Page 384------------------------------------------------------------------------------ 1.37 Write tool offset amount (range specified). ------------------------------------------------------------------------------ [Name] cnc_wrtofsr [Syntax] #include #include short cnc_wrt
  • Page 385[Description] Alters the tool offset amount stored in the CNC within the specified range. Specify the start offset number in "buf.datano_s" and the end one in "buf.datano_e". Specify the kind of offset amount to be read in "type". The combinations of the value specified in "type", the data block len
  • Page 386------------------------------------------------------------------------------ 1.38 Read work origin offset. ------------------------------------------------------------------------------ [Name] cnc_rdzofs [Syntax] #include #include short cnc_rdzofs( short number, s
  • Page 387[Description] Reads the work origin offset amount stored in the CNC. In the CNC, a work origin offset amount is provided for each controlled axis (the first to 32nd controlled axes). The work origin offset amount can be read either for individual axes separately or for all axes at a time. If there i
  • Page 388------------------------------------------------------------------------------ 1.39 Write work origin offset. ------------------------------------------------------------------------------ [Name] cnc_wrzofs [Syntax] #include #include short cnc_wrzofs( short length,
  • Page 389[Description] Alters the work origin offset amount stored in the CNC. In the CNC, a work origin offset amount is provided for each controlled axis (the first to 32nd controlled axes). The work origin offset amount can be rewritten either for individual axes separately or for all axes at a time. If t
  • Page 390[Example] The following program alters the work origin offset amount of the specified offset number and axis number. #include #include /* ofs is offset number to be altered. */ /* axis is the axis number, offset is new offset value. */ short example( short ofs, short axis, long
  • Page 391------------------------------------------------------------------------------ 1.40 Read work origin offset (range specified). ------------------------------------------------------------------------------ [Name] cnc_rdzofsr [Syntax] #include #include short cnc_rdzo
  • Page 392[Description] Reads the work origin offset amount stored in the CNC within the specified range. In the CNC, a work origin offset amount is provided for each controlled axis (the first to 32nd controlled axes). The work origin offset amount can be read either for individual axes separately or for all
  • Page 393The unit of the work origin offset amount is as follows. IS-B IS-C -------------------------------+---------------+--------------- Linear axis (metric input) 0.001 [mm] 0.0001 [mm] Linear axis (inch input) 0.0001 [inch] 0.00001 [inch] Rotation axis 0.001 [deg] 0.0001 [deg] [Example] The following pr
  • Page 394------------------------------------------------------------------------------ 1.41 Write work origin offset (range specified). ------------------------------------------------------------------------------ [Name] cnc_wrzofsr [Syntax] #include #include short cnc_wrz
  • Page 395Specify one of following value as start/end offset number in "buf.datano_s"/"buf.datano_e". datano Kind of work origin offset amount -------+-------------------------------------------- 0 External work origin offset amount 1,..,6 Work origin offset amount of G54 through G59 7,..,306Work origin offse
  • Page 396[Example] The following program alters the work origin offset amount of G54 through G59 for the specified axis. #include #include #include /* axis is axis index to be altered. */ /* offset is array of new offset value. */ short example( short axis, long *offset ) { st
  • Page 397------------------------------------------------------------------------------ 1.42 Read parameter. ------------------------------------------------------------------------------ [Name] cnc_rdparam [Syntax] #include #include short cnc_rdparam( short number, short ax
  • Page 398[Description] Reads the parameter data stored in the CNC. This function is used for reading the various settings of CNC to execute any processes which are equivalent to CNC's by the application program, etc. The attribute of CNC parameter depends on the type and axis, and it is different for each pa
  • Page 399[Example] The following program reads axis names of all controlled axes and displays them. #include #include #include #include void example( void ) { struct iodbpsd buf ; short ret, idx ; ret = cnc_rdparam( 1020, -1, 4+10, &buf ) ; /* standard 10axes */ for
  • Page 400------------------------------------------------------------------------------ 1.43 Write parameter. ------------------------------------------------------------------------------ [Name] cnc_wrparam [Syntax] #include #include short cnc_wrparam( short length, struct
  • Page 401[Description] Alters the parameter data stored in the CNC. This function is used for changing the various settings of CNC by the application program, etc. Even if "PARAMETER WRITE" is "DISABLE" in setting data, it is possible to alter CNC's parameter data. The attribute of CNC parameter depends on t
  • Page 402[Example] The following program rewrites the stroke limit setting for a specified axis. #include #include /* axis is axis index. */ /* plus and minus are plus and minus position of stroke limit. */ short example( short axis, logn plus, long minus ) { struct iodbpsd buf ; short r
  • Page 403------------------------------------------------------------------------------ 1.44 Read parameters (range specified). ------------------------------------------------------------------------------ [Name] cnc_rdparar [Syntax] #include #include short cnc_rdparar( sho
  • Page 404[Return] EW_OK( 0) Successful. EW_LENGTH( 2) Incorrect data block length "length". EW_NUMBER( 3) Incorrect parameter number "s_number" or "e_number". EW_ATTRIB( 4) Incorrect axis number "axis". Any data other than -1, 0 or (1,..,amount of controlled axes) has been specified. [Description] Reads the
  • Page 405Specify one of following values corresponding with each parameter as axis number in "axis". axis Parameter type -----------------------+------------------------------------ 0 Ordinary (none axis type) parameter -1 All axes data of axis type parameter 1,..,amount of One specified axis data of control
  • Page 406[Example] The following program reads parameters in a specified range for a specified axis and displays them on the screen. #include #include #include #include /* start/end are start/end number to be read, axis is axis number. */ short example( short start,
  • Page 407default : printf( " #%d:", ptr->type & 0xff ) ; case 0 : switch ( ptr->type >> 8 ) { case 0: printf( " 0x%02X¥n", (unsigned char)(ptr->u.cdata) ) ; inc = 1+1 ; break ; case 1: printf( " %d¥n", ptr->u.cdata ) ; inc = 1+1 ; break ; case 2: printf( " %d¥n", ptr->u.idata ) ; inc = 2 ; break ; case 3: pr
  • Page 408------------------------------------------------------------------------------ 1.45 Write parameters (multiple output). ------------------------------------------------------------------------------ [Name] cnc_wrparas [Syntax] #include #include short cnc_wrparas( sh
  • Page 409[Return] EW_OK( 0) Successful. EW_LENGTH( 2) Incorrect data block length "length". EW_NUMBER( 3) Incorrect parameter number "buf.datano". EW_ATTRIB( 4) Incorrect axis number "buf.type". Any data other than -1, 0 or (1,..,amount of controlled axes) has been specified. EW_PROT( 7 ) Write operation is
  • Page 410Store the parameters to be written in "buf" in following order. The data structure is same as "Read parameters(range specified) (cnc_rdparar)". +-----------------------+ │ Parameter number 1 │ <-- buf[0].datano │-----------------------│ │ Type 1 │ <-- buf[0].type │-----------------------│ │ Data 1 │
  • Page 411[Example] The following program specifies that M code Nos. 6080 to 6089 be subjected to a macro call. #include #include #include /* mcode is 10 M-code values to be set. */ short example( short *mcode ) { struct iodbpsdr *buf, *ptr ; short ret, idx ; buf = (struct iodb
  • Page 412------------------------------------------------------------------------------ 1.46 Read setting parameter. ------------------------------------------------------------------------------ [Name] cnc_rdset [Syntax] #include #include short cnc_rdset( short number, shor
  • Page 413[Description] Reads the setting parameter stored in the CNC. This function is used for getting the information of I/O device from the setting parameter to input/output via Reader/Puncher interface of CNC by the application program, etc. The attribute of setting data depends on the type and axis, and
  • Page 414[Example] The following program changes the input unit to inch. #include #include void example( void ) { struct iodbpsd buf ; cnc_rdset( 0, 0, 4+1*1, &buf ) ; *buf.u.cdata │= 0x04 ; cnc_wrset( 4+1*1, &buf ) ; }
  • Page 415------------------------------------------------------------------------------ 1.47 Write setting parameter. ------------------------------------------------------------------------------ [Name] cnc_wrset [Syntax] #include #include short cnc_wrset( short length, str
  • Page 416[Description] Alters the setting parameter stored in the CNC. Even if "PARAMETER WRITE" is "DISABLE" in setting parameter, it is possible to alter CNC's setting parameter. This function is used for changing the setting of I/O device by the application program, etc. The attribute of setting data depe
  • Page 417------------------------------------------------------------------------------ 1.48 Read setting parameters (range specified). ------------------------------------------------------------------------------ [Name] cnc_rdsetr [Syntax] #include #include short cnc_rdset
  • Page 418[Return] EW_OK( 0) Successful. EW_LENGTH( 2) Incorrect data block length "length". EW_NUMBER( 3) Incorrect setting parameter number "s_number" or "e_number". EW_ATTRIB( 4) Incorrect axis number "axis". Any data other than -1, 0 or (1,..,amount of controlled axes) has been specified. [Description] Re
  • Page 419Specify one of following values corresponding with each setting parameter as axis number in "axis". axis Setting parameter type -----------------------+------------------------------------ 0 Ordinary (none axis type) parameter -1 All axes data of axis type parameter 1,..,amount of One specified axis
  • Page 420The setting parameter data is stored in "Data". The setting parameter data of none axis type setting parameter or the axis type setting parameter data which was read for one specified axis is stored in "buf[i].u.cdata/idata/ldata/rdata". The axis type setting parameters which were read for all axes
  • Page 421------------------------------------------------------------------------------ 1.49 Write setting parameters (multiple output). ------------------------------------------------------------------------------ [Name] cnc_wrsets [Syntax] #include #include short cnc_wrse
  • Page 422[Description] Alters the multiple setting parameter data stored in the CNC. Even if "PARAMETER WRITE" is "DISABLE" in setting data, it is possible to alter CNC's setting parameter data. The attribute of setting data depends on the type and axis, and it is different for each setting data. It is as fo
  • Page 423Store the setting parameter number in "Setting param. Number i" (buf[i].datano) with binary format. Store the setting parameter type in the upper byte of "Data i" (buf[i].type) and the axis type in the lower byte. Type (upper byte) Parameter type -----------------------+---------------- 0 Bit 1 Byte
  • Page 424------------------------------------------------------------------------------ 1.50 Read pitch error compensation data (range specified). ------------------------------------------------------------------------------ [Name] cnc_rdpitchr [Syntax] #include #include sh
  • Page 425[Example] The following program reads the pitch error compensation data within the specified number range and displays them. #include #include #include #include /* start/end are start/end number to be read. */ short example( short start, short end ) { struct
  • Page 426------------------------------------------------------------------------------ 1.51 Write pitch error compensation data (range specified). ------------------------------------------------------------------------------ [Name] cnc_wrpitchr [Syntax] #include #include s
  • Page 427[Example] The following program alters the pitch error compensation data within the specified number range. #include #include #include /* start/end are start/end number to be written. */ /* data is array of value to be written. */ short example( short start, short end
  • Page 428------------------------------------------------------------------------------ 1.52 Read custom macro variable. ------------------------------------------------------------------------------ [Name] cnc_rdmacro [Syntax] #include #include short cnc_rdmacro( short numb
  • Page 429[Description] Reads the custom macro variable data stored in the CNC. This function is used for controlling flow of the machining program of CNC by the application program exchanging data between the custom macro program in CNC and the application program, etc. Types of custom macro variable are as
  • Page 430[Example] The following program reads the custom macro variable data of specified number and displays it. #include #include #include #include /* number is variable number to be read. */ short example( short number ) { struct odbm buf ; char strbuf[11] ; shor
  • Page 431------------------------------------------------------------------------------ 1.53 Write custom macro variable. ------------------------------------------------------------------------------ [Name] cnc_wrmacro [Syntax] #include #include short cnc_wrmacro( short num
  • Page 432Refer "USER'S MANUAL" of CNC for details of custom macro variables. Specify the custom macro variable number to be written in "number" with binary format. Specify variable data to be written in both "mcr_val" and "dec_val". mcr_val 4-byte singed binary format data. (The negative value is represented
  • Page 433------------------------------------------------------------------------------ 1.54 Read custom macro variables (range specified). ------------------------------------------------------------------------------ [Name] cnc_rdmacror [Syntax] #include #include short cnc
  • Page 434[Description] Reads the custom macro variable data stored in the CNC within the specified range. Types of custom macro variable are as follows. (1) Local variables ( #1,..,#33 ) Not readable. (Use cnc_rdmacro function.) (2) Common variables ( #100,..,#149, #500,..,#531 ) Readable. In case that Custo
  • Page 435[Example] The following program reads the custom macro variables within the specified range and displays them. #include #include #include #include #include /* start/end are start/end variable number to be read. */ short example( short start, short
  • Page 436------------------------------------------------------------------------------ 1.55 Write custom macro variables (range specified). ------------------------------------------------------------------------------ [Name] cnc_wrmacror [Syntax] #include #include short cn
  • Page 437[Description] Writes the custom macro variable data stored in the CNC within the specified range. Types of custom macro variable are as follows. (1) Local variables ( #1,..,#33 ) Not writable. (Use cnc_wrmacro function.) (2) Common variables ( #100,..,#149, #500,..,#531 ) Writable. In case that Cust
  • Page 438------------------------------------------------------------------------------ 1.56 Read P-code macro variable. ------------------------------------------------------------------------------ [Name] cnc_rdpmacro [Syntax] #include #include short cnc_rdpmacro( long num
  • Page 439Specify the P-code macro variable number to be read in "number" with binary format. The variable data is stored in both "buf.u.p6.mcr_val" and "buf.u.p6.dec_val". mcr_val 4-byte singed binary format data. (The negative value is represented as 2's complement.) Variable value converted into integer. d
  • Page 440------------------------------------------------------------------------------ 1.57 Write P-code macro variable. ------------------------------------------------------------------------------ [Name] cnc_wrpmacro [Syntax] #include #include short cnc_wrpmacro( long nu
  • Page 441The following values are stored concretely. (These are same as format of cnc_rdpmacro() function.) Value to be written mcr_val dec_val ---------------+---------------+-------- void 0 -1 0.000 0 3 0.0000001 1 7 0000.0001 1 4 00000.100 100 3 00001.000 1000 3 00010.000 10000 3 100000.00 10000000 2 9999
  • Page 442------------------------------------------------------------------------------ 1.58 Read P-code macro variables (range specified). ------------------------------------------------------------------------------ [Name] cnc_rdpmacror [Syntax] #include #include short cn
  • Page 443[Description] Reads the macro executor variable (P-code macro variable) data within the specified range. Specify the start P-code macro variable number in "s_number" and the end one in "e_number" with binary format. The variable data is stored in both "buf.pr_m[i].p6_r.mcr_val" and "buf.pr_m[i].p6_r
  • Page 444------------------------------------------------------------------------------ 1.59 Write P-code macro variables (range specified). ------------------------------------------------------------------------------ [Name] cnc_wrpmacror [Syntax] #include #include short c
  • Page 445[Description] Writes the macro executor variable (P-code macro variable) data within the specified range. Specify the start custom macro variable number in "buf.datano_s" and the end one in "buf.datano_e" with binary format. Store the variable data to be written in both "buf.pm_r[i].p6_r.mcr_val" an
  • Page 446------------------------------------------------------------------------------ 1.60 Read modal data. ------------------------------------------------------------------------------ [Name] cnc_modal [Syntax] #include #include short cnc_modal( short type, short block,
  • Page 447[Return] EW_OK( 0) Successful. EW_NUMBER( 3) Incorrect kind of data "type". EW_ATTRIB( 4) Incorrect objective block "block". EW_BUSY(-1) It was impossible to read modal information because the CNC was updating the modal information. [Description] Reads the modal information of CNC. The readable moda
  • Page 448(1) Reading modal G code. The G code group listed below can be specified as the type. Machining Lathe Series Center Series -------+-------+---------------+-----------------------+ G code type g_data G code System A System B System C -------+-------+---------------+---------------+-------+ 0 0 G00 G0
  • Page 449Machining Lathe Series Center Series -------+-------+---------------+-----------------------+ G code type g_data G code System A System B System C -------+-------+---------------+---------------+-------+ 6 0 G40 G40 G40 G40 1 G41 G41 G41 G41 2 G42 G42 G42 G42 3 G41.2 G41.2 G41.2 G41.2 4 G42.2 G42.2
  • Page 450Machining Lathe Series Center Series -------+-------+---------------+-----------------------+ G code type g_data G code System A System B System C -------+-------+---------------+---------------+-------+ 11 0 G67 G67 G67 G67 1 G66 G66 G66 G66 2 G66.1 G66.1 G66.1 G66.1 -------+-------+---------------
  • Page 451The numbers in the g_data column of the above table are stored to bits 0 to 6 of buf.modal.g_data in binary form. Bit 7 of buf.modal.g_data is used to store information about whether this G code is specified in a read target block specified in "block". 7 6 5 4 3 2 1 0 ┌─┬─┬─┬─┬─┬─┬─┬─┐ ┌┼・│ Code in
  • Page 452(2) Reading modal data other than B code. type Address -------+------------------------ 100 B (2nd auxiliary function) 101 D 102 - (Reserved) 103 F 104 H [M] 105 L 106 M 107 S 108 T 109 R [M] 110 P [M] 111 Q [M] 112 A 113 C 114 I 115 J 116 K 117 N 118 O 119 U 120 V 121 W 122 X 123 Y 124 Z 125 M (2nd
  • Page 453┌───────────────┐ │ Data │ : 4 bytes ├───────────────┤ ┌─│ FLAG1 │ : 1 byte │ ├───────────────┤ ┌┼─│ FLAG2 │ : 1 byte ││ └───────────────┘ ││ 7 6 5 4 3 2 1 0 ││ ┌─┬─┬─┬─┬─┬─┬─┬─┐ │└→│ │ │ │−│Number of │ │ │ │ │ │ │input digits │ │ └─┴─┴─┴─┴─┴─┴─┴─┘ │ │ │ ├─→ 0 : The data is positive. │ │ │ └─→ 1 : T
  • Page 454(3) Reading modal data for one-shot G codes Machining Lathe Series Center Series -------+-------+---------------+-----------------------+ G code type g_data G code System A System B System C -------+-------+---------------+---------------+-------+ 300 0 G04 G04 G04 G04 1 G10 G27 G27 G27 2 G28 G28 G2
  • Page 455Machining Lathe Series Center Series -------+-------+---------------+-----------------------+ G code type g_data G code System A System B System C -------+-------+---------------+---------------+-------+ 116 G91.1 G38 G38 G38 119 G43.6 G43.6 G43.6 120 G50.4 G50.4 G50.4 121 G50.5 G50.5 G50.5 122 G50.
  • Page 456------------------------------------------------------------------------------ 1.61 Read diagnostics data. ------------------------------------------------------------------------------ [Name] cnc_diagnoss [Syntax] #include #include short cnc_diagnoss( short number,
  • Page 457[Description] Reads the contents of data displayed in the diagnostics screen of CNC. The attribute of diagnosis depends on the type and axis, and it is different for each diagnosis. Diagnosis type Use Byte size -----------------------+-------------------------------+--------- Byte type data To displ
  • Page 458Reference Types of diagnostics data displayed on the CNC screen Diagnosis number Type -----------------------+--------------- 000 to 006 Byte 010 to 015 Byte 020 to 025 Byte 030 to 031 Byte 200 to 204 Byte axis 280 Byte axis 300 to 302 2-word axis 380 to 381 Word axis 400 to 402 Byte 408 to 409 Byte
  • Page 459[Example] The following program reads information about what operation status the CNC is in and displays the information on the screen. #include #include #include void example( void ) { short dgn_no[] = { 0,1,2,3,4,5,6,10,11,12,13,14,15 } ; char *dgn_msg[] = { "WAITING
  • Page 460------------------------------------------------------------------------------ 1.62 Read diagnostics data (range specified). ------------------------------------------------------------------------------ [Name] cnc_diagnosr [Syntax] #include #include short cnc_diagn
  • Page 461[Description] Reads the contents of data displayed in the diagnostics screen of CNC within the specified range. The attribute of diagnosis depends on the type and axis, and it is different for each diagnosis. Diagnosis type Use Byte size -----------------------+-------------------------------+------
  • Page 462The read diagnostics data are stored in "buf" in following order. +-----------------------+ │ Data number 1 │ <-- buf[0].datano │-----------------------│ │ Type 1 │ <-- buf[0].type │-----------------------│ │ Data 1 │ <-- buf[0].u.cdata/idata/ldata/ │ │ cdatas/idatas/ldatas │-----------------------│
  • Page 463[Example] The following program reads diagnose data in a specified range for a specified axis and displays it on the screen. #include #include #include #include /* start/end are start/end number to be read. */ /* axis is axis number. */ short example( short
  • Page 464default : printf( " #%d:", ptr->type & 0xff ) ; case 0: switch ( ptr->type >> 8 ) { case 0: printf( " %02X¥n", ptr->u.cdata ) ; inc = 2 ; break ; case 1: printf( " %d¥n", ptr->u.idata ) ; inc = 2 ; break ; case 2: printf( " %ld¥n", ptr->u.ldata ) ; inc = 4 ; break ; } ptr = (struct iodbpsdr *)(((cha
  • Page 465------------------------------------------------------------------------------ 1.63 Read A/D conversion data. ------------------------------------------------------------------------------ [Name] cnc_adcnv [Syntax] #include #include short cnc_adcnv( short inp_type,
  • Page 466[Description] Reading the load information of the controlled axis of the CNC. Reads the load current data of the controlled axis of the CNC which is converted into analog voltage via A/D converter. Specify "2" in "inp_type". Specify the controlled axis number of the CNC whose load information is rea
  • Page 467------------------------------------------------------------------------------ 1.64 Read operator's message. ------------------------------------------------------------------------------ [Name] cnc_rdopmsg [Syntax] #include #include short cnc_rdopmsg( short type ,
  • Page 468[Example] The following program reads the operator's message and displays it. #include #include #include void example( void ) { struct msg buf ; cnc_rdopmsg( 0, 6+256, &buf ) ; if ( buf.datano != -1 ) printf( "%04d %s¥n", buf.datano, buf.data ) ; else printf( "No opera
  • Page 469------------------------------------------------------------------------------ 1.65 Set path index (multi-path system). ------------------------------------------------------------------------------ [Name] cnc_setpath [Syntax] #include #include short cnc_setpath( in
  • Page 470[Example] The following program sets up a specified path and processing target path. #include #include #include /* path is new path number to be set. */ short example( short path ) { short ret ; ret = cnc_setpath( path ) ; if ( !ret ) printf( "PATH #%d has been set as
  • Page 471------------------------------------------------------------------------------ 1.66 Get path index (multi-path system). ------------------------------------------------------------------------------ [Name] cnc_getpath [Syntax] #include #include short cnc_getpath( sh
  • Page 472------------------------------------------------------------------------------ 1.67 Set calendar timer of CNC. ------------------------------------------------------------------------------ [Name] cnc_settimer [Syntax] #include #include short cnc_settimer( struct io
  • Page 473[Description] Sets the date or time data to the calendar timer device of the CNC unit. CNC software and C library read date and time from the calendar timer device of the CNC unit. This function set the date and time data to that calendar timer device. Specify one of following values in "buf.type".
  • Page 474[Example] The following program sets the calendar/timer with the date and time entered using keys. #include #include #include short example( void ) { struct iodbtimer buf ; short ret, year, month, date, hour, minute, second ; printf( "Year =" ) ; scanf( "%d", &year ) ;
  • Page 475------------------------------------------------------------------------------ 1.68 Read load information of serial spindle. ------------------------------------------------------------------------------ [Name] cnc_rdspload [Syntax] #include #include short cnc_rdspl
  • Page 476[Example] The following program reads information about the load on the first spindle and displays the load ratio on the screen. #include #include #include short example( void ) { struct iodbpsd prm ; struct odbspn buf ; short ret ; long val ; cnc_rdparam( 4127, 1, 4+2
  • Page 477------------------------------------------------------------------------------ 1.69 Read executing program. ------------------------------------------------------------------------------ [Name] cnc_rdexecprog [Syntax] #include short cnc_rdexecprog( unsigned short *length, sh
  • Page 478* Executing NC program. O1234 ; N10 G0 X10. Y20. Z30. ; <-- This function is called when N20 G0 X20. Y30. Z40. ; this block is being executed. N30 G0 X30. Y40. Z50. ; N40 G0 X40. Y50. Z60. ; M30 ; % * String to be read. "N10G0X10.Y20.Z30.¥n" "N20G0X20.Y30.Z40.¥n" "N30G0X30.Y40.Z50.¥n" "N40G0X40.Y50.
  • Page 479[Example] The following program displays an NC program being currently executed on the screen. #include #include #include #include #define BUFLEN 200 void example( void ) { short ret, blknum ; unsigned short length, idx, lcount, num1, num2 ; char ch, data[BUF
  • Page 480------------------------------------------------------------------------------ 1.70 Read manual handle override amount. ------------------------------------------------------------------------------ [Name] cnc_rdmovrlap [Syntax] #include #include short cnc_rdmovrlap
  • Page 481data[1][0] - data[1][7] (Output unit) IS-B IS-C -------------------------------+---------------+--------------- Linear axis (metric output) 0.001 [mm] 0.0001 [mm] Linear axis (inch output) 0.0001 [inch] 0.00001 [inch] Rotation axis 0.001 [deg] 0.0001 [deg] The array size of each members of "iodbovl.
  • Page 4822. PMC window library ------------------------------------------------------------------------------ 2.1 Read arbitrary PMC data (range specified). ------------------------------------------------------------------------------ [Name] pmc_rdpmcrng [Syntax] #include #include
  • Page 483[Description] Reads the PMC data within the specified address range. This function is used for exchanging various data between the C application and the PMC ladder software. Specify the discrimination code corresponding to the PMC address to be read in "adr_type". The discrimination code is either a
  • Page 484The referenceable range of PMC data of FANUC Series 30i I.D. code Kind of PMC address ---------------+----------------------- 0,'G' G (PMC->CNC) 1,'F' F (CNC->PMC) 2,'Y' Y (PMC->Machine) 3,'X' X (Machine->PMC) 4,'A' A (Message request) 5,'R' R (Relay) 6,'T' T (Timer) 7,'K' K (Keep relay) 8,'C' C (Co
  • Page 485------------------------------------------------------------------------------ 2.2 Write arbitrary PMC data (range specified). ------------------------------------------------------------------------------ [Name] pmc_wrpmcrng [Syntax] #include #include short pmc_wrp
  • Page 486[Description] Writes the PMC data within the specified address range. This function is used for exchanging various data between the C application and the PMC ladder software. Specify the discrimination code corresponding to the PMC address to be written in "buf.type_a". The discrimination code is ei
  • Page 487Example of arguments specification (1) Writing 250 to "D0100" (Word type data). buf.type_a 9 or 'D' buf.type_d 1 buf.datano_s 100 buf.datano_e 101 length 8+2*1 (=10) buf.u.idata[0] 250 (2) Writing 0 to every "R0200" through "R0209" (Byte type data). buf.type_a 5 or 'R' buf.type_d 0 buf.datano_s 200
  • Page 488------------------------------------------------------------------------------ 2.3 Read PMC message. ------------------------------------------------------------------------------ [Name] pmc_rdpcmsg [Syntax] #include #include short pmc_rdpcmsg( unsigned short adr_no
  • Page 489[Example] The following program reads all PMC message character strings and displays them on the screen. #include #include #include #include void example( void ) { short ret ; unsigned short idx, bit ; struct pmcmsg *buf ; buf = (struct pmcmsg *)malloc( size
  • Page 4903.5 MDI operation library ========================= Library outline 1. Outline The application program can control the MDI-KEY using the MDI operation library. 2. MDI key matrix (1) Structure of matrix MDI key matrix is a table where the relationship of the MDI key bit matrix which is defined by the
  • Page 491(2) Structure of function flag The function flag is one byte flag which defines attributes of key for every key. This flag defines following items bit by bit. Bit Symbol definition -------+-------+---------------------------------------------------- 7 F Enabling/disabling key repeat. (effective when
  • Page 4923. Key input by application program (1) Functions The application program can send an arbitrary character or string to the key input buffer of the MDI-KEY by calling following functions. aux_mdi_putc() Output one character. aux_mdi_write() Output a string. These character and string are received reg
  • Page 4934. MDI key control in case that both C Executor and Open-CNC or Intelligent Terminal exist. When one of Open-CNC or Intelligent Terminal is present, MDI key data is processed as follows. (A) When Open-CNC is present. MDI operation library of C Library can handle only key information input to C User
  • Page 494Lists of Functions ---------------------------------------------------------------------- Name Function ---------------------------------------------------------------------- 1. aux_mdi_getmatrix Get MDI key matrix. 2. aux_mdi_putmatrix Put MDI key matrix. 3. aux_mdi_rstmatrix Reset MDI key matrix.
  • Page 495Function Reference ------------------------------------------------------------------------------ 1. Get MDI key matrix. ------------------------------------------------------------------------------ [Name] aux_mdi_getmatrix [Syntax] #include int aux_mdi_getmatrix( void *matrix
  • Page 496------------------------------------------------------------------------------ 2. Put MDI key matrix. ------------------------------------------------------------------------------ [Name] aux_mdi_putmatrix [Syntax] #include int aux_mdi_putmatrix( void *matrix_ptr, int matrix_le
  • Page 497------------------------------------------------------------------------------ 3. Reset MDI key matrix. ------------------------------------------------------------------------------ [Name] aux_mdi_rstmatrix [Syntax] #include int aux_mdi_rstmatrix( int module_id ) ; [Arguments]
  • Page 498------------------------------------------------------------------------------ 4. Alter MDI key matrix. ------------------------------------------------------------------------------ [Name] aux_mdi_altmatrix [Syntax] #include int aux_mdi_altmatrix( int module_id, int category,
  • Page 499Specify updating specification of key in "update". upper byte of "update" <- current code lower byte of "update" <- new code The specified key is set as "invalid key" by specifying "NULL(0x00)" as new code. It is impossible to alter the RESET key. (2) Altering character attribute. Alters the attribu
  • Page 500------------------------------------------------------------------------------ 5. Put one character to key input buffer. ------------------------------------------------------------------------------ [Name] aux_mdi_putc [Syntax] #include int aux_mdi_putc( int c ) ; [Arguments]
  • Page 501------------------------------------------------------------------------------ 6. Write block data to key input buffer. ------------------------------------------------------------------------------ [Name] aux_mdi_write [Syntax] #include int aux_mdi_write( void *buffer, int siz
  • Page 502------------------------------------------------------------------------------ 7. Test or control key input buffer. ------------------------------------------------------------------------------ [Name] aux_mdi_control [Syntax] #include int aux_mdi_control( int control ) ; [Argu
  • Page 503------------------------------------------------------------------------------ 8. Set key repeating interval time. ------------------------------------------------------------------------------ [Name] aux_mdi_repeat [Syntax] #include int aux_mdi_repeat( int delay, int repeat )
  • Page 504------------------------------------------------------------------------------ 9. Read inputting status of MDI key. ------------------------------------------------------------------------------ [Name] aux_mdi_getstat [Syntax] #include unsigned int aux_mdi_getstat( void ) ; [Ar
  • Page 505[Example] The following program reads a line of alpha-numeric characters from the MDI panel. Inputting operation is completed by inputting [INPUT] key. It displays one of '_' (in normal state) and '^' as cursor. #include #include #include #define BUFSIZE 80 unsigned char
  • Page 506------------------------------------------------------------------------------ 10. Clear input buffer of MDI key. ------------------------------------------------------------------------------ [Name] aux_mdi_clrbuf [Syntax] #include void aux_mdi_clrbuf( void ) ; [Arguments] ---
  • Page 507Key code table The following are the key code table of various keyboard which are supported by C Executor. Lines and columns of "Key bit matrix", "Key function flag table" and "Key code table" are correspond each other in every keyboard. For example, to get key code and function flag for C applicati
  • Page 508Reading extension MDI keys Setting bit 2 (EKY) of parameter No. 8650 in the NC to 1 causes the key BIOS of the C executor to scan the extension MDI keys. If a user application assigns key codes to the extension of the key matrix, the assigned keys can be read. (If no key code is specified, it is imp
  • Page 5091. 30i QWERTY MDI Key bit matrix bit= 0 1 2 3 4 5 6 7 +------+------+------+------+------+------+------+------+ 0 │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ +------+------+------+------+------+------+------+------+ 1 │ 8 │ 9 │ - + │ . , │ CTRL │DELETE│ EOB │ ALT │ +------+------+------+------+------+------+-
  • Page 510Key code table for CNC +0 +2 +4 +6 +8 +A +C +E ----+------+------+------+------+------+------+------+------ 60 │ 30 3D 31 82 32 83 33 8C 34 8D 35 A9 36 00 37 00 70 │ 38 AA 39 AB 2D 2B 2E 2C 9B 9B 95 95 0A 0A 97 97 80 │ 96 99 94 94 9C 9C 98 98 9A 9A 84 85 88 88 89 89 90 │ E8 E1 E9 E1 EA E1 EB E1 EC E
  • Page 5112. 30i ONG MDI (M series) Key bit matrix bit= 0 1 2 3 4 5 6 7 +------+------+------+------+------+------+------+------+ 0 │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ +------+------+------+------+------+------+------+------+ 1 │ 8 │ 9 │ - │ ・ │ CTRL │DELETE│ EOB │ ALT │ +------+------+------+------+------+----
  • Page 512Key code table for CNC +0 +2 +4 +6 +8 +A +C +E ----+------+------+------+------+------+------+------+------ 60 │ 30 00 31 82 32 83 33 8C 34 8D 35 A9 36 00 37 00 70 │ 38 AA 39 AB 2D 2D 2E 2E 9B 9B 95 95 0A 0A 97 97 80 │ 96 99 94 94 9C 9C 98 98 9A 9A 84 85 88 88 89 89 90 │ E8 E1 E9 E1 EA E1 EB E1 EC E
  • Page 5133. 30i ONG MDI (T series) Key bit matrix bit= 0 1 2 3 4 5 6 7 +------+------+------+------+------+------+------+------+ 0 │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ +------+------+------+------+------+------+------+------+ 1 │ 8 │ 9 │ - │ ・ │ CTRL │DELETE│ EOB │ ALT │ +------+------+------+------+------+----
  • Page 514Key code table for CNC +0 +2 +4 +6 +8 +A +C +E ----+------+------+------+------+------+------+------+------ 60 │ 30 00 31 82 32 83 33 8C 34 8D 35 A9 36 00 37 00 70 │ 38 AA 39 AB 2D 2D 2E 2E 9B 9B 95 95 0A 0A 97 97 80 │ 96 99 94 94 9C 9C 98 98 9A 9A 84 85 88 88 89 89 90 │ E8 E1 E9 E1 EA E1 EB E1 EC E
  • Page 5153.6 CRT operation library ========================= Supported display device C Executor supports the following display devices. VGA Display Character 80-column x 25-line/half-size (40-column x 25-line/ full-size) x 16-color. 80-column x 30-line/half-size (40-column x 30-line/ full-size) x 16-color.
  • Page 516Lists of Functions 1. CRT operation library -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1.1 crt_getcurscrn Get current screen index. 1.2 crt_setuserscrn Register user screen index.
  • Page 5172. Multiple window display library -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 2.1 win_open Open window. 2.2 win_close Close window. 2.3 win_select Select window. 2.4 win_activate
  • Page 518Function Reference 1. CRT operation library ------------------------------------------------------------------------------ 1.1 Get current screen index. ------------------------------------------------------------------------------ [Name] crt_getcurscrn [Syntax] #include int crt
  • Page 519Screen index number of FS30i Symbol Index number Screen ---------------+---------------+------------------------------- CRT_POS_ABS 0x0100 ABS CRT_POS_REL 0x0200 REL CRT_POS_ALL 0x0300 ALL CRT_POS_HNDL 0x0400 HNDL CRT_POS_MONI 0x0600 MONITOR CRT_POS_5AX 0x0700 5AXMAN CRT_POS_CEXE 0x3200 C
  • Page 520 CRT_SYS_PRM 0x0103 PARAM CRT_SYS_DGN 0x0203 DGNOS CRT_SYS_SRVGUID 0x0303 SERVO GUIDEM CRT_SYS_SYS 0x0403 SYSTEM CRT_SYS_MEM 0x0603 MEMORY CRT_SYS_PIT 0x0703 PITCH CRT_SYS_SVPR 0x0803 SV-PRM CRT_SYS_SPPR 0x0903 SP.SET CRT_SYS_MAINTENANCE 0x0b03 PMC MAINTE CRT_SYS_LADDER 0x0c03 PMC LADDER CRT
  • Page 521[Example] The following program displays the index number of the current screen. #include #include void example( void ) { int scrn ; scrn = crt_getcurscrn() ; printf( "Current screen index is %02X-%02X¥n", scrn & 0xFF, scrn >> 8 ) ; }
  • Page 522------------------------------------------------------------------------------ 1.2 Register user screen index.
    ------------------------------------------------------------------------------ [Name] crt_setuserscrn [Syntax] #include int crt_setuserscrn( int num, int *scrntbl ) ; [Argume
  • Page 523This function doesn't check integrity of the screen index numbers to be registered. Re-registration of the user screen index numbers by calling of this function again is allowable. In this case, this function must be called under condition that any screen switching is disabled by "crt_setswt" functi
  • Page 524------------------------------------------------------------------------------ 1.3 Test screen switching status. ------------------------------------------------------------------------------ [Name] crt_isnewscrn [Syntax] #include int crt_isnewscrn( void ) ; [Arguments] ------ [
  • Page 525------------------------------------------------------------------------------ 1.4 Get CRT information. ------------------------------------------------------------------------------ [Name] crt_gettype [Syntax] #include unsigned int crt_gettype( void ) ; [Arguments] ------ [Retu
  • Page 526bit9 0: 7.2-inch or 8.4-inch LCD. 1: 9-inch CRT. (CRT_TYPE_VCRT) (This bit indicates the kind of display device of 9-inch VGA display. This bit is always set as "0".) bit10 0: Normal display 1: Extended and reduced display (CRT_TYPE_V9MD2) (This bit is always set as "0".) bit11 0: VGA Display 1: Cha
  • Page 527------------------------------------------------------------------------------ 1.5 Set CRT screen mode. ------------------------------------------------------------------------------ [Name] crt_setmode [Syntax] #include int crt_setmode( unsigned int mode ) ; [Arguments] mode CRT
  • Page 528"Upper blank:n" in VGA Display is, +---------------------------------+ +- │ Blank of n lines │ │ │---------------------------------│ │ │Start line ^ │ -+ │ │ │ │ │ │ │ │ │ │ 30 lines │ │ │ │ │ (19 lines)│ │ │ Display region │ │ 25 lines │ │ │ │ │(16 lines) │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ v │ -+ +-
  • Page 529------------------------------------------------------------------------------ 1.6 Switch to CNC screen. ------------------------------------------------------------------------------ [Name] crt_cncscrn [Syntax] #include int crt_cncscrn( int index ) ; [Arguments] index Index num
  • Page 530[Example] The following program changes into "PROGRAM CHECK" screen if the current mode is "MEM". #include #include #include void example( void ) { struct odbst stat ; cnc_statinfo( &stat ) ; if ( stat.aut == 1 ) crt_cncscrn( CRT_PRG_PCHK ) ; }
  • Page 531------------------------------------------------------------------------------ 1.7 Output character by FANUC character code.
    ------------------------------------------------------------------------------ [Name] crt_fchar [Syntax] #include int crt_fchar( unsigned int code ) ; [Argument
  • Page 532[Example] The following program displays the specified integer value using bold numeric characters. #include #include #include void example( unsigned int val ) { int idx ; char buf[6] ; sprintf( buf, "%u", val ) ; for ( idx = 0 ; idx < strlen( buf ) ; idx++ ) crt_fchar(
  • Page 533------------------------------------------------------------------------------ 1.8 Customize softkey on CNC screen.
    ------------------------------------------------------------------------------ [Name] crt_setuserskey [Syntax] #include int crt_setuserskey( unsigned int index, unsigned
  • Page 534Softkey index number is the sequential number for each softkey tables. For example, the following sequential numbers are assigned to the softkeys on the POSITION screen. Key Softkey index number ---------------+--------------------- [ ABS ] 1 [ REL ] 2 [ ALL ] 3 [ HNDL ] 4 Available operations are "
  • Page 535CNC original softkey table The following list includes the original softkey display items of FS30i. Softkeys shown in the left side are defined for screen selection in each screens (and each modes). The numbers shown in the right side are the small classification numbers of the screen which is selec
  • Page 536SYSTEM [ PARAM ][ DGNOS ][SERVO GUIDEM][ SYSTEM ][ ] [ MEMORY ][ PITCH ][ SV-PRM ][ SP.SET ][ ] [ PMC MAINTE ][ PMC LADDER ][ PMC CONFIG ][ ][ ] [ M-TUN ][ ALL IO ][ ALL IO ][ OPEHIS ][ ] [ COLOR ][ MAINTE ][ M-INFO ][ W.DGNS ][ ] [ ][ FSSB ][ PRMTUN ][ ][ ] [ EMBED PORT ][ PCMCIA LAN ][ETHER BOARD
  • Page 537How to define display string of the softkey The display string of the softkey must be defined by FANUC code when softkey item is customized using this function. (1) Define array of "int" type(or "unsigned int" type). The total number of elements is 12( 6 characters x 2-line). The exceeded elements a
  • Page 538[Example] This is procedure to customize the softkey of POSITION screen as follows. Original [ ALL ][ REL ][ ABS ][ MCN ] After customizing [ USER ][ ALL ][ ABS ][ ] 1. Define a string " USER " by FANUC character code. unsigned int skey_str[] = { 0x0020,0x0055,0x0053,0x0045,0x0052,0x0020, /* " USER
  • Page 539------------------------------------------------------------------------------ 1.9 Set switching method between CNC's screen and user's. ------------------------------------------------------------------------------ [Name] crt_setswt [Syntax] #include unsigned int crt_setswt( un
  • Page 540bit5 The automatic graphic beam ON when the screen is switched from the CNC to the user's is 0: not executed. 1: executed. (only when the graphic beam is enabled on the previous user's screen.) (CRT_SWT_GRON) bit6 For VGA Display, the contents of the user screen is saved and restored at the switchin
  • Page 541------------------------------------------------------------------------------ 1.10 Set scroll area.
    ------------------------------------------------------------------------------ [Name] crt_setscrlarea [Syntax] #include int crt_setscrlarea( unsigned int start, unsigned int height ) ;
  • Page 542------------------------------------------------------------------------------ 1.11 Open graphic display.
    ------------------------------------------------------------------------------ [Name] crt_opengr [Syntax] #include int crt_opengr( void ) ; [Arguments] ------ [Return] Returns "0"
  • Page 543When screen is switched from the user screen to the CNC screen while displaying application graphics, graphic display to the CRT is disabled (BEAM OFF). However, the graphics drawn by the user application program is retained as is, provided no graphic screen is displayed by CNC. When screen is switc
  • Page 544------------------------------------------------------------------------------ 1.12 Close graphic display.
    ------------------------------------------------------------------------------ [Name] crt_closegr [Syntax] #include void crt_closegr( void ) ; [Arguments] ------ [Return] ------
  • Page 545------------------------------------------------------------------------------ 1.13 Enable or disable graphic display. ------------------------------------------------------------------------------ [Name] crt_graphic [Syntax] #include int crt_graphic( int mode ) ; [Arguments] mo
  • Page 546[Example] Following program tests the current screen, and turns the "GRAPHIC BEAM" on if it is POSITION display screen. Turns the "GRAPHIC BEAM" off if else. #include void example( void ) { int scrn ; scrn = crt_getcurscrn() ; if ( ( scrn & 0xFF ) == ( CRT_POS_ABS & 0xFF ) ) crt_graphic( CRT
  • Page 547------------------------------------------------------------------------------ 1.14 Read the status of function keys. ------------------------------------------------------------------------------ [Name] crt_readfkey [Syntax] #include int crt_readfkey( void ) ; [Arguments] -----
  • Page 548[Example] Following is a sample program which, when a function key is pressed, switches the screen to the corresponding CNC screen.(Execute as auxiliary task) #include #include void main( void ) { unsigned int idx, fkey, newscrn, curscrn, savescrn[8] ; for ( idx = 0 ; idx < 8 ; id
  • Page 549------------------------------------------------------------------------------ 1.15 Display the secondary cursor.
    ------------------------------------------------------------------------------ [Name] crt_2ndcursor [Syntax] #include int crt_2ndcursor( unsigned int attrib, unsigned int
  • Page 550position Specify cursor position. To display cursor on the Mth column of the Nth line, specify as (N-1)*(columns per line)+(M-1). (Both line number and column number starts from "1" which corresponds to the top line and the left-most column. Columns are the number of single column character.) width
  • Page 551------------------------------------------------------------------------------ 1.16 Set attribute of characters on VRAM.
    ------------------------------------------------------------------------------ [Name] crt_settextattr [Syntax] #include int crt_settextattr( unsigned int y1, unsign
  • Page 552+-----------------------------------+ │(1,1) Whole screen│ │ │ │ +-------------------+ │ │ │(y1,x1) │ │ │ │ │ │ │ │ │ │ │ │ (y2,x2)│ │ │ +-------------------+ │ │ Attribute setting region │ │ │ │ (ymax,xmax)│ +-----------------------------------+ ymax=30, xmax=80 This function changes the attributes
  • Page 553[Example] The following program make the top line of the screen "REVERSE" for a moment. #include void example( void ) { crt_settextattr( 1, 1, 1, 80, 0x0010, 0 ) ; crt_settextattr( 1, 1, 1, 80, 0x0010, 1 ) ; }
  • Page 554------------------------------------------------------------------------------ 1.17 Get attribute of character on VRAM.
    ------------------------------------------------------------------------------ [Name] crt_gettextattr [Syntax] #include unsigned int crt_gettextattr( unsigned int y,
  • Page 555------------------------------------------------------------------------------ 1.18 Set color palette of VGA characters.
    ------------------------------------------------------------------------------ [Name] crt_setpalette [Syntax] #include #include int crt_setpalette( unsign
  • Page 556Palette ESC sequence index Color value Displayed color Char Back -------+---------------+---------------+-------------------- 0 0x00000000 Black 30 40 1 0x0000003F Red 31 41 2 0x00003F00 Green 32 42 3 0x00003F3F Yellow 33 43 4 0x003F0000 Blue 34 44 5 0x003F003F Magenta 35 45 6 0x003F3F00 Cyan 36 46
  • Page 557It is possible to set the priority of the palette of characters and graphics by specifying "_PAL_COMP" in "index". In this case, specify the palette priority in "color". color Palette priority ---------------+----------------------- CRT_PAL_COMP Composite (default) CRT_PAL_CHAR Character over graphi
  • Page 558------------------------------------------------------------------------------ 1.19 Set all color palette of VGA characters.
    ------------------------------------------------------------------------------ [Name] crt_setallpalette [Syntax] #include #include int crt_setallpalet
  • Page 559------------------------------------------------------------------------------ 1.20 Get color palette of CNC screen.
    ------------------------------------------------------------------------------ [Name] crt_getcncpalette [Syntax] #include int crt_getcncpalette( unsigned long *cnccol )
  • Page 560Color palette of the CNC screen both for character and for graphics is set as follows. Palette index Color --------------+--------------- 0 Black 1 Red 2 Green 3 Yellow 4 Blue 5 Magenta 6 Cyan 7 White 8 Dark Gray 9 Dark Green 10 Dark Blue 11 Dark Magenta 12 Light Gray 13 Black 14 Dark Cyan 15 Light
  • Page 561------------------------------------------------------------------------------ 1.21 Output character string by FANUC character code.
    ------------------------------------------------------------------------------ [Name] crt_fstr [Syntax] #include int crt_fstr( unsigned int *code, unsig
  • Page 562------------------------------------------------------------------------------ 1.22 Get text data from VRAM.
    ------------------------------------------------------------------------------ [Name] crt_gettextimg [Syntax] #include int crt_gettextimg( unsigned int y1, unsigned int len x1,
  • Page 563[Description] Gets character codes, displayed on the screen, with their attribute. This function is used with the function "crt_puttextimg" to backup or restore the text image on the screen. y1,x1 is top,left, y2,x2 is bottom,right position of the area from where characters are got as follows. (The
  • Page 564[Example] The following program backs up and restores the displayed characters of upper 3 rows on the 14 inch screen. #include #include void example( void ) { unsigned long *buf ; /* allocate (3-line)*(80-column)*(4-byte) buffer */ buf = (unsigned long *)malloc( 3*80*4 ) ; /* get
  • Page 565------------------------------------------------------------------------------ 1.23 Put text data into VRAM.
    ------------------------------------------------------------------------------ [Name] crt_puttextimg [Syntax] #include int crt_puttextimg( unsigned int y1, unsigned int len x1,
  • Page 566[Example] The following program makes the characters and attributes that are displayed on the specified area to move to right by 3 digit. #include #include #include void example( unsigned int y1, unsigned int x1, unsigned int y2, unsigned int x2 ) { unsigned long *buf ;
  • Page 567------------------------------------------------------------------------------ 1.24 Select graphic page to use.
    ------------------------------------------------------------------------------ [Name] crt_setgraphpage [Syntax] #include int crt_setgraphpage( int page ) ; [Arguments] page
  • Page 568[Example] The following program draws graphics using only graphic page #1. #include #include void example( void ) { if ( crt_opengr() == 1 ) { crt_setgraphpage( 1 ) ; _setvideomode( _VRES16COLOR ) ; } << Calling graphic function >> crt_closegr() ; }
  • Page 569------------------------------------------------------------------------------ 1.25 Select drawing method of 6x sized character.
    ------------------------------------------------------------------------------ [Name] crt_set6chmode [Syntax] #include int crt_set6chmode( int mode ) ; [Arg
  • Page 570[Description] Selects drawing method of 6x sized character. This function selects the drawing method of 6x sized character that is displayed over "CNC screen display function" application program on PC side of FS300i. Specify one of the followings. mode = 0 High speed mode (default). This is effecti
  • Page 571------------------------------------------------------------------------------ 1.26 Select saving method of graphic contents.
    ------------------------------------------------------------------------------ [Name] crt_setgsvmode [Syntax] #include int crt_setgsvmode( unsigned int flag )
  • Page 572The following memory is required to save contents of graphic page. 16-color mode Approx. 150KB per page. 256-color mode Approx. 300KB per page. Required memory is allocated when "Save graphic contents" is specified by this function. Memory area is provided from free memory region of DRAM memory allo
  • Page 5732. Multiple window display library ------------------------------------------------------------------------------ 2.1 Open window.
    ------------------------------------------------------------------------------ [Name] win_open [Syntax] #include whandle win_open( winfo *spec, char *titl
  • Page 574Values set for each member of the structure "spec" are as follows.. posl line number of the upper left corner of the window ( >=2) (top line of the screen being "1") posc column number of the upper left corner of the window ( >=2) (left-most column of the screen being "1") sizev number of lines of t
  • Page 575A new window is placed over existing windows and both screen output and key input are bound to this window (active window). When new window is opened, cursor is placed on the upper-left corner (home position) of the window and cursor display attribute is set to non-display state. While more than one
  • Page 576------------------------------------------------------------------------------ 2.2 Close window.
    ------------------------------------------------------------------------------ [Name] win_close [Syntax] #include int win_close( void ) ; [Arguments] ------ [Return] Returns zero if succes
  • Page 577------------------------------------------------------------------------------ 2.3 Select window.
    ------------------------------------------------------------------------------ [Name] win_select [Syntax] #include int win_select( whandle handle ) ; [Arguments] handle window handle of t
  • Page 578------------------------------------------------------------------------------ 2.4 Activate window.
    ------------------------------------------------------------------------------ [Name] win_activate [Syntax] #include int win_activate( whandle handle ) ; [Arguments] handle window handl
  • Page 579------------------------------------------------------------------------------ 2.5 Move window.
    ------------------------------------------------------------------------------ [Name] win_move [Syntax] #include int win_move( int dy, int dx ) ; [Arguments] dy vertical displacement dx hor
  • Page 580------------------------------------------------------------------------------ 2.6 Alter window size.
    ------------------------------------------------------------------------------ [Name] win_size [Syntax] #include int win_size( int dy, int dx ) ; [Arguments] dy vertical expansion/red
  • Page 581------------------------------------------------------------------------------ 2.7 Let active window be full screen size.
    ------------------------------------------------------------------------------ [Name] win_full [Syntax] #include int win_full( void ) ; [Arguments] ------ [Return]
  • Page 582------------------------------------------------------------------------------ 2.8 Let active window be window size.
    ------------------------------------------------------------------------------ [Name] win_window [Syntax] #include int win_window( void ) ; [Arguments] ------ [Return]
  • Page 583------------------------------------------------------------------------------ 2.9 Get window information.
    ------------------------------------------------------------------------------ [Name] win_info [Syntax] #include int win_info( whandle handle, winfo *spec ) ; [Arguments] handle
  • Page 584------------------------------------------------------------------------------ 2.10 Set color of window frame and title string.
    ------------------------------------------------------------------------------ [Name] win_col [Syntax] #include void win_col( int colf, int colt, int colh, i
  • Page 585[Description] Set color for window frame and window title string. Specify colors and attribute for each argument as follows. 15 8 7 0 +------------------------+------------------------+ │ 0 0 0 Ib Bb Gb Rb I │ B G R r b 0 0 0 │ +------------------------+------------------------+ B: Blue r: Reverse v
  • Page 586------------------------------------------------------------------------------ 2.11 Hide window.
    ------------------------------------------------------------------------------ [Name] win_hide [Syntax] #include int win_hide( whandle handle ) ; [Arguments] handle window handle for the w
  • Page 587------------------------------------------------------------------------------ 2.12 Show window.
    ------------------------------------------------------------------------------ [Name] win_show [Syntax] #include int win_show( whandle handle ) ; [Arguments] handle window handle of the wi
  • Page 588------------------------------------------------------------------------------ 2.13 Set window title string.
    ------------------------------------------------------------------------------ [Name] win_setttl [Syntax] #include int win_setttl( whandle handle, char *title ) ; [Arguments] h
  • Page 589------------------------------------------------------------------------------ 2.14 Set window frame line character.
    ------------------------------------------------------------------------------ [Name] win_setfrm [Syntax] #include void win_setfrm( unsigned int *frame ) ; [Arguments]
  • Page 590------------------------------------------------------------------------------ 2.15 Get window display status.
    ------------------------------------------------------------------------------ [Name] win_getstat [Syntax] #include void win_getstat( struct winstat *stat ) ; struct winstat
  • Page 591For example, three windows are opened now as below. This function returns the following result. +[1]-------------+ │Selected │ +[2]---│ │ │ │ │ │ │ +[3]-------------+ │ │ │Active │ │ +------│ │ │ │ │ │ │ │ +-------------│ │ +----------------+ stat.selected = 1 stat.active = 3 stat.numwin = 3 stat.wi
  • Page 592------------------------------------------------------------------------------ 2.16 Redraw windows.
    ------------------------------------------------------------------------------ [Name] win_redraw [Syntax] #include void win_redraw( void ) ; [Arguments] ------ [Return] ------ [Descript
  • Page 5933. User defined character library 3-1. scope User defined character is a character which is defined by machine tool builders. (usually referred to as extended character) C Executor allows the user application program to define and use extended characters. Up to 256 single byte characters can be defi
  • Page 594* Binary notation Horizontally aligned 8 bits(dots) are represented by one byte data. Single byte character 2-byte character bit order-> #7 #0 #7 #0 #7 #0 +----------+ +-------------------+ │ byte 1 │ │ byte 1 │ byte 17 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
  • Page 595- 2-byte character ("KAN" of Japanese KANJI character) pattern ................ .......#...#.... .##..#########.. ...#...#...#.... ......#######... .##...#..#..#... ...#..#######... .........#...... ...#..#######... ...#.....#...... ...#.#########.. ..#.....#.#..... ..#....#...#.... .##..##.....##..
  • Page 5963-3. Character code (1) FANUC code Character codes from 0x4100 to 0x41FF in FANUC code set are reserved for user defined characters and automatically assigned to the user defined character in the order of its registration. In case of 2-byte characters, two consecutive codes are assigned to a 2-byte
  • Page 597Whole character patterns for all user defined characters to be registered have to be stored in one unsigned character string. User defined characters cannot be registered separately. They can only be registered all characters at one time. Put this character string in the user application program. (3
  • Page 598Function reference ------------------------------------------------------------------------------ 3.1 Register user character.
    ------------------------------------------------------------------------------ [Name] crt_reguserchar [Syntax] #include int crt_reguserchar( unsigned int numb
  • Page 599------------------------------------------------------------------------------ 3.2 Map user character.
    ------------------------------------------------------------------------------ [Name] crt_mapuch [Syntax] #include int crt_mapuch( unsigned int code, unsigned int ucode ) ; [Argument
  • Page 600------------------------------------------------------------------------------ 3.3 Get CG pattern.
    ------------------------------------------------------------------------------ [Name] crt_getcgpttn [Syntax] #include int crt_getcgpttn( unsigned int code, unsigned char *buf ) ; [Argume
  • Page 6013-6. Sample application program #define UCH_NUM 10 /* number of defined characters( single byte equivalent) */ /* Character pattern */ unsigned char pattern[ UCH_NUM * CHAR_SIZE_14 ] = { 0x00,0x3F,0x02,0x02,0x02,0x3F,0x22,0x22, /* 0x4100 */ 0x22,0x22,0x22,0x3F,0x02,0x02,0x02,0x7F, 0x00,0xFE,0x20,0x2
  • Page 6024. VGA window display library Outline of VGA window display "VGA window" is an overlapping window provided by VGA display device. This VGA window has the following features. * Overlapping on any arbitrary screen such as CNC, PMC and C-EXE screen. * Both graphics and character overlapping. * Simultan
  • Page 603VGA window has the following restrictions. * Color palettes are common with the base screen. So, if any color palette is changed in the base screen or the VGA window, the corresponding color palette of the other screen is changed. * The control of graphic display enabling/disabling is common with th
  • Page 604Using VGA window Usually VGA window is used in the window task. It is possible to only output to VGA window in the window task. VGA window is used in also the main task. In the following section, usages of VGA window is described for each cases. (A) VGA window display in the window task. Execute the
  • Page 605(B) VGA window display in the main task. The procedures to display VGA window in the main task is basically same as in the window task. There are some differences as follows. (1) Once "vwin_open()" function is called, all of the following output are displayed in the VGA window. (both character and g
  • Page 606Function Reference ------------------------------------------------------------------------------ 4.1 Open VGA window. ------------------------------------------------------------------------------ [Name] vwin_open [Syntax] #include int vwin_open( unsigned int widx, unsigned int p
  • Page 607------------------------------------------------------------------------------ 4.2 Close VGA window. ------------------------------------------------------------------------------ [Name] vwin_close [Syntax] #include int vwin_close( unsigned int widx ) ; [Arguments] widx VGA window
  • Page 608------------------------------------------------------------------------------ 4.3 Select VGA window. ------------------------------------------------------------------------------ [Name] vwin_select [Syntax] #include int vwin_select( unsigned int widx ) ; [Arguments] widx VGA win
  • Page 609------------------------------------------------------------------------------ 4.4 Show VGA window. ------------------------------------------------------------------------------ [Name] vwin_show [Syntax] #include int vwin_show( unsigned int widx, unsigned int posl, unsigned int p
  • Page 610------------------------------------------------------------------------------ 4.5 Hide VGA window. ------------------------------------------------------------------------------ [Name] vwin_hide [Syntax] #include int vwin_hide( unsigned int widx ) ; [Arguments] widx VGA window in
  • Page 611------------------------------------------------------------------------------ 4.6 Get VGA window information. ------------------------------------------------------------------------------ [Name] vwin_info [Syntax] #include int vwin_info( unsigned int widx, struct vwinfo *buf ) ;
  • Page 6123.7 File Operation Library ========================== Using Memory Card The application program can access a memory card which is inserted in the card slot equipped on the LCD/MDI panel of FS30i as a disk device. To read/write a memory card, execute the following procedures. (1) Insert a memory card
  • Page 613[Note] * The drive name to aceess a memory card is "B:". It is fixed. * The C application program can't access the memory card while the other software (CNC software, etc.) is accessing it. * The C application program may fail to access the memory card just after insertion the memory card (for a few
  • Page 614Lists of Functions -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1. aux_file_format Format specified drive 2. aux_file_mount Mount memory card. 3. aux_file_unmount Unmount memory car
  • Page 615Function Reference ------------------------------------------------------------------------------ 1. Format specified drive
    ------------------------------------------------------------------------------ [Name] aux_file_format [Syntax] #include int aux_file_format( unsigned char dr
  • Page 616------------------------------------------------------------------------------ 2. Mount memory card. ------------------------------------------------------------------------------ [Name] aux_file_mount [Syntax] #include int aux_file_mount( unsigned char drive ) ; [Argum
  • Page 617[Example] The following program reads character by character from "TESTFILE.DAT" in the memory card and writes them to the stdout. #include #include int example( void ) { FILE *fp ; signed char ch ; int ret ; unsigned int stat ; ret = aux_file_mount( 'B' ) ; if ( ret ) { return
  • Page 618------------------------------------------------------------------------------ 3. Unmount memory card. ------------------------------------------------------------------------------ [Name] aux_file_unmount [Syntax] #include int aux_file_unmount( unsigned char drive ) ;
  • Page 619------------------------------------------------------------------------------ 4. Get memory card information. ------------------------------------------------------------------------------ [Name] aux_file_memcinfo [Syntax] #include int aux_file_memcinfo( unsigned int *
  • Page 6203.8 Serial Library ================== Library outline 1. Outline Serial Library is a set of general functions which are used to send/receive data to/from devices via RS-232C communication interface. Character or block type data can be handled by these functions. To utilize communication function wit
  • Page 621[3] Authorization to access communication channel Each communication channels have authorization control mechanism independent of each other. Application program has to get authorization to use a channel by calling rs_open() function, before using the serial communication interface. If the channel i
  • Page 622(2) Receiving handshake DC code is used to request the source device to stop or restart sending data according to the state of receiving buffer. Send DC1 : request to restart sending data Send DC3 : request to stop sending data These DC1 or DC3 codes are automatically transmitted by the serial commu
  • Page 6232. Interface [1] Connection CNC Serial device ----------+ +------------ │ │ SD ------------------------------------------------> RD RD <------------------------------------------------ SD │ │ RS ------------------------------------------------> CS CS <------------------------------------------------
  • Page 624[2] Signal state Only difference between "hardware flow ctrl" and "no hardware flow ctrl" is that signals CS and DR are deemed always ON if "no hardware flow ctrl" is selected. (1) After channel is open hardware flow ctrl no hardware flow ctrl -------+-----------------------+--------------------- SD
  • Page 625(4) After channel is closed hardware flow ctrl no hardware flow ctrl -------+-----------------------+--------------------- SD RD RS OFF <- CS ER OFF <- DR CD
  • Page 626List of functions -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1. rs_open Initialize communication channel 2. rs_close Close communication channel 3. rs_putc Put one byte data into
  • Page 627Function Reference ------------------------------------------------------------------------------ 1. Initialize communication channel ------------------------------------------------------------------------------ [Name] rs_open [Syntax] #include int rs_open( int channel, s
  • Page 628Specify communication conditions in the structure "param". param->baud baud rate -----------------------+------------------------ BAUD_0600 600 bits/sec BAUD_1200 1200 bits/sec BAUD_2400 2400 bits/sec BAUD_4800 4800 bits/sec BAUD_9600 9600 bits/sec param->stop_bit stop bit length -------------------
  • Page 629param->dc1_code define DC1 code (usually 0x11 ) param->dc2_code define DC2 code (usually 0x12 ) param->dc3_code define DC3 code (usually 0x13; 0x93: when using ISO code ) param->dc4_code define DC4 code (usually 0x14 ) Specify open mode of the communication interface by the argument "mode". mode ope
  • Page 630------------------------------------------------------------------------------ 2. Close communication channel ------------------------------------------------------------------------------ [Name] rs_close [Syntax] #include int rs_close( int channel ) ; [Argument] channel
  • Page 631------------------------------------------------------------------------------ 3. Put one byte data into transmit buffer ------------------------------------------------------------------------------ [Name] rs_putc [Syntax] #include int rs_putc( int c, int channel ) ; [Arg
  • Page 632------------------------------------------------------------------------------ 4. Get one byte data from receive buffer ------------------------------------------------------------------------------ [Name] rs_getc [Syntax] #include int rs_getc( int channel ) ; [Argument] c
  • Page 633------------------------------------------------------------------------------ 5. Put block of data into transmit buffer ------------------------------------------------------------------------------ [Name] rs_write [Syntax] #include int rs_write ( char *buffer, int size,
  • Page 634------------------------------------------------------------------------------ 6. Get block of data from receive buffer ------------------------------------------------------------------------------ [Name] rs_read [Syntax] #include int rs_read ( char *buffer, int size, int
  • Page 635------------------------------------------------------------------------------ 7. Test or clear transmit/receive buffer ------------------------------------------------------------------------------ [Name] rs_buffer [Syntax] #include int rs_buffer( int channel, int cmnd )
  • Page 636------------------------------------------------------------------------------ 8. Get status of communication buffer and interface ------------------------------------------------------------------------------ [Name] rs_status [Syntax] #include int rs_status( int channel )
  • Page 637------------------------------------------------------------------------------ 9. Wait for communication interface event ------------------------------------------------------------------------------ [Name] rs_wait [Syntax] #include #include int rs_wait( int cha
  • Page 638After this function call, the task from which this function is called is switched to the "wait state" until specified condition is satisfied. For this reason, this function especially suits with communication tasks. This function is used for following purposes. (1) Wait for transmit completion ret =
  • Page 6393.9 Task management library =========================== Library outline Following functions are provided to control execution of the application programs or to manage execution of multiple tasks. 1. Time management 2. Semaphore control 3. Event flag 1. Time management The time management functions c
  • Page 6402. Synchronization of tasks (semaphore management) The semaphore is used to synchronize or arbitrate execution of tasks. The semaphore consists of semaphore counter and semaphore queue. Suspended tasks which are waiting for the semaphore to be signaled are queued in the semaphore queue, and when the
  • Page 641Waiting for signal * os_wait_sem() decrements the semaphore counter, and suspends the execution of the calling task if the value of the semaphore counter is negative. sem-- ==> decrement semaphore counter if( sem < 0 ) ==> if negative counter value Wait ==> queue the task into the semaphore queue an
  • Page 642[ Example of task arbitration ] As an example, here it is assumed that there are three sets of resources which are shared between five tasks. The following example shows a method to manage assignment of these resources among tasks. +-----------+ Signal │ resources │ Task Queue Wait <====== │ TASK-A
  • Page 643[Example of task synchronization] This is a sample case that a task is waiting for another task to complete, and assumes that TASK-A waits for TASK-B and TASK-B waits for TASK-C. This task synchronization can be achieved by using two semaphores. * Priority of each task is assumed to be A>B>C (C bein
  • Page 644[ Example of inter task communication ] A method of sending or receiving data between tasks by means of ring buffer ( or circulating buffer) is considered in the following example. Assume that the TASK-A writes a data into the buffer and the TASK-B reads the data from the buffer. Writing a data into
  • Page 6453. Synchronizing tasks ( Event flag) Event flag is used to synchronize execution of tasks. The event flags relating to the specific operation are grouped and it forms an event group. (For example, consider a case that a task detects a signal and notifies that to other tasks.) Maximum 32 flags can be
  • Page 646Following functions are used for event flag management. Name Function ---------------+---------------------------------------------- os_make_flg create event flag os_delt_flg delete event flag os_sign_flg signal event flag ( modal type) os_puls_flg signal event flag ( pulse type) os_wait_flg wait fo
  • Page 647Operation if( wait message & image == 0 ) Wait ==> wait until "wait massage" is satisfied image wait message 0..0000XXX 0..0000111 │ │ +-------> AND <-------+ │ │ !=0 0..0XXX -----> NO wait │ │ ==0 V wait for signal (b) AND wait The execution of the calling task is suspended until all three flags 1,
  • Page 648(3) Signaling the event flag Functions os_sign_flg() or os_puls_flg() signals the event flag. For example, to signal the event flag 1,2 and 3 to become ON, specify 0x00000007 for the parameter of os_sign_flg(). (This parameter is referred to as "signal message".) The suspended tasks which are waitin
  • Page 649(b) Signaling the "AND waiting" task operation wait message = signal message & wait message if( wait message == 0 ) Ready ===> waked signal message wait message 0..0000XXX 0..0000111 NOT │ │ 1..1111XXX -> AND <------+ │ │ ==0 0..0XXX -----> waked │ !=0 V suspended (4) Clearing the event flag os_clar
  • Page 650[Transition of flags to be waited and event flag image by signals] Following example explains the state transition of the flags to be waited and the event flag image when they are signaled by modal type and pulse type signaling functions. Parameter flags to be event flag Function (message) waited im
  • Page 651Lists of Functions -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1. os_show_tim read timer 2. os_set_tim set timer 3. os_sync_tim suspend execution of task until specified time of ti
  • Page 652Function Reference ------------------------------------------------------------------------------ 1. Read timer ------------------------------------------------------------------------------ [Name] os_show_tim [Syntax] #include void os_show_tim( unsigned long *current_ti
  • Page 653------------------------------------------------------------------------------ 2. Set timer ------------------------------------------------------------------------------ [Name] os_set_tim [Syntax] #include void os_set_tim( unsigned long new_timer_value, unsigned long *o
  • Page 654------------------------------------------------------------------------------ 3. Suspend execution of task until specified time of timer ------------------------------------------------------------------------------ [Name] os_sync_tim [Syntax] #include unsigned short os
  • Page 655------------------------------------------------------------------------------ 4. Suspend execution of task for specified time period ------------------------------------------------------------------------------ [Name] os_wait_tim [Syntax] #include unsigned short os_wai
  • Page 656------------------------------------------------------------------------------ 5. Create event flag ------------------------------------------------------------------------------ [Name] os_make_flg [Syntax] #include unsigned short os_make_flg( unsigned char event_flag_id
  • Page 657------------------------------------------------------------------------------ 6. Delete event flag ------------------------------------------------------------------------------ [Name] os_delt_flg [Syntax] #include unsigned short os_delt_flg( unsigned char event_flag_id
  • Page 658------------------------------------------------------------------------------ 7. Signal event flag ------------------------------------------------------------------------------ [Name] os_sign_flg [Syntax] #include unsigned short os_sign_flg( unsigned char event_flag_id
  • Page 659------------------------------------------------------------------------------ 8. Wait for being signaled ------------------------------------------------------------------------------ [Name] os_wait_flg [Syntax] #include unsigned short os_wait_flg( unsigned char event_f
  • Page 660------------------------------------------------------------------------------ 9. Clear event flag ------------------------------------------------------------------------------ [Name] os_clar_flg [Syntax] #include unsigned short os_clar_flg( unsigned char event_flag_id,
  • Page 661------------------------------------------------------------------------------ 10. Signal event flag (pulse type) ------------------------------------------------------------------------------ [Name] os_puls_flg [Syntax] #include unsigned short os_puls_flg( unsigned char
  • Page 662------------------------------------------------------------------------------ 11. Create semaphore ------------------------------------------------------------------------------ [Name] os_make_sem [Syntax] #include unsigned short os_make_sem( unsigned char semaphore_id,
  • Page 663------------------------------------------------------------------------------ 12. Delete semaphore ------------------------------------------------------------------------------ [Name] os_delt_sem [Syntax] #include unsigned short os_delt_sem( unsigned char semaphore_id
  • Page 664------------------------------------------------------------------------------ 13. Signal semaphore ------------------------------------------------------------------------------ [Name] os_sign_sem [Syntax] #include unsigned short os_sign_sem( unsigned char semaphore_id
  • Page 665------------------------------------------------------------------------------ 14. Wait until semaphore is signaled ------------------------------------------------------------------------------ [Name] os_wait_sem [Syntax] #include unsigned short os_wait_sem( unsigned ch
  • Page 666------------------------------------------------------------------------------ 15. Start window task
    ------------------------------------------------------------------------------ [Name] os_strt_wtsk [Syntax] #include unsigned short os_strt_wtsk( unsigned int wghs ) ; [Argument] wg
  • Page 6673.10 FCA Library ================ Library outline 1. Outline FCA(FANUC CASSETTE ADAPTOR) Library is a library of functions which are used to send or receive data between CNC and FANUC's peripheral devices like FANUC Handy File or FANUC CASSETTE ADAPTOR. To utilize communication function with FCA Lib
  • Page 668[3] How it works +---------------------------------------+ │ │ │ Application │ │ │ +-------------------+-------------------+ │ +-------------------+-------------------+ │ │ │ FCA Library │ │ │ +-------------------+-------------------+ │ +-------------------+-------------------+ │ │ │ Serial Library
  • Page 669+----------------+ +------------------+ │ │ │ +--------------+ │ │ │ │ │ │ │ │ -----fca_setparam()------> │ │ │ │ │ │ FCA mode │ │ │ <-------fca_bye()--------- │ │ │ │ │ │ │ │ │ Idle state │ │ +--------------+ │ │ │ │ │ │ --------rs_open()--------> │ │ │ │ │ │ <-------rs_close()-------- │ │ │ │ Gene
  • Page 670List of Functions -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1. fca_setparam Initialize communication line. 2. fca_bye Close communication line. 3. fca_open Open a binary file on
  • Page 671Function Reference ------------------------------------------------------------------------------ 1. Initialize communication line. ------------------------------------------------------------------------------ [Name] fca_setparam [Syntax] #include int fca_setparam( int ch
  • Page 672While in FCA mode, other FCA Library Functions, fca_xxx(), can be called. If they are called prior to the fca_setparam() function, the operation of those functions are not guaranteed. By calling fca_bye(), the serial port is returned to the idle state. For the parameters set in the structure, ser_t,
  • Page 673------------------------------------------------------------------------------ 2. Close communication line. ------------------------------------------------------------------------------ [Name] fca_bye [Syntax] #include int fca_bye( int channel ) ; [Argument] channel Chann
  • Page 674------------------------------------------------------------------------------ 3. Open a binary file on FCA device. ------------------------------------------------------------------------------ [Name] fca_open [Syntax] #include int fca_open( char *name, int mode ) ; [Argu
  • Page 675------------------------------------------------------------------------------ 4. Close a binary file. ------------------------------------------------------------------------------ [Name] fca_close [Syntax] #include int fca_close( void ) ; [Argument] ------ [Return] Retur
  • Page 676------------------------------------------------------------------------------ 5. Read binary data from the file. ------------------------------------------------------------------------------ [Name] fca_read [Syntax] #include int fca_read( char *buffer, unsigned int bytes
  • Page 677[Example] Following sample program displays the specified file in the FCA device connected to the first channel in binary dump format. #include #include #include #include #define BUFSIZE 256 int example( void ) { ser_t r_para ; int ret, mode = 0, i, c ; char name[
  • Page 678for( i = 0 ; i < ret ; i++ ) { c = buffer[ i ] ; c &= 0x00ff ; printf( "%02X", c ) ; count++ ; } if ( ret < bytes ) { printf( "¥n" ) ; printf( "ret = %d¥n", ret ) ; printf( "bytes = %d¥n", bytes ) ; printf( "ret < bytes¥n", ret ) ; break ; } } printf( "¥n" ) ; printf( "%ld bytes¥n", count ) ; ret =
  • Page 679------------------------------------------------------------------------------ 6. Write binary data to the file. ------------------------------------------------------------------------------ [Name] fca_write [Syntax] #include int fca_read( char *buffer, unsigned int bytes
  • Page 680[Example] Following sample program writes the NC part program of specified program number into the device connected to the first channel as a file with specified name. #include #include #include #include #define BUFSIZE 256 int example( void ) { int ret, number, i
  • Page 681ret = cnc_upload( (struct odbup *)(&buf), &number ) ; if ( ret ) { printf( "error in cnc_upload¥n" ) ; cnc_upend() ; fca_close() ; fca_bye( 1 ) ; return ( ret ) ; } ret = fca_write( &buf[4], number ) ; if ( ret == -1 ) { printf( "error in fca_write¥n" ) ; cnc_upend() ; fca_close() ; fca_bye( 1 ) ; r
  • Page 682------------------------------------------------------------------------------ 7. Open a text file on FCA device. ------------------------------------------------------------------------------ [Name] fca_fopen [Syntax] #include int fca_fopen( char *name, char *mode ) ; [Ar
  • Page 683------------------------------------------------------------------------------ 8. Close a text device. ------------------------------------------------------------------------------ [Name] fca_fclose [Syntax] #include int fca_fclose( void ) ; [Argument] ------ [Return] Ret
  • Page 684------------------------------------------------------------------------------ 9. Read a character from the text file. ------------------------------------------------------------------------------ [Name] fca_getc [Syntax] #include int fca_getc( void ) ; [Argument] ------
  • Page 685r_para.baud = BAUD_4800 ; r_para.stop_bit = STOP_2 ; r_para.parity = PARITY_N ; r_para.data_bit = DATA_8 ; r_para.hardflow = 2 ; r_para.dc_enable = 3 ; r_para.dc_put = 0 ; r_para.dc1_code = 0x11 ; r_para.dc2_code = 0x12 ; r_para.dc3_code = 0x93 ; r_para.dc4_code = 0x14 ; ret = fca_setparam( 1, &r_pa
  • Page 686------------------------------------------------------------------------------ 10. Write a character to the text file. ------------------------------------------------------------------------------ [Name] fca_putc [Syntax] #include int fca_putc( int c ) ; [Argument] c A ch
  • Page 687[Example] Following sample program writes the NC part program of specified program number, character by character, into the device connected to the first channel as a file with the specified name. #include #include #include #include #define BUFSIZE 256 int example
  • Page 688ret = cnc_upstart( o_num ) ; if ( ret ) { printf( "error in cnc_upstart¥n" ) ; fca_fclose() ; fca_bye( 1 ) ; return ( ret ) ; } for (;;) { number = BUFSIZE - 1 ; ret = cnc_upload( (struct odbup *)(&buf), &number ) ; if ( ret ) { printf( "error in cnc_upload¥n" ) ; cnc_upend() ; fca_fclose() ; fca_by
  • Page 689------------------------------------------------------------------------------ 11. Delete a file on FCA device. ------------------------------------------------------------------------------ [Name] fca_delete [Syntax] #include int fca_delete( char *name ) ; [Argument] name
  • Page 690r_para.baud = BAUD_4800 ; r_para.stop_bit = STOP_2 ; r_para.parity = PARITY_N ; r_para.data_bit = DATA_8 ; r_para.hardflow = 2 ; r_para.dc_enable = 3 ; r_para.dc_put = 0 ; r_para.dc1_code = 0x11 ; r_para.dc2_code = 0x12 ; r_para.dc3_code = 0x93 ; r_para.dc4_code = 0x14 ; ret = fca_setparam( 1, &r_pa
  • Page 691------------------------------------------------------------------------------ 12. Change name of a file on FCA device. ------------------------------------------------------------------------------ [Name] fca_rename [Syntax] #include int fca_rename( char *oldname, char *n
  • Page 692ret = fca_setparam( 1, &r_para ) ; if ( ret ) { printf( "error in fca_setparam¥n" ) ; return ( ret ) ; } printf( "old name?(max 17 )¥n" ) ; ret = scanf( "%s", &oldname ) ; printf( "new name?(max 17 )¥n" ) ; ret = scanf( "%s", &newname ) ; ret = fca_rename( oldname, newname ) ; if ( ret ) { printf( "
  • Page 693------------------------------------------------------------------------------ 13. Read directory information of FCA device. ------------------------------------------------------------------------------ [Name] fca_readdir [Syntax] #include int fca_readdir( fca_dir *buffer
  • Page 694(2) The number of directory information from the "ndir"th file to the last file is given as the return value. Allocate memory area sufficient to store above directory information and specify the pointer to this memory area as the argument "buffer". (3) Call this function again with the number of dir
  • Page 695for ( i = 0 ; i < n ; i++ ) { ret = fca_readdir( &buf[0], i + 1, 1 ) ; if ( ret == -1 ) { printf( "error in fca_readdir 2¥n" ) ; fca_bye( 1 ) ; return ( ret ) ; } else{ printf( " %02d %-17s %-8s %c %c %-2s %c¥n" , i+1 , buf[0].file_name , buf[0].file_size , buf[0].wrt_protect , buf[0].record_code ,
  • Page 696------------------------------------------------------------------------------ 14. Read status information of FCA device. ------------------------------------------------------------------------------ [Name] fca_status [Syntax] #include int fca_status( char *buffer ) ; [Ar
  • Page 697(Note) It can happen that "ERROR CODE" does not indicate correct error code. ERROR CODE TABLE ERROR CODE CAUSE ---------------+----------------------------------- 00000(= 0) no error 00001(= 1) file search error 00010(= 2) (not used) 00011(= 3) (not used) 00100(= 4) (not used) 00101(= 5) (not used)
  • Page 698------------------------------------------------------------------------------ 15. Read free space size of a floppy disk. ------------------------------------------------------------------------------ [Name] fca_remains [Syntax] #include int fca_remains( long *remains ) ;
  • Page 699[Example] Following sample program reads and displays the amount of remaining free Tsapce in the Floppy Disk connected to the first channel. #include #include #include #include int example( void ) { int ret ; ser_t r_para ; long remains = 0 ; r_para.baud = BAUD_48
  • Page 7003.11 F-ROM Library ================== Library outline Included in the F-ROM Library are the functions which are used to read the data files for the C Executor that are stored in the Flush ROM Module for FS30i (referred to as "F-ROM" hereafter). The data file for the C Executor (referred to as "C Exe
  • Page 701A C Executor application program is compiled and converted to the memory card format file. Then, Data files are combined to the C Executor program file by executing "dat2mem.com". When power is applied to the CNC, only program part of this type of file is loaded into D-RAM to run. (3) C Executor dat
  • Page 702List of functions -------------------------------------------------------------------------- Name Function -------------------------------------------------------------------------- 1. aux_from_open Open the specified F-ROM file. 2. aux_from_close Close the F-ROM file. 3. aux_from_select Select data
  • Page 703Function reference ------------------------------------------------------------------------------ 1. Open the specified F-ROM file. ------------------------------------------------------------------------------ [Name] aux_from_open [Syntax] #include int aux_from_open( char
  • Page 704------------------------------------------------------------------------------ 2. Close the F-ROM file. ------------------------------------------------------------------------------ [Name] aux_from_close [Syntax] #include int aux_from_close( void ) ; [Argument] ------ [Re
  • Page 705------------------------------------------------------------------------------ 3. Select data in the F-ROM file. ------------------------------------------------------------------------------ [Name] aux_from_select [Syntax] #include int aux_from_select( char *name ) ; [Arg
  • Page 706------------------------------------------------------------------------------ 4. Move read pointer. ------------------------------------------------------------------------------ [Name] aux_from_moveptr [Syntax] #include int aux_from_moveptr( long offset, int origin ) ; [
  • Page 707------------------------------------------------------------------------------ 5. Read data from the F-ROM file. ------------------------------------------------------------------------------ [Name] aux_from_read [Syntax] #include int aux_from_read( unsigned char *buffer,
  • Page 708------------------------------------------------------------------------------ 6. Read directory information of a F-ROM file. ------------------------------------------------------------------------------ [Name] aux_from_getdir [Syntax] #include int aux_from_getdir( struct
  • Page 709------------------------------------------------------------------------------ 7. Read F-ROM file information. ------------------------------------------------------------------------------ [Name] aux_from_getinfo [Syntax] #include int aux_from_getinfo( char *name ) ; [Arg
  • Page 710------------------------------------------------------------------------------ 8. Read a character from the F-ROM file. ------------------------------------------------------------------------------ [Name] aux_from_getc [Syntax] #include unsigned int aux_from_getc( void )
  • Page 711------------------------------------------------------------------------------ 9. Read a line from the F-ROM file. ------------------------------------------------------------------------------ [Name] aux_from_gets [Syntax] #include int aux_from_gets( unsigned char *buffer
  • Page 712[Example 1] /* Select a file, TEST02.DAT, read and display 10 bytes of data from the beginning of the file. Then move read pointer 50 bytes ahead of current position, and read and display 50 bytes of data. Used functions : aux_from_open , aux_from_close , aux_from_select aux_from_read , aux_from_mov
  • Page 713[Example 2] /* Open F-ROM file of combined C Executor program file and C Executor data file and display directory list. Used functions : aux_from_open , aux_from_close , aux_from_getdir */ void sample2() { int dir_num, ret , i ; typedef infodir *dirarea ; dirarea dir_area ; printf( "List directory i
  • Page 714[Example 3] /* Get information of F-ROM file CEX 1.0M, and display. Used function : aux_from_getinfo */ void sample3() { int file_type ; printf( "Showing F-ROM file information¥n" ) ; file_type = aux_from_getinfo( "CEX 1.0M" ) ; switch ( file_type ) { case ( CEXEC ) : { printf( "C Executor program ¥
  • Page 7153.12 Touch-panel Library ======================== Overview of library 1. Overview In case that the display device is "10.4-inch LCD with touch-panel", the C application can read status of the touch-panel. The information to be read is; Whether touch-panel is pushed or not. The coordinate of the push
  • Page 716The whole coordinate range is (X,Y)=(0,0) - (639,479). This coordi- nate corresponds with the C Executor screen as below. +-----------------------------------+ ----- │(0,0) │ ^ +-----------------------------------+ -- │ │(0,48) │ ^ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ B A │ │ │ │ │ │ │ │ │ (639,447)│ v │ +
  • Page 717List of Functions ---------------------------------------------------------------------- Name Function ---------------------------------------------------------------------- 1. aux_tpl_read Read the status and (X,Y) coordinate of the touch-panel. -----------------------------------------------------
  • Page 718Function Reference ------------------------------------------------------------------------------ 1. Read the status and (X,Y) coordinate of the touch-panel. ------------------------------------------------------------------------------ [Name] aux_tpl_read [Syntax] #include
  • Page 719The status of touch-panel is not buffered. The status at calling this function by the application program is just returned. So, HEAD, BODY, TAIL are not exactly read as this order according to timing of calling by the application program. Usually it is not needed for the application program to disti
  • Page 720[Example] The following program wait until touch-panel is pushed, and displays coordinate of the pushed point. #include #include void example( void ) { struct tpl_xy_coord buf ; int ret ; while ( !( ret = aux_tpl_read( &buf ) ) ) ; printf( "Touch panel is pushed at (%u,%u),", buf.
  • Page 7214. Code Tables ============== 4.1 Keycode, screen control code ================================ 4.1.1 Keycode +----+------+------+------+------+------+------+-------+------+ │ │ 0x │ 1x │ 2x │ 3x │ 4x │ 5x │ 6x │ 7x │ │----+------+------+------+------+------+------+-------+------│ │ x0 │ │ │ SP │ 0
  • Page 7224.1.2 Keycode of special keys on MDI panel (1) Cursor key, Page key Key Symbol Code ---------------+---------------+------ CursorRight MDIKEY_CURRIGHT 0x88 CursorLeft MDIKEY_CURLEFT 0x89 CursorDown MDIKEY_CURDOWN 0x8A CursorUp MDIKEY_CURUP 0x8B PageDown MDIKEY_PAGEDN 0x8E PageUp MDIKEY_PAGEUP 0x8F (
  • Page 723(5) Function keys Key Symbol Code ---------------+---------------+------ [POS] MDIKEY_POS 0xE8 [PROG] MDIKEY_PROG 0xE9 [OFFSET] MDIKEY_OFFSET 0xEA [SYSTEM] MDIKEY_SYSTEM 0xEB [MESSAGE] MDIKEY_MESSAGE 0xEC [GRAPH] MDIKEY_GRAPH 0xED [CUSTOM] MDIKEY_CUSTOM 0xEE [CUSTOM2] MDIKEY_CUSTOM 0xEF 4.1.3 CRT di
  • Page 724(2) Deleting Escape sequence Function ---------------+------------------------------------------------------- ESC [K Delete from current cursor position to end of line. ESC [0K Same as above. ESC [1K Delete from current cursor position to beginning of line. ESC [2K Delete current line. ESC [J Delete
  • Page 725(5) Character attribute Escape sequence Function ---------------+------------------------------------------------------- ESC [0m Restore default attribute. (White, no blinking, no reverse video) ESC [5m Turn on blinking. ESC [7m Turn on reverse video mode. ESC [25m Turn off blinking. ESC [27m Turn o
  • Page 726(6) Selecting character set Escape sequence Function ---------------+------------------------------------------------------- ESC (1 Select special characters and fragment set of 6x magnified numeric characters. ESC (2 Select fragment set of 6x magnified alphabetic characters. ESC (3 Select graphic c
  • Page 7274.2 Displayable characters ========================== 4.2.1 Single byte characters (1) Displayable characters The characters, 20-7F, A0-DF, shown in the following table can be displayed on the screen. │ 0123456789ABCDEF -----+----------------- 0000 │ 0010 │ 0020 │ !"#$%&'()*+,-./ 0030 │ 0123456789:;
  • Page 7284.2.2 2-byte characters (1) JIS 1st level character set Following KANJI characters of JIS 1st level character set are available in C Executor. The characters in parentheses cannot be displayed. If these characters are output, double width space is displayed instead. FANUC original special marks are
  • Page 729(3) FANUC special marks The FANUC special marks which are assigned to JIS 1st level character set code are shown below. No. SJIS [JIS ] FANUC Character -------+---------------+-------+---------------------------- 01 885F [2F40] 0752 right arrow 02 8860 [2F41] 0754 right-up arrow 03 8861 [2F42] 0756
  • Page 730(4) Describing 2-byte characters in source-codes The DIAB-SDS compiler does not support Japanese language. If a 2-byte charac- ter whose second byte happens to be 5Ch is included directly in a source file, it is not recognized as correct data. JIS 1st level character set ----------------------------
  • Page 7314.2.3 Display code for single byte characters In the following tables, the code of the FANUC characters in each character set selected by the escape sequences, "ESC (x", are shown. . If , for example, 0x20 (space) is output in the "ESC (1" mode, FANUC character of the code 0x00E0 is displayed on the
  • Page 732(3) "ESC (3" Graphic characters +----+------+------+------+------+------+------+------+------+------+------+ │ │ 2x │ 3x │ 4x │ 5x │ 6x │ 7x │ Ax │ Bx │ Cx │ Dx │ │----+------+------+------+------+------+------+------+------+------+------│ │ x0 │ 1D50 │ 1D60 │ 1D70 │ 1D80 │ 1D90 │ 1DA0 │ 1DB0 │ 1DC0
  • Page 733(5) "ESC (6" Fragments of 6x magnified characters +----+------+------+------+------+------+------+------+------+------+------+ │ │ 2x │ 3x │ 4x │ 5x │ 6x │ 7x │ Ax │ Bx │ Cx │ Dx │ │----+------+------+------+------+------+------+------+------+------+------│ │ x0 │ │ 0100 │ │ 0196 │ │ │ │ │ │ │ │ x1
  • Page 7344.2.4 Kanji character code Following two types of codes are used in the application program. Shift-JIS code selected by "ESC (B" (default) Shift-FANUC code selected by "ESC (C" In the "ESC (B" mode, application programs can specify Shift-JIS code Kanji characters in character strings, similar to the
  • Page 7355. Other References =================== 5.1 Multitasking ================ 5.1.1 Task classes Application programs are composed of three independent task classes. +- User application program -----------------+ │ +========================================+ │ │ │ │ │ │ │ (A) Main Task │ │ │ │ │ │ │ +===
  • Page 736(supplement) Each task class corresponds to the macro-program of the Macro Executor as follows. Macro Executor C Executor -----------------------+--------------------------- Conversational Macro Main task Auxiliary Macro Alarm task , Communication task Execution Macro none 5.1.2 Difference of each t
  • Page 737Event Function -----------------------+------------------------------ Time os_sync_tim(), os_wait_tim() Event flag os_wait_flg() Semaphore os_wait_sem() Status of serial port rs_wait() This type of task management is called "event driven" task management. +-------------------+ +----- auxiliary task
  • Page 7385.1.5 Task Management Kind of tasks (1) CNC task * CNC interruption tasks Automatic or manual operation, servo control, spindle control, I/O transfer of PMC and execution of the ladder, MDI control, program editing, etc. are realized by these tasks. They are triggered by the timer interruptions and
  • Page 7395.2 File system =============== The File system compatible with MS-DOS is included in C Executor library. (1) File definition The entire format is as follows. This supports the layered directories. [drive name:][¥][directory name ¥...]name[.extension] The parts enclosed by [] can be omitted. (2) Dri
  • Page 740(5) Wild card The following Wild card characters can be used for the File name and extension. ? The meaning of any one character * The meaning of any plural characters (contain nulls) As using Wild card characters, the file can be flexibly specified. But in case of the file specification with '*', t
  • Page 741(8) Practicable number of files for opening simultaneously The number of files which the application can open simultaneously is fixed 60 as a whole. I/O Control buffers which are used by High level input/output functions(fopen,fclose,fprintf,...) are prepared respectively 15 for each task. At launch
  • Page 7425.3 Power-on procedure ====================== 5.3.1 Key operation at power on On FS30i with C Executor, the special procedure is executed when the power is turned on with pushing the definite MDI keys. Key pushed at power on Execution ---------------+-------------------------------------------------
  • Page 7435.4 Parameter setting on CNC ============================ Parameters related to C Executor Descriptions of parameters Data number #7 #6 #5 #4 #3 #2 #1 #0 +--------+ +------+------+------+------+------+------+------+------+ │ 8650 │ │ │ │ │ CKM │ │ EKY │ CNA │ RSK │ +--------+ +------+------+------+-
  • Page 744Data number Data +--------+ +-------------------------------------------------------+ │ 8661 │ │ Size of variable areas │ +--------+ +-------------------------------------------------------+ Data format : word type Data unit : KByte Data range : 0 through 59 (251) Specify the size of the static vari
  • Page 745Data number Data +--------+ +-------------------------------------------------------+ │ 8663 │ │ Specification of time zone │ +--------+ +-------------------------------------------------------+ Data format : 2-word type Data unit : second Data range : -12*3600 through 12*3600 Specify the equation o
  • Page 7465.5 Dat2mem utility manual ========================== ---------------------------------------------------- Data file to Memory_Card file conversion utility ---------------------------------------------------- The "dat2mem.com" is a utility program which converts arbitrary MS-DOS data file to Memory_
  • Page 747Multiple MS-DOS data files are combined in this file. F-ROM file identification name for this type of file is "CEXnxxxx" where 'n' is a number from 0 to 9 and "xxxx" is any combination of max. 4 alpha- numeric characters. Ten C Executor data files ( "CEX0xxxx" -- "CEX9xxxx") can be stored in the F-R
  • Page 748The size of this type of file is calculated by size of existing C Executor program file + directory entry size (16 + number of data file * 32 bytes) + total size of all data files and the F-ROM memory blocks of 128KB unit is allocated to the file. This type of file is suited to store the data closel
  • Page 749(1) Name of the Memory_Card file being created Specify the name( usually *.mem) of the Memory_Card file to be created. The format of the file name part should be "CEXnxxxx", where 'n' is a number from 0 to 9 and "xxxx" is any combination of max. 4 alpha-numeric characters, "CEX1TOOL.MEM" or "CEX3DOC
  • Page 750[Example 1] Command file which combines all "*.dat" files in the directory "c:¥data" and creates "CEX1PARM.MEM". --<< from the next line >>---------------------------------------------------- ;================================ ; DAT2MEM Specification file ;================================ ;----------
  • Page 751(5) Error messages It can happen that following error messages are displayed. "insufficient memory" Cannot allocate enough memory to execute the program. "file open error xxx (??H)" Cannot open the file xxx. "file create error xxx (??H)" Cannot create the file xxx. "file read error xxx (??H)" Encoun
  • Page 7525.6 Conforming O8-digits program number ======================================= The program numbers are 8 digits in C language Executor for FANUC Series 30i. It is not compatible with the application of the program number 4 digits designed for FANUC Series 16/18. Please change the application referr
  • Page 7535.7 Window task =============== 5.7.1 Overview C Executor system is composed of 3 tasks, Main task, Alarm task and Communi- cation task. The Window task is fourth additional task to these 3 tasks. +--------------------------------------------+ CNC tasks │ CNC Interruption TASKs │ +------------------
  • Page 7545.7.3 Usage of the window task The typical processing flow of the window task is as follows. (1) Start │ (2) Initialize │ │ <---------------------+ │ <----------------+ │ │ │ │ (3) Wait the trigger ----------+ │ to display no trigger │ │ │ │ │ (4) Open VGA window │ │ │ │ <----------------+ │ │ │ │ (
  • Page 755(5) Display and read commands The application program displays to the VGA window. It also receives operator's commands. To receive commands, use the following method; (because the application can't read MDI keys.) Input signal from PMC. (using "pmc_rdpmcrng()" function) Status of touch-panel (using
  • Page 756(10) FCA library Unavailable. (11) F-ROM library Unavailable. (12) Touch-panel library Available. (13) Inter-task common variables (DRAM/SRAM) Available. 5.7.5 How to make application program The procedure to make window task application is mentioned below. Basically, it is same as the ordinary appl
  • Page 7575.8 Conforming CNC screen display ================================= 5.8.1 Overview It is possible to run C Executor on the following equipments on which "CNC screen display" application. * FS300i (CNC equipment with Personal Computer function) * FS300i connected via high-speed serial bus with Person
  • Page 7585.8.2 How do application program run on each equipment In this section, how each task of the application program runs is described. (1) FS300i with PC Status of CNC & PC Status of C-EXE application -------------------- ------------------------------ PC starts │ v CNC starts -------> Auxiliary tasks
  • Page 759[5] The window task must close already opened VGA windows when "CNCscrn- APP" is terminated. "CNCscrnApp" can't close itself while any VGA windows keep opening. It is possible to test whether "CNCscrnApp" is going closed or not by "crt_pcinfo()" function. [6] The main task runs again when "CNCscrnAp
  • Page 760(2) FS300i with HSSB/Ethernet Status of CNC & PC Status of C-EXE application -------------------- ------------------------------ CNC starts -------> Auxiliary tasks start [1] │ --------------------> Main task starts [2] │ │ │ │ │ *---> Window task starts │ CNC side display │ │ [3] │ v │ │ │ "CNCscrn
  • Page 761[6] When "CNCscrnApp" is closed on PC and CNC side screen wakes up again, the main task goes sleeping once. Because CNC's screen must be se- lected for changing the screen between CNC side and PC side. After starting CNC side display, by changing the screen to C-EXE the main task runs again and the
  • Page 7625.8.3 Restrictions on specification In this section, differences from C Executor on the ordinary FS30i are de- scribed. You can regard the specifications which are not listed below as same as on the ordinary FS30i with VGA display device. The following descrip- tions are applied to PC side screen if
  • Page 763(8) It is impossible to turn ON and OFF back-light of LCD screen by "ESC [>9l" and "ESC [>9h" while PC side screen is alive. [*] (9) It is impossible to set LCD screen reverse. [*] That is, "crt_setpalette( _PAL_RVS, xxx )" is unavailable. (10) It is impossible to start or terminate "CNCscrnApp" whi
  • Page 764(7) If you want to customize MDI key mapping for CNC's screen, alter key mapping on PC side ("CNCscrnApp"). (8),(9) To control LCD display (turning ON/OFF the back-light, reversing the screen), use the ordinary screen control feature of PC. (10) While the application program is displaying VGA window
  • Page 7655.8.5 Function reference ------------------------------------------------------------------------------ 1. Get status of CNC screen display application
    ------------------------------------------------------------------------------ [Name] crt_pcinfo [Syntax] #include unsigned short crt
  • Page 766(2) Status of "CNCscrnApp" This is a pack of bit-flags which indicates the status of "CNC screen display" application on PC. "1" means "effective" for each bit. CRT_PC_ENB 0x01 "CNC screen display" is available. (This bit is set as "1" when CNC is FS300i with PC, FS300i with HSSB, FS300i with Ethern
  • Page 767[Example] The following program closes VGA windows when "CNCscrnApp" goes closed on PC. (This is executed in the window task.) #include void example( void ) { unsigned short pcinfo ; pcinfo = crt_pcinfo() ; /* Is CNC 300i ? */ if ( pcinfo & CRT_PC_ENB ) { /* Has PC app closed or been down ?
  • Page 7685.9 High-Level Task ==================== 5.9.1 Overview of High-Level Task High-Level Task is the independent task of C Executor ordinary tasks (Main Task, Auxiliary Tasks and Window Task) and is called at fixed intervals. Task priority +-------------------------------------------------------+ │ CNC
  • Page 769(2) Available variable types and operators The following variable types are available in High-Level task. Type char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, array of these types and pointers to these type variables. Kind auto variable, static variable, global va
  • Page 7705.9.3 Task execution rule High-Level Task is called after CNC task in the periodical interrupt procedure at 8msec intervals. <---- 8msec ---> <---- 8msec ---> <---- 8msec ---> │----------------│----------------│----------------│ │--->│==>│ │--->│==>│ │--->│==>│ (A) (B) (A) CNC task (B) C-EXE High-Le
  • Page 771High-Level Task has priority over the other CNC tasks such as preparing task. If High-Level task runs long time, CPU time for CNC preparing task, etc. may be reduced. (In this case, any harmful effect, such as machining time by CNC's automatic operation increases, etc., may occur.) To avoid influenc
  • Page 7725.9.4 Application programming The following sections mention development process of application including High-Level Task. (1) Source module(s) The structure of High-Level Task's source modules is same as the other tasks. That is, it has one or more source modules ( "*.c" file ) and one "main()" fun
  • Page 7735.9.5 Function reference ------------------------------------------------------------------------------ 1. Interrupt execution of High-Level Task ------------------------------------------------------------------------------ [Name] rettask [Syntax] void rettask( void ) [Arguments] ------ [Re
  • Page 774------------------------------------------------------------------------------ 2. Start and End of getting the High-Level task execution management data ------------------------------------------------------------------------------ [Name] cnc_hldata [Syntax] #include int cnc_hldata
  • Page 7753. High-Level task execution management data "High-Level task execution management data" are variables in where how High- Level task runs is stored. The following structure is defined. struct HL_MNGDATA { unsigned long HL_COUNT ; unsigned int HL_STIME ; unsigned int HL_ETIME ; unsigned int HL_MAXETI
  • Page 776HL_MAXPROCTIME Maximum value of (HL_ETIME - HL_STIME) This is the maximum execution time of High-Level task. The unit of this value is [micro-sec]. HL_TIMEOVER Total counts that execution time exceeds the limit (1 msec). This is total count that High-Level task attempts to exceeds 1 msec execution t
  • Page 777Data format stored in buffer memory is as follows. Byte offset from the top of buffer Stored data -------------------+--------------- +0000 HL_STIME (0) +0004 HL_ETIME (0) +0008 HL_STIME (1) +0012 HL_ETIME (1) : :
  • Page 7785.10 Programming technique ========================== 5.10.1 Various techniques (1) Making application program faster There is considerable over-head in calling library function of C Executor. (in comparison with personal computer's applications.) This is mainly based on the two reason. 1. Execution
  • Page 779(2) How to use inter-task common variable There are two type variables (memory) that C Executor application can access. Local memory Memory that only owner task can access. Inter-task Memory that all tasks can access. common memory < C Executor memory > +-------------------------------+ │ Library me
  • Page 7805.10.2 Applying C Executor to machine (1) Machine maintenance Machine Tool Builders(MTB) can make their own custom man-machine interface, such as screen display and operation method, on CNC device made by FANUC using C Executor. This is better for MTB and end users in most case. However, take care t
  • Page 781B-63944EN-3/01 INDEX INDEX Difference of each task class......................................... 728 Display code for single byte characters......................... 723 2-byte characters........................................................... 720 Display control escape sequences ......
  • Page 782INDEX B-63944EN-3/01

    Parameter setting on CNC ............................................ 735 Power-on procedure...................................................... 734 Programming technique................................................ 770 Remarks ......................................

  • Page 783Revision Record FANUC Series 30i/300i/300is-MODEL A C Language Executor PROGRAMMIG MANUAL (B-63944EN-3) 01 Jul., 2003 Edition Date Contents Edition Date Contents
  • Page 784