Download Print this page
Omron NS Reference Manual
Hide thumbs Also See for NS:

Advertisement

Cat. No. V075-E1-08
NS-Series
Macro Reference
REFERENCE MANUAL

Advertisement

loading

Summary of Contents for Omron NS

  • Page 1 Cat. No. V075-E1-08 NS-Series Macro Reference REFERENCE MANUAL...
  • Page 3: Section1 Outline Of Macro Function

    Section 1 Outline of Macro Function NS series Macro Reference Section1 Outline of Macro Function This section describes execution conditions and programming procedure for using macro. 1-1 What is Macro?…………………………………………………………………….1 – 1 1-2 Macro Execution Condition……………………………………………………….1 – 2 1-3 Macro Programming…………………………………………………… …………1 – 8...
  • Page 4 CX-Designer. This function allows the PT to process screen display or data, which is performed by PLC before. It is also possible to reduce a load of PLC. In this manual, the timing for executing macro is called “Macro Execution Condition”. Macro can be made by roughly divided three execution conditions as shown below.
  • Page 5 Section 1 Outline of Macro Function NS series Macro Reference 1-2 Macro Execution Condition Macros can be created for each project, screen, and functional objects. Also they can be created for the following execution conditions. Executing conditions for the project Macro execution conditions that can be made for the project are indicated below.
  • Page 6 Section 1 Outline of Macro Function NS series Macro Reference Reference Macros are executed by the timing as shown below. NS series, NSJ series and NSH series When loading a screen When unloading a screen (Execute at the destination (Execute at the destination...
  • Page 7 NS series Macro Reference Execution conditions for the functional objects Macro execution conditions that can be made for each functional object are described in the following table. Open property dialog for each functional object and select [Macro] tab page, then set the execution condition and create macro.
  • Page 8 Section 1 Outline of Macro Function NS series Macro Reference The following conditions can be selected for functional objects. Functional Object ON/OFF Button Word Button Command Button Bit Lamp Word Lamp Numeral Display & Input String Display & Input Thumbwheel Switch...
  • Page 9 NS series Macro Reference Reference When a command button is set in the following functions, macros that are set at the touch on will be executed at the touch off. Macros that are set at the off will not be executed. Switch screen...
  • Page 10 This section describes macro creation procedures and programming terms. The Method for Writing a Macro Delimiter of the Program Put a semicolon (;) at the end of each program as a delimiter. However, it is not necessary for IF (), ELSEIF (), ELSE(),ENDIF. Example;...
  • Page 11 ‘Accesses regarding $W0, $W1 as 32-bit $W100L=1000*1000; ‘Accesses regarding $W100, $W101 as 32-bit Numeral Put “:n” at the end of variable. Specify the value of bit address (up to 32 Access of Bit by 4-bit unit) for “n”. Exceptions: If n=16, input ”W”.
  • Page 12 Section 1 Outline of Macro Function NS series Macro Reference Constant Usable constants for macro program and procedure are described in the following table. Item Explanation Decimal constant -32768 to 32767 can be input when using word (16-bit) -2147483648 to 2147483647 can be input when using 2...
  • Page 13 The result (A&&B, A>B) can be substituted for the variable. E.g.$B100=$W0>100; If the value of $W is “100” or less, “0” will be substituted for $B100. If the value of $W is more than ”100”, “1” will be substituted for $B100.
  • Page 14 Se the value that A is arithmetic shifted B-bit to the right to C. Reference If executing logical operation, process must be performed between the same data types (between word, bit, or long access) E.g.$SW0L=$SW10L&$W20L;’Use all long access of word’...
  • Page 15 Section 1 Outline of Macro Function NS series Macro Reference Functions The following functions are provided for macro of NS Series. Action Function Conversion between BCD Value (BIN code)->BCD code and BIN BCD code->value (BIN code) Manipulating character Copy character string...
  • Page 16 Section 1 Outline of Macro Function NS series Macro Reference Data manipulation Swap high order and low order of SWAP /conversion the specified address. Swap high order (2byte) and low SWAPL order (2byte) of the specified long word data. Copy contents of $W in the PT...
  • Page 17 Section 1 Outline of Macro Function NS series Macro Reference The timing when a function can be executed as shown below. Project Macro Screen Functional object Macro Macro CLOSEPOPW GETNUMVAL GETPARTS MOVEPARTS MOVEPOPW MOVEPOPWDOWN MOVEPOPWLEFT MOVEPOPWRIGHT MOVEPOPWUP MSGBOX READCMEM RETURN...
  • Page 18 Section 1 Outline of Macro Function NS series Macro Reference Added Functions Action Function Remarks Set Date/Time SETTIME Added in the NS system program Ver.3.0 Reading/writing data READCF Added in the NS system program Ver.4.0 WRITECF Data manipulation SWAP /conversion...
  • Page 19 Section 1 Outline of Macro Function NS series Macro Reference In addition to macro of NS Series, the following functions are provided for macro of NS-Runtime. Action Function Manipulating String Comparison (Case sensitive) STRCMP/STRCMPW character strings String Comparison (Not case sensitive)
  • Page 20 Section 1 Outline of Macro Function NS series Macro Reference The timing when a function can be executed as shown below. Screen Project Macro Functional object Macro Macro STRCMP(W) STRICMP(W) STRCAT(W) STRLEN(W) STRLEFT(W) STRMID(W) STRRIGHT(W) STRLTRIM(W) STRTRIM(W) STRRTRIM(W) STRLWR(W) STRUPR(W)
  • Page 21: Section2 Functions

    Section2 Functions NS series Macro Reference Section2 Functions This section describes how to use the standard functions. Table of Function and Argument..................2 Details of the Function....................... 7...
  • Page 22 NS series Macro Reference 2-1 Table of Function and Argument The varity of variables and values, which can be specified as an argument for macro function is described below. Alphabets such as S,D,n,x,y in the row indicated parameter used in “2-2”...
  • Page 23 Section2 Functions NS series Macro Reference PT Memory Function ○ ○ ○ ○ ○ ○ ○ ○ ○ READCMEM ○ ○ ○ ○ ○ ○ RETURN ○ ○ ○ ○ ○ RSTALARMCNT ○ ○ ○ ○ ○ SHOWPAGE ○ ○...
  • Page 24 Section2 Functions NS series Macro Reference PT Memory Function ○ ○ ○ ○ ○ READHOSTB ○ ○ ○ ○ ○ ○ addr ○ ○ ○ ○ ○ ○ ○ ○ READHOSTW ○ ○ ○ ○ ○ ○ ○ ○ ○...
  • Page 25 Section2 Functions NS series Macro Reference The following macros can be used only with NS-Runtime. PT Memory Function ○ ○ ○ STRCMP(W) ○ ○ ○ ○ ○ ○ STRICMP(W) ○ ○ ○ ○ ○ STRCAT(W) ○ ○ ○ ○ ○...
  • Page 26 Section2 Functions NS series Macro Reference PT Memory Function ○ ○ ○ WINNORMAL ○ ○ ○ ○ ○ ○ ○ ○ WINTERM ○ ○ ○ ○ ○ ○ ○ ○ WINTOP ○ ○ ○ ○ ○ ○ ○ ○ ○...
  • Page 27 BCD(S) Function Convert value “s” to BCD code Converting range is 0 to 99999999 If you specify the character string outside of the range, overflow occurs. “0” is set at the end of the character string. Return Value BCD code Example $W0 = 1234;...
  • Page 28 System Version 6.2 or higher Format BITSET(D, c, n) Function Writes c(0/1) for n-bit data from bit address D in the PT memory ($B/$HB). D: Starting address c: Set value (0/1) n: Number of elements to write 1 to 32768 ($B)
  • Page 29 System version 2 or higher Format CLOSEPOPW(n) Function Close pop-up window screen page number “n” Setting range for “n” is 0 to 3999. If you set pop-up screen page number that does not exist, the process will not be performed. Return Value None Example...
  • Page 30 Applicable versions System version 6 or higher Format CONTINUE Function During a program between “FOR to NEXT”, it will return to the top of the FOR loop and resume the FOR process. Return Value None Example If ‘$W50I0>30 is true, a loop will return to the top, and resume the next repetitious program.
  • Page 31 $SW27=0; FOR(10) $W0I0=0; $SW27=$SW27+1; NEXT; *Setting range for “n” is 0 to 32767. A negative number is considered as 0. $W, $HW or $SW can be specified as an address. GETNUMVAL Outputs written value and changed value Applicable versions System version 2 or higher...
  • Page 32 (Right, Bottom) at the lower right on rectangle. (Left T op ) (Right, Bottom) Setting range is 0 to 1023. If you set other value or ID number that does not exist, return value 1 will be returned. Return Value...
  • Page 33 When specifying “n” indirectly: $W0 to $W32767 $HW0 to $HW8191 Note: Index can be set when using address to specify for S. Setting range is for $W is between 0 and 32767 and for $HW is between 0 to 8191.
  • Page 34 System Version 6.2 or higher Format MEMSET(D, c, n) Function Writes data c for n-word from a word address D in the PT memory ($W/$HW). D: Starting address c: Set value -32767 to 32768 (decimal format) H0000 to HFFFF (hexadecimal format)
  • Page 35 Specify coordinate upper left of the moving object for “x, y”. Setting range for “n” is 0 to 1023. If the value out side the range or ID number that does not exist is specified, return value –1 will be returned. There is no restriction on setting value for “x, y”.
  • Page 36 Moves top left of the pop-up window for screen number “n” to the specified coordinates (x, y). Setting range for “n” is 0 to 3999. If the value outside of the range or screen number that does not exist is specified, return value “-1” will be returned. There is no restriction on setting the value for “x, y”.
  • Page 37 Move the pop-up window page number “n” to y down. Setting range for “n” is 0 to 3999. If the value outside of the range or page number which does not existed is specified, return value “-1” will be returned. There is no restriction on setting value for “y”.
  • Page 38 Move the pop-up window page number “n” to x dot left. Setting rage for “x” is 0 to 3999. If the value outside of the range or page number that does not exist is specified, return value “-1” is returned. There is no restriction on setting the value for “x”.
  • Page 39 Move pop-up window page “n” to x dot right. Setting range for “n” is 0 to 3999. If the value outside the range or screen number that does not exist is specified, return value “-1” is returned. There is no restriction on setting for “x”.
  • Page 40 Move the pop-up screen page “n” to y dot up. Setting range for “n” is 0 to 3999. If the value outside of the range or page number that does not exist is specified, return value “-1” is returned. There is no restriction on setting the value for “y”.
  • Page 41 Select PT – Project Properties in the CX-Designer to display the Project Property Dialog box. Checking “Recognize “\n” in the message as a line feed code” of the MSGBOX option in the Macro option tab enables to insert a line feed by typing “\n” in the message string.
  • Page 42 1 is displayed. Message box of lamp 2 is not displayed and value “1” is stored in $W1. If Buzzer Sound is set ON or OFF at PT tab in the system menu and STOP or EXCLAMATION is specified for the icon, buzzer will be sounded when displaying...
  • Page 43 0 and 8191. If the set value is exceeded the maximum, an access error occurs and an error message appears. If the value 0 or less is set for Size, the specified size will be read to the PT memory.
  • Page 44 Applicable versions System version 2 or higher Format READCMEM (D,S,n) Function Read n but/n channel from the address in the host specified with “s”, and copy to “D”. Maximum points for reading are indicated below. 126Bit Word 126Channel If value outside of the range is set for “n”, communication error or macro execution error occurs.
  • Page 45 To check the host number, confirm the number at the left side of host name shown on the Comm.Setting dialog of CX-Designer. Also, note that if a host name is changed with CX-Designer when the host name is used as argument h of READHOSTB, it is necessary to specify the host name after change.
  • Page 46 HOST3 HOST3 Please note that when a host number is given as argument h of READHOSTW, it is necessary to specify the host number after change. With the above example, please change the macro as follows. Macro Before Deleting Host READHOSTW($B10,3,100,1000,0,10);...
  • Page 47 No argument is used. Function If the input focus has been set for any of numeral display & input object or string display & input object in the project, this macro will release the input focus. If an object that the input focus has been set exists on the screen currently displayed, the macro will release the input focus.
  • Page 48 System version 2 or higher Format RSTALARMCNT(S) Function When the value of “S” is 0, clear the number of occurrence of alarm. When the value of “s” is 1, clear the number of occurrence of event. Return Value 0: Completed normally...
  • Page 49 System version 5 or higher Format SETFOCUS(n); Function Set the input focus on the specified numeral display & input object or string display & input object. n: Object ID number which the input focus should be set. (0 to 32767) When setting the input focus for the object specified as top in the Input Order List, set ”-1”.
  • Page 50 Format SETTIME(S) Function Preset values for the specified address as S and writes them to the internal clock of PT. Setting range for S is between $W0 and $W32765 or between $HW0 and $HW8189. (See note) Set the value in BCD format for addresses to be written.
  • Page 51 Switch screen to the page that is specified in “s”. Setting range for “s” is 0 to 3999. If the value outside of the range is set, macro execution error occurs. If the screen number that does not exist is set, reading page error occurs.
  • Page 52 Switch screen to the page that is specified in “S”. Setting range for “S” is H0 to H3999. If either the value outside of the range is set or an invalid value is set for BCD, macro execution error occurs. If the screen number that does not exist is set, reading page error occurs.
  • Page 53 Reference ‘null’ matches for “00” in ASCII code, and “0000” in Unicode. Care must be taken to set string to $W32767 because copy is performed including null. When executing STRCPY(W), string data and null may not be executed $W32767 because null is copied. (If data is exceeded $W32767, communication error occurs).
  • Page 54 Converts character string from Unicode to ASCII code Applicable versions System version 2 or higher Format STRW2M (D,S) Function Convert string specified in “S” to ASCII code and copy to “D”. Copy is performed including null. Return Value None Example STRW2M($W0, “ABC”);...
  • Page 55 Format SWAP(S,n) Function Swap high order (1 byte) and low order (1 byte) of the word data or the internal holding word which was taken n word form S. S: Top address ($W or $HW) to be swapped. (See note.) n: The number of words to be taken from S.
  • Page 56 SWAPL(S,n) Function Swap high order (2 byte) and low order (2 byte) of the long word data or the internal holding word which was taken n long word from S. S: Top address ($W or $HW) to be swapped. (See note.) n: The number of words to be swapped.
  • Page 57 (Return value will be 0 (Completed normally)). Up to 43 alphanumerical characters (“0 to 9”, “A to Z”, “a to z”, “$”, “_”) including extension can be set for the file name. Dev: Always specify 0 since destination will be a Memory Card only.
  • Page 58 Applicable versions System version 2 or higher Format WRITECMEM(D,S,n) Function Copy data of n bit/n channel from “S” to the address in the host specified in “D”. Maximum points of writing are indicated below. 126Bit Word 126Channel If the value outside of range is set for “n”, communication error or macro execution error occurs.
  • Page 59 To check the host number, confirm the number at the left side of host name shown on the Comm.Setting dialog of CX-Designer. Also, note that if a host name is changed with CX-Designer when the host name is used as argument h of WRITEHOSTB, it is necessary to specify the host name after change.
  • Page 60 To check the host number, confirm the number at the left side of host name shown on the Comm.Setting dialog of CX-Designer. Also, note that if a host name is changed with CX-Designer when the host name is used as argument h of WRITEHOSTW, it is necessary to specify the host name after change.
  • Page 61 Holding area (HR) Auxiliary area (AR) Link area (LR) Work area (WR) Timer (TIM) Only available for READHOSTW / WRITEHOSTW Counter (CNT) Only available for READHOSTW / WRITEHOSTW Data memory area (DM) Expansion data memory (EM) Expansion data memory 0 (EM0)
  • Page 62 Section2 Functions NS series Macro Reference The following macros can be used with NS-Runtime. The details of macros are described as below. EXEC Application Startup Applicable versions System Version 6.6 or higher Format EXEC(S1, S2,S3) Function Executes the command specified with S1 and displays at S2 window title and in S3 window style Specify a startup file and a startup argument with S1.
  • Page 63 System Version 6.6 or higher ・・・ASCII code Format STRLEFT(D,S,n), ・・・Unicode STRLEFTW(D,S,n) Function Stores n characters from the left of the string S to D. Return Value None Example STRLEFT($W0,"ABCDEFG",3); 'Extract 3 characters (ABC) from the leftmost string and store ABC in $W0 to $W1.
  • Page 64 System Version 6.6 or higher ・・・ASCII code Format STRLWR(D, S) ・・・Unicode STRLWRW(D, S) Function Converts upper cases of the string S to lower cases and enter them to D. Return Value None Example STRCPY($W0, "ABC"); STRLWR($W10, $W0); 'Set abc to $W10 to $W11...
  • Page 65 System Version 6.6 or higher ・・・ASCII code Format STRMID(D,S,n1,n2) STRMIDW(D,S,n1,n2) ・・・Unicode Function Extracts n2 characters from n1 of a string specified with S. Then store them in D. (n1: The head of a string is set to 1.) Return Value None Example STRMID($W0,"ABCDEFG",2,3);...
  • Page 66 System Version 6.6 or higher STRTRIM(D,S) ・・・ASCII code Format STRTRIMW(D,S)・・・Unicode Function Extracts spaces at both sides of a string specified with S. Then stores them to D. Return Value None Example STRTRIM($W0, " ABC "); 'Set ABC in $W0 to $W1 excluding spaces at both ends.
  • Page 67 System Version 6.6 or higher STRUPR(D, S) ・・・ASCII code Format STRUPRW(D, S) ・・・Unicode Function Converts a string S from lower case to upper case. Then set it to D. Return Value None Example STRCPY($W0, "abc"); STRUPR($W10, $W0); ‘Set ABC to $W10 to $W11.
  • Page 68 0:Window title that completely matches with S1. 1:Window title that matches with the number of characters of S1. 2:Window title that matches with the number of characters of S1 (Except for a folder). Use Unicode if you use a symbol to specify a string with S1.
  • Page 69 0:Window title that completely matches with S1. 1:Window title that matches with the number of characters of S1. 2:Window title that matches with the number of characters of S1 (Except for a folder). Use Unicode if you use a symbol to specify a string with S1.
  • Page 70 The 0 bit to 3rd bit: 0:Window title that completely matches with S1. 1:Window title that matches with the number of characters of S1. 2:Window title that matches with the number of characters of S1 (Except for a folder). The 4th bit: 0:Sends a WOM_CLOSE message to a specified window.
  • Page 71 0:Window title that completely matches with S1. 1:Window title that matches with the number of characters of S1. 2:Window title that matches with the number of characters of S1 (Except for a folder). Use Unicode if you use a symbol to specify a string with S1.
  • Page 72: Section3 Error Message List

    Section3 Error Message List NS series Macro Reference Section3 Error Message List This section describes error message which is displayed in error list box when macro is added to the project, the screen and the functional objects. Error Message List ................53...
  • Page 73 Section3 Error Message List NS series Macro Reference Error Message List Error messages are displayed in the error list box after checking the error as shown below. Details Example Error Message Format error The program contains description besides $W0=ABC+100; variable name, function name, or programming terms that cannot be recognized.

This manual is also suitable for:

Ns-series