Download Print this page
Hide thumbs Also See for XD Series:

Advertisement

Quick Links

XD/XL series PLC
User manual [Instruction]
WUXI XINJE ELECTRIC CO., LTD.
Data No. PD05 20220627EN 1.0

Advertisement

loading

Summary of Contents for Xinje XD Series

  • Page 1 XD/XL series PLC User manual [Instruction] WUXI XINJE ELECTRIC CO., LTD. Data No. PD05 20220627EN 1.0...
  • Page 2 Preface ————————————————— Programming summary ————————————————— Soft component functions ————————————————— Basic program instructions ————————————————— Applied instructions ————————————————— High speed counter ————————————————— Pulse output XD/XL series PLC ————————————————— User manual[Instruction] Communication functions ————————————————— PID functions ————————————————— C Language function block ————————————————— Sequence BLOCK —————————————————...
  • Page 3 Excuse us that we will not inform you if manual is changed.  Contact information If you have any problem about products, please contact the agent or Xinje company. Tel: 0086 510-85134136 85123803 Fax: 0086 510-85111290 Address: Building 7 fourth floor, No.100, Dicui Rd, Wuxi, China.
  • Page 4 Catalog 1 PROGRAMMING SUMMARY ....................10 1-1 PLC F ..........................10 EATURES 1-2 P ......................11 ROGRAMMING ANGUAGE 1-2-1 Type ............................11 1-2-2 Alternation ..........................11 1-3 P ........................12 ROGRAMMING MODE 2 SOFT COMPONENT FUNCTION ................... 13 2-1 S ..................13 UMMARY OF THE OMPONENTS 2-2 S...
  • Page 5 3-16 [GROUP] , [GROUPE] .......................76 3-17 P ........................ 76 ROGRAMMING NOTES 4 APPLIED INSTRUCTIONS ...................... 78 4-1 A ......................78 PPLIED NSTRUCTIONS 4-2 R ................82 EADING ETHOD OF PPLIED NSTRUCTIONS 4-3 P ....................85 ROGRAM NSTRUCTIONS 4-3-1 Condition Jump [CJ] ......................85 4-3-2 Call subroutine [CALL] and Subroutine return [SRET] ............
  • Page 6 4-7-5 Bit shift right [SFTR] ......................139 4-7-6 Word shift left [WSFL] ......................140 4-7-7 Word shift right [WSFR] ..................... 141 4-8 D ..........................142 ONVERT 4-8-1 Single word integer converts to double word integer [WTD.DWTD] ........ 143 4-8-2 32 bits integer to 64 bits integer batch conversion [BDWTD] ...........144 4-8-3 Integer converts to float point [FLT, DFLT,FLTD] .............
  • Page 7 4-10-8 Convert second data to hours, minutes, and seconds[STOH] ........... 195 4-10-9 Clock compare [TCMP] ....................196 4-10-10 Date (year, month, day) compare [DACMP] ..............197 5 HIGH SPEED COUNTER (HSC) ................... 200 5-1 F ........................ 200 UNCTIONS UMMARY 5-2 HSC M ..........................201 5-3 HSC R ..........................
  • Page 8 6-3-2 Serial port configuration ......................280 6-3-3 Suitable occasion ......................... 282 6-3-4 Free communication instruction ..................282 6-3-5 Free communication example ....................286 6-4 C ..................292 OMMUNICATION FLAG AND REGISTER 6-5 R ..................296 EAD WRITE SERIAL PORT PARAMETERS 6-5-1 Read serial port parameters [CFGCR] ................296 6-5-2 Write serial port parameters [CFGCW] ................297 6-5-3 Serial port parameter name and setting ................
  • Page 9 9-2-2 Move the BLOCK ....................... 360 9-2-3 Delete the BLOCK ......................361 9-2-4 Modify the BLOCK ......................361 9-3 E BLOCK ..................362 DIT THE INSTRUCTION OF THE 9-3-1 Command item ........................362 9-3-2 Pulse Item ..........................364 9-3-3 Wait Item ..........................365 9-3-4 Module Read and Write(FROM/TO)instruction ..............
  • Page 10 Q15: W ? ....425 HY THE OUTPUT POINT ACTION ERRORS AFTER RUNNING FOR A WHILE Q16: W ON? .......425 HY EXPANSION MODULE DOES NOT WORK WHILE POWER INDICATOR IS Q17: W ? ....425 HY THE SIGNAL INPUT BUT CANNOT SEE THE HIGH SPEED COUNTER WORKING Q18: C ? ............426 LANGUAGE ADVANTAGES COMPARED TO LADDER CHART...
  • Page 11 1 Programming Summary XD/XL series PLC accept the signal and execute the program in the controller, to fulfill the requirements of the users. This chapter introduces the PLC features, two kinds of programming language and etc. 1-1 PLC Features Programming Language XD/XL series PLC support two kinds of program language, instruction and ladder chart, the two kinds of language can convert to each other.
  • Page 12 Stop PLC whenreboot XD/XL series PLC support “Stop PLC when reboot” function. When there is a serious problem during PLC running, this method can stop all output immediately. Besides, if the COM port parameters are changed by mistake, this function can help PLC connect to the PC. Communication Function XD/XL series PLC has many communication modes, such as Modbus-RTU, Modbus-ASCII.
  • Page 13 1-3 Programming mode Direct Input The two kinds of programming language can be input directly in the editing window. The ladder chart window has hint function which improves the programming efficiency greatly. Instruction Configuration Some instruction is complicated to use, like pulse output, PID etc. XDPPro software has the configuration window for these special instructions.
  • Page 14 2 Soft Component Function In chapter 1, we briefly introduce the programming language. However, the most important element in a program is the operands. These elements include the relays and registers. In this chapter, we will describe the functions and using methods of these relays and registers. 2-1 Summary of the Soft Components There are many relays, timers and counters inside PLC.
  • Page 15 XD1/XD2/XL1 does not support extension modules, XD3/XL3 can accept 10 extension modules, XD5/XDM/XDC/XD5E/XDME/XDH/XL5/XL5E/XLME can accept 16 extension modules. Expanding the address number of BD board, starting from X20000 according to octal system, 24-32 points PLC can extend one BD board, 48-60 points PLC can extend two BD boards. (16-point PLC does not support extended BD board, XL/XDH series does not support extended BD board.) The address number of the left extended ED module, starting from Y30000 according to octal...
  • Page 16 There are three timer pulses: 1ms, 10ms, and 100ms. For example, 10ms means accumulate 10ms pulses.  Accumulation/not accumulation The timer has two modes: accumulation timer means even the timer drive coil is OFF, the timer will still keep the current value; while the not accumulation timer means when the accumulation value reaches the set value, the output acts, the accumulation value reset to 0.
  • Page 17 Special secret Register (FS)  The Function of Secret Register A part of the FlashROM register is used to store data in soft components, which are represented by the symbol FS. The values in the FS register can be written but can not be read, so they can be used to protect the intellectual property rights of users.
  • Page 18 D10[D0] D100 Y0[D0] When D0=0, D100=D10, Y0 is ON. When M2 turns from OFF to ON, D0=5, then D100=D15, Y5 is ON. Therein, D10[D0]=D[10+D0], Y0[D0]=Y[0+D0]. The word offset combined by bit: DXn[Dm] represents DX[n+Dm]. The soft components with offset, the offset can represent by soft component D, HD. Timer T, HT/Counter C, HC For common usage,16 bits, represent the current value of timer/counter;...
  • Page 19 DX2[D0] When M0 changes from OFF to ON, the value in the word which is combined by Y0~Y17 equals to 21, i.e. Y0, Y2, Y4 become ON. Before M1 activates, if D0=0, DX2[D0] represents a word combined by X2~X21. If M1 changes from OFF to ON, D0=3, then DX2[D0] represents a word combined by X5~X24.
  • Page 20 2-3 Soft Components List 2-3-1 Soft Components List XD1 series PLC soft components list: Range Points Name 10 I/O 16 I/O 24 I/O 32 I/O X Input points X0~X4 X0~X7 X0~X13 X0~X17 Output Y0~Y4 Y0~Y7 Y0~Y13 Y0~Y17 points M0~M7999 8000 Internal HM0~HM959 ※1...
  • Page 21 Output Y30000~Y30077(#1 expansionED) points ※5 M0~M7999 8000 Internal relay HM0~HM959 ※1 Special purposeSM0~SM2047 ※2 2048 S0~S1023 1024 Flow HS0~HS127 ※1 T0~T575 Timer HT0~HT95 ※1 Precise timer ET0~ET31 C0~C575 Counter HC0~HC95 ※1 High speed counter HSC0~HSC31 D0~D7999 8000 HD0~HD999 ※1 1000 Data register Special purposeSD0~SD2047 2048...
  • Page 22 Input points X30000~X30077(#1expansionED) ※5 Output points Y30000~Y30077(#1expansionED) ※5 M0~M7999 8000 Internal relay HM0~HM959 ※1 special purpose SM0~SM2047 2048 ※2 S0~S1023 1024 Flow HS0~HS127 ※1 T0~T575 Timer HT0~HT95 ※1 precise timer ET0~ET31 C0~C575 Counter HC0~HC95 ※1 High speed counter HSC0~HSC31 D0~D7999 8000 HD0~HD999 1000...
  • Page 23 XD5 series PLC soft components list: Range Points Name 16I/O 24 I/O 32 I/O 48 I/O 60 I/O Input points X0~X7 X0~X15X0~X21X0~X33X0~X43 8 Output points Y0~Y7 Y0~Y11Y0~Y15Y0~Y23Y0~Y27 8 X10000~X10077(#1 expansion module) …… Input points ※3 1024 X11700~X11777(#16 expansion module) Y10000~Y10077(#1 expansion module) Output ……...
  • Page 24 QD20000~QD20099(#1expansionBD) expansion BD QD20100~QD20199(#2expansionBD) expansion ED QD30000~QD30099(#1expansionED) Special coil of Sequence block SEM0~SEM31 instruction WAIT XDM series PLC soft components list: Range Points Name 24 I/O 32 I/O 60 I/O Input points X0~X15 X0~X21 X0~X43 Output points Y0~Y11 Y0~Y15 Y0~Y27 X10000~X10077(#1 expansion module) ……...
  • Page 25 ID10000~ID10099(#1 expansion module) Expansion module …… 1600 ID11500~ID11599(#16 expansion module) ID20000~ID20099(#1expansionBD) expansion BD ID20100~ID20199(#2expansionBD) expansion ED ID30000~ID30099(#1expansionED) Main body QD0~QD99 QD10000~QD10099(#1 expansion module) …… Expansion module 1600 QD11500~QD11599(#16 expansion ※7 module) QD20000~QD20099(#1expansionBD) expansion BD QD20100~QD20199(#2expansionBD) expansion ED QD30000~QD30099(#1expansionED) Special coil of Sequence block SEM0~SEM31 instruction WAIT...
  • Page 26 HD0~HD24999 25000 ※1 Special purpose SD0~SD4999 5000 Special purpose HSD0~HSD1023 ※2 1024 FD0~FD8191 8192 FlashROM register Special purpose SFD0~SFD5999 6000 ※2 Special secret FS0~FS47 register Main body ID0~ID99 ID10000~ID10099(#1 expansion module) Expansion …… 1600 module ID11500~ID11599(#16 expansion module) ※6 ID20000~ID20099(#1expansionBD) expansion BD ID20100~ID20199(#2expansionBD) expansion ED ID30000~ID30099(#1expansionED)
  • Page 27 Range Points Name 24 I/O 30 I/O 48 I/O 60 I/O Output Y30000~Y30077(#1 expansion ED) points ※5 M0~M69999 70000 Internal HM0~HM11999 12000 ※1 relay special purpose SM0~SM4999 5000 ※2 S0~S7999 8000 Flow HS0~HS999 1000 ※1 T0~T4999 5000 Timer HT0~HT1999 ※1 2000 precise timer ET0~ET39 C0~C4999...
  • Page 28 Range Points Name 24 I/O 30 I/O 48 I/O 60 I/O Special coil of Sequence block SEM0~SEM31 instruction WAIT XDME series PLC soft components list: Range Points Name 30 I/O 60 I/O Input points X0~X17 X0~X43 Output Y0~Y15 Y0~Y27 points X10000~X10077(#1 expansion module) Input ……...
  • Page 29 ID10000~ID10099(#1 expansion module) Expansion …… 1600 module ID11500~ID11599(#16 expansion module) expansion ID20000~ID20099(#1expansionBD) ID20100~ID20199(#2expansionBD) expansion ID30000~ID30099(#1expansionED) Main body QD0~QD99 QD10000~QD10099(#1 expansion module) Expansion …… 1600 module QD11500~QD11599(#16 expansion ※7 module) expansion QD20000~QD20099(#1expansionBD) QD20100~QD20199(#2expansionBD) expansion QD30000~QD30099(#1expansionED) Special coil of Sequence block SEM0~SEM31 instruction WAIT XDH series PLC soft components list:...
  • Page 30 D0~D499999 500000 HD0~HD49999 50000 ※1 Data register special purpose SD0~SD49999 50000 special purpose HSD0~HSD49999 ※2 50000 FD0~FD65535 65536 FlashROM register special purpose SFD0~SFD49999 50000 ※2 Special secret FS0~FS47 register Main body ID0~ID99 ID10000~ID10099(#1 expansion module) Expansion …… 1600 module ID11500~ID11599(#16 expansion module) ※6 ID20000~ID20099(#1 expansion BD) expansion BD...
  • Page 31 S0~S1023 1024 Flow HS0~HS127 ※1 T0~T575 Timer HT0~HT95 ※1 precise timer ET0~ET31 C0~C575 Counter HC0~HC95 ※1 high speed counter HSC0~HSC31 D0~D7999 8000 HD0~HD999 1000 ※1 Data register special purpose SD0~SD2047 2048 special purpose HSD0~HSD499 ※2 FD0~FD5119 5120 FlashROM register special purpose SFD0~SFD1999 2000 ※2 Special secret...
  • Page 32 Range Points Name 16 I/O 32 I/O Y10000~Y10077(#1 expansion module) Output …… points ※3 Y11100~Y11177(#10 expansion module) X20000~X20077(#1 expansion BD) Input points ※4 X20100~X20177(#2 expansion BD) Output Y20000~Y20077(#1 expansion BD) points Y20100~Y20177(#2 expansion BD) ※4 Input points X30000~X30077(#1 expansion ED) ※5 Output Y30000~Y30077(#1 expansion ED)
  • Page 33 Range Points Name 16 I/O 32 I/O QD30000~QD30099(#1 expansion expansion ED Special coil of Sequence block SEM0~SEM31 instruction WAIT XL5, XL5E, XLME series PLC soft components list: Range Points Name 32 I/O 64 I/O 16 I/O Input points X0~X7 X0~X17 X0~X37 Output points Y0~Y7...
  • Page 34 ID20000~ID20099(#1expansion BD) expansion BD ID20100~ID20199(#2expansion BD) expansion ED ID30000~ID30099(#1expansion ED) Main body QD0~QD99 QD10000~QD10099(#1 expansion module) …… Expansion module 1600 ※ QD11500~QD11599(#16 expansion module) QD20000~QD20099(#1expansion BD) expansion BD QD20100~QD20199(#2expansion BD) expansion ED QD30000~QD30099(#1expansion ED) Special coil of Sequence block SEM0~SEM31 instruction WAIT XLH series PLC soft components list: Range...
  • Page 35 Range Points Name 24 I/O HS0~HS1999 ※1 2000 T0~T19999 20000 Timer HT0~HT1999 2000 ※1 precise timer ET0~ET39 C0~C19999 20000 HC0~HC1999 2000 ※1 Counter high speed counter HSC0~HSC39 D0~D499999 500000 HD0~HD49999 50000 ※1 Data register special purpose SD0~SD49999 50000 special purpose 50000 HSD0~HSD49999 ※2...
  • Page 36 Memory area is the default power outage holding area (Note: XD/XL series PLC ※ 【】 power outage holding area can not be modified). 2: Special use (non-power-down maintenance) refers to registers for special use occupied ※ by the system, which can not be used for other purposes. For details, refer to the relevant sections of the List of Special Soft Components in the appendix of this manual.
  • Page 37 2-4 Input/output relays (X, Y) Number List XD series PLC input/output are all in octal form, each series numbers are listed below: Range Points Series Name 10 16 24 30 42 48 60 X0~X4 X0~X7 X0~X13 X0~X17 8 12 Y0~Y4 Y0~Y7 X0~X13...
  • Page 38 Function XD/XL series CPU unit Input Relay X PLC input terminals are used to recive the external signal. the input relays are optocoupler to connect PLC and input terminals The input relays which are not connected with external devices can be seemed to fast internal relays Output Relay Y PLC output terminals can be used to send signals to external loads.
  • Page 39 Input processing Before PLC executing the program, read every input terminal’s ON/OFF status to the image area. When the program is running, even the input changed, the content in the input image area will not change until the next scanning period coming. Output processing After running all the instructions, transfer the ON/OFF status of output Y image area to the output lock memory area.
  • Page 40 Special relays are some relays which are defined with special meanings or functions, start from SM0. There are two functions for special relays, first is used to drive the coil, the other type is forspecial running. E.g.: SM2 is the initial pulse, activates only at the moment of start SM34 is “all output disabled”...
  • Page 41 2-7 Timer (T, HT) Address List The timer addresses of XD/XL series PLC are in the form of decimal; please see the following table: Range Series Name Power-off Normal Precise timer holding XD1/XD2/XD3 T0~T575 HT0~HT95 ET0~ET24 HT0~HT1999 ET0~ET24 XD5/XDM/XDC/XD5E/XDME T0~T4999 T0~T19999 HT0~HT1999 XL1/XL3...
  • Page 42 Accumulation type If X0 is ON, HT0 accumulates the 10ms pulse based on the current value. When the accumulation value reaches the set value K2000, the timer outputactivates. If X0 is suddenly OFF during timer working, the timer value will be retentive.
  • Page 43 MOV K1 D0 TMR T0 D0 K100 TMR T0 K1 K100 Set value is constant K set value is register D Power-off retentive, accumulation (1) Time unit is 1ms, set time is K100, the real time is 1ms *100=0.1s MOV K100 D0 TMR_A HT0 D0 K1 TMR_A HT0 K100 K1 Set value is constant K...
  • Page 44 The time value is stored in register TD. The working mode of timer T0~T575 and HT0~HT95 are 16-bits linear increasing. The time range is from 0 to 32767. When the time value in TD reaches 32767, the timer will stop timing and keep the status. MOV T0 D0 MOV TD0 D0 The two instructions are the same.
  • Page 45 The counter addresses of XD/XL series PLC are in decimal; please see the following table for details: Range Series Name Power-off High speed Normal holding counter XD1/XD2/XD3 C0~C575 HC0~HC95 HSC0~HSC31 XD5/XDM/XDC/XD5E/XDME C0~C4999 HC0~HC1999 HSC0~HSC39 C0~C19999 HC0~HC1999 HSC0~HSC39 XL1/XL3 C0~C575 HC0~HC95 HSC0~HSC31 XL5/XL5E/XLME C0~C4999...
  • Page 46 16-bit common counter and power-off retentive counter The set value range of 16-bit count-up counter is K1~K32,767(decimal). K0 and K1 have the same function. They mean the counter output will act at the first counting. If the PLC power supply is cut off, common counter value will be reset. The power-off retentive counter value will be kept.
  • Page 47 32-bit counter: Reset instruction: 16-bit counter: 32-bit counter: DRST S1: counter (such as C0, HC10) S2: counter set value (such as K100) The counter is different from XC series. They don’t have 16-bit and 32-bit type. The type is set through instruction. 16-bit counter (common, count up) 《set value is constant K》《set value is register 》...
  • Page 48 32-bit counter (common, count up) 《set value is constant K》《set value is register 》 DMOV K43100 D0 DCNT C0 K43100 DCNT 32-bit counter (power-off retentive, count up) 《set value is constant K》《set value is register 》 DMOV K43100 D0 DCNT HC0 K43100 DCNT HC0 32-bit counter (common, count down) 《set value is constant K》《set value is register 》...
  • Page 49 counting value decreases to the minimum value K-2,147,483,648 will become K2,147,483,647, the ON/OFF state of the counter will also change with the change of the count value. MOV C0 D0 The above two instructions are equivalent. In the left instruction, C0 is processed as a register, while in the right instruction, CD0 is a data register corresponding to the timer C0.
  • Page 50 Note: For XD5 firmware version V3.4.6 and above, data register D ranges from D0 to D69999; XD5 firmware version below V3.4.6, and data register D ranges from D0 to D59999. Structure Data register is used to store data; it includes16 bits(the higheset bit is sign bit) and32 bits. (32 bits contains two registers, the highest bit is sign bit) 16 bits 16-bits register range is -32,768 ~ +32,767...
  • Page 51 When write a new value in the register, the former value will be covered. When PLC changes from RUN to STOP or STOP to RUN, the value in the register will be cleared.  Retentive type When PLC changes from RUN to STOP or power off, the value in the register will be retained.
  • Page 52 Data transfer When M0 is ON, transfer the value of D10 to D0 Read the timer and counter When M0 is ON, move the value of C10 to D0. As the set value of timer and counter When X0 is ON, T10 starts to work, T0 will set ON when TMR_A D0 value is equal to timer value, time unit is D2.
  • Page 53 Programming method two: (application of word consists of bits) 2-9-2 Offset application Application 1: When M0 is ON, the output from Y1 to Y7 will be ON one by one. D0 is offset address. If there are many output points, M can replace Y. MOV K7 D4000 Y0[D0] SM13...
  • Page 54 Application 2: When M0 is ON, read the ID10000 value every second and store in the register starting from D4000 (amounts is 50 registers). D0 is offset address. SM13 MOV ID10000 D4000[D0] 2-10 Flash register (FD, SFD, FS) The FLASH registers of XD/XL series PLC are all addressed in decimal system. The serial numbers are shown in the corresponding table.
  • Page 55 A part of the FlashROM register is used to store data soft components, which are represented by the symbol FS. The values in the FS register can be written but can not be read, so they can be used to protect the intellectual property rights of users. The value of the soft element can be set arbitrarily in the FS register, but the value of the register can not be read (always returned to 0);...
  • Page 56  BIN: BINARY NUMBER Inside the PLC, all the numbers will be processed in binary. But when monitoring on the device, all the binary will be transformed into HEX or DEC.  OCT: OCTAL NUMBER XD/XL series PLC I/O relays are in octal. Such as [X0-7, X10-17,….X70-77]. BCD: BINARY CODE DECIMAL ...
  • Page 57 Range External interruption Model Name Timer interruption Input Rising Falling interruption terminal interruption I0000 I0001 There are 20 timer I0100 I0101 interruptions. From XD/XL I40** to I59**. “**” I0200 I0201 series means the timeof timer I0300 I0301 16 points interruption, the unit is I0400 I0401 I0500...
  • Page 58 CALL If X0 is ON, jump to the subprogram If the coil is not ON, run the FEND original program; After executing the subprogram, return to the main program; SRET The subprogram will start from Pn and finish with SRET. CALL Pn is used to call the subprogram.
  • Page 59 to 1, 000/(20+20)=25Hz input pulse can’t be processed. But, this condition could be improved when use PLC’s special function and applied instructions (such as high speed count, input interruption, input filter adjustment).  Dual output(Dual coils)action Input process As shown in the left map, please X0=ON X1=OFF consider the case of using the same coil...
  • Page 60 3 Basic Program Instructions This chapter introduces the basic instructions and their functions. 3-1 Basic Instructions List XD, XL series support all the basic instructions: Chapt Mnemonic Function Format and Device Initial logical operation contact type NO (normally open) Read the status from the contact directly Initial logical operation contact type NC...
  • Page 61 contacts ORDI Read the normally closed contact directly Parallel connection of rising edge pulse Parallel connection of falling/trailing edge pulse Serial connection of multiply parallel circuits Parallel connection of multiply parallel circuits Final logic operation type coil drive OUTD Output to the contact directly Set a bit device 3-12...
  • Page 62 operation of the instruction Non-power-off holding 3-14 timer K100 TMR_A Power-off holding timer 3-14 TMR_A K100 Force the current 3-15 program scan to end GROUP Group 3-15 GROUP GROUPE Group End 3-16 GROUPE 3-2 [LD] , [LDI] , [OUT] Mnemonic and Function Mnemonic Function Format and Operands...
  • Page 63 Program Y100 Y100 M 1203 M1203 TM R T0 K10 K100 TMR T0 K10 K100 3-3 [AND] , [ANI] Mnemonic and Function Mnemonic Function Format and Operands Normal open (and) contactor in series Operand: X,Y,M,HM,SM,S,HS,T,HT,C,HC,Dn.m Normal close (and contactor in series reverse) Operand: X,Y,M,HM,SM,S,HS,T,HT,C,HC,Dn.m Statements...
  • Page 64 Program X2 M1 3-4 [OR] , [ORI] Mnemonic and Function Mnemonic Function Format and Operands Parallel connection (OR) of NO (Normally Open) contactors Operand: X,Y,M,HM,SM,S,HS,T,HT,C,HC,Dn.m Parallel connection of NC (Normally reverse) Closed) contactors Operand: X,Y,M,HM,SM,S,HS,T,HT,C,HC,Dn.m Statements Use the OR and ORI instructions for parallel connection of contactors. To connect a block ...
  • Page 65 Y6 M4 X7 M100 M100 Relationship with ANB The parallel connection with OR, ORI instructions should connect with LD, LDI instructions in principle. But behind the ANB instruction, it’s still ok to add a LD or LDI instruction. 3-5 [LDP] , [LDF] , [ANDP] , [ANDF] , [ORP] , [ORF] Mnemonic and Function Mnemonic Function...
  • Page 66 (AND Falling Falling/trailing edge pulse pulse) X,Y,M,HM,SM,S,HS,T,HT,C,HC,Dn.m Parallel connection of Rising edge (OR Pulse) pulse X,Y,M,HM,SM,S,HS,T,HT,C,HC,Dn.m Parallel connection of (OR Falling Falling/trailing edge pulse pulse) X,Y,M,HM,SM,S,HS,T,HT,C,HC,Dn.m Statements LDP, ANDP, ORP will be ON for one scanning period when the signal rising pulse is coming ...
  • Page 67 3-6 [LDD] , [LDDI] , [ANDD] , [ANDDI] , [ORD] , [ORDI] , [OUTD] Mnemonic and Function Mnemonic Function Format and Operands Read the status from the contact directly Devices: X LDDI Read the normally closed contact directly Devices: X ANDD Read the status from the contact directly...
  • Page 68 LDDI OUTD 3-7 [ORB] Mnemonic and Function Mnemonic Function Format and Devices Parallel connect the (OR Block) serial circuits Devices: none Statements Two or more contactors are called "serial block". If parallel connect the serial block, use LD, LDI at the branch start point, use ORB at the branch end point; As the ANB instruction, an ORB instruction is an independent instruction which is not associated with any soft component.
  • Page 69 3-8 [ANB] Mnemonic and Function Mnemonic Function Format and Devices Serial (And connection of Block) parallel Devices: none circuits Statements Use ANB to serial connects two parallel circuits. Use LD, LDI at the brach start point; use ANB at the branch end point. There are no limits for ANB instruction using times.
  • Page 70 Statements  After the execution of an MCS instruction, the bus line (LD, LDI) moves to a point after the MCS instruction. An MCR instruction resets this to the original bus line.  MCS, MCR instructions should use in pair. The bus line can be nesting.
  • Page 71 Statements The status of the coil is reversed after using ALT (ON changes to OFF, OFF changes to ON). Program M100 M100 3-11 [PLS] , [PLF] Mnemonic and Function Mnemonic Function Format and Devices Turn on a scan (Rising cycle when Pulse) Rising edge Operand:...
  • Page 72 ---------------------- 3-12 [SET], [RST] Mnemonic and Function Mnemonic Function Format and Devices Set a bit (Set) device permanently Operand: X,Y,M,HM,SM,S,HS,T,HT,C,HC,Dn.m Reset a bit (Reset) device permanently Operand: X,Y,M,HM,SM,S,HS,T,HT,C,HC,Dn.m Statements In the following program, Y0 will keep ON even X10 turns OFF after turning ON. Y0 will not ON even X11 turns OFF after turning ON.
  • Page 73 Program T250 TMR T250 K10 K10 T250 T250 3-13 [CNT],[CNT_D],[DCNT],[DCNT_D],[RST]for the counters Mnemonic and Function Mnemonic Function Format and devices 16 bits non power-off retentive Output increase count, the drive of count coil Operand: K, D CNT_D 16 bits power-off retentive CNT_D HC0 Output decrease count, the drive of...
  • Page 74 DCNT_D 32 bits power-off retentive DCNT_D HC0 Output decrease count, the drive of Operand: K, D count coil Reset the output coil, clear the Reset current count value Operand: C, HC, HSC Internal counter programming C0 increase counts the X11 OFF to ON times.
  • Page 75 3-14 [TMR], [TMR_A] for timers Mnemonic and Function Mnemonic Function Format and devices Non power-off retentive 100ms output timer, the drive of coil operand: K, D Non power-off retentive 10ms output timer, the drive of coil operand: K, D Non power-off retentive 1ms output timer, the drive of coil operand: K, D...
  • Page 76 3-15 [END] Mnemonic and Function Mnemonic Function Format and Devices:None Force the (END) current program scan Devices: None to end Statements PLC repeatedly carries on input disposal, program executing and output disposal. If write END instruction at the end of the program, then the instructions behind END instruction won’t be executed.
  • Page 77 3-16 [GROUP] , [GROUPE] Mnemonic and Function Mnemonic Function Format and Device GROUP GROUP Devices: None GROUPE GROUP END Devices: None Statements GROUP and GROUPE should use in pairs. GROUP and GROUPE don't have practical meaning; they are used to optimize the program structure.
  • Page 78 If carry on coil’s dual output (dual coil) in the sequencial control program, then the last action is prior. Dual output (dual coil) doesn’t go against the input rule. But as the preceding action is very complicate, please modify the program as in the following example. There are other methods.
  • Page 79 4 Applied Instructions In this chapter, we describe applied instruction’s function of XD, XL series PLC. 4-1 Applied Instructions List Mnemonic Function Ladder chart Chapter Program Flow Condition jump 4-3-1 CALL Call subroutine 4-3-2 CALL SRET Subroutine return 4-3-2 SRET Flow start 4-3-3 STL Sn...
  • Page 80 AND activates if(S1) AND< 4-4-2 AND< <(S2) AND activates if(S1) AND<> 4-4-2 AND<> ≠ (S2) AND activates if(S1) AND<= 4-4-2 AND<= ≤ (S2) AND activates if(S1) AND>= 4-4-2 AND= ≥ (S2) OR activates if(S1)= OR= 4-4-3 (S2) OR activates if(S1)> OR>...
  • Page 81 Increment 4-6-5 Decrement 4-6-5 MEAN Mean 4-6-6 MEAN WAND Word And 4-6-7 WAND Word OR 4-6-7 WXOR Word eXD3lusive OR 4-6-7 WXOR Compliment 4-6-8 Negative 4-6-9 Data Shift Arithmetic Shift Left 4-7-1 Arithmetic Shift Right 4-7-1 Logic shift left 4-7-2 Logic shift right 4-7-2 Rotation shift left...
  • Page 82 64 bits integer to QFLTD double precision 4-8-4 floating point Float point converts to 4-8-5 integer Double - precision DINTD floating point to32 4-8-6 bits integer Double - precision QINTD floating point to64 4-8-6 bits integer Single precision floating point to ECON 4-8-7 double precision...
  • Page 83 Float division EDIV 4-9-6 EDIV Float Square Root ESQR 4-9-7 ESQR Sine 4-9-8 Cosine 4-9-9 Tangent 4-9-10 Float Sine ASIN 4-9-11 ASIN Float Cosine ACOS 4-9-12 ACOS Float Tangent ATAN 4-9-13 ATAN Clock Operation Read RTC data 4-10-1 Write RTC data 4-10-2 Accurate clock BD 4-10-3...
  • Page 84 2)Operands Operands Function Data Type Specify the data or register address 16 bits/32 bits, BIN Specify the data or register address 16 bits/32 bits, BIN Specify the register to store the sum result 16 bits/32 bits, BIN 3)Suitable Soft Components Word soft elements Bit soft elements Operan...
  • Page 85 Related flag Flag Name Function ON: the calculate result is zero SM20 Zero OFF: the calculate result is not zero ON: the calculate result is over 32767(16bits) or 2147483647(32bits) SM21 Borrow OFF: the calculate result is not over 32767(16bits) or 2147483647(32bits) ON: the calculate result is over 32767(16bits) or 2147483647(32bits)
  • Page 86 4-3 Program Flow Instructions Mnemonic Instruction’s name Chapter Condition Jump 4-3-1 CALL Call subroutine 4-3-2 SRET Subroutine return 4-3-2 Flow start 4-3-3 STLE Flow end 4-3-3 Open the assigned flow, close the current flow (flow 4-3-3 jump) Open the assigned flow, not close the current flow 4-3-3 (Open the new flow) Start of a FOR-NEXT loop...
  • Page 87  In the left graph, Y0 becomes to be dual coil output, but when X0=OFF, X1 activates; when X0=ON, X5 activates T246  CJ can’t jump from one STL to another STL; TMR T246 K1000 K10  After driving timer T0~T575, HT0~HT795 and HSC0~HSC30, if executes CJ, continue working, the...
  • Page 88 CALL FEND SRET If X0= ON, execute the call instruction and jump to P10. After executing the subroutine,  return the original step via SRET instruction. Program the tag with FEND instruction (will describe this instruction later)  In the subroutine 9 times call is allowed, so totally there can be 10 nestings. ...
  • Page 89 If X0=ON, the program executes as the arrow. If X0=OFF, the CALL instruction will not work; only the main program works. The notes to write the subprogram: Please programming the tag after FEND. Pn is the start of subprogram; SRET is the end of subprogram.
  • Page 90 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M,HM,SM;S includes S,HS;T includes T,HT;C includes C, HC. Description STL and STLE should be used in pairs. STL represents the start of a flow; STLE represents ...
  • Page 91 After executing SET S1, close S0, open S1. After executing ST S2, open S2, not close S0. Example Example 1: the flows run in branch then merge in one flow. Program diagram:...
  • Page 92 The program explanation: When SM2 is ON, set ON flow S0. When M0 is ON, set ON flow S10 and S20. In S10 branch, it runs S10, S11 and S12. Set on M1 means the S10 branch is finished. In S20 branch, it runs S20, S21 and S22. Set on M2 means the S20 branch is finished.
  • Page 93 Example 2: flow nesting. When S0 is running for a while, S1 and S2 start to run; the running status of S1 is kept. When S0 is running for certain time, closes S0 and force close S1 and S2.
  • Page 94 4-3-4 [FOR] and [NEXT] 1)Summary Loop execute the program between FOR and NEXT with the specified times; Loop starts [FOR] 16 bits 32 bits Execution Rising/Falling edge Suitable Models XD, XL condition Hardware Software requirement requirement Loop ends [NEXT] 16 bits NEXT 32 bits Execution...
  • Page 95 Between FOR~NEXT, CJ nesting is not allowed. FOR~NEXT must be in pairs in one STL. Example 1: when M0 is ON, the FOR NEXT starts to sort the numbers in the range of D1 to D20 from small to large. D21 is offset value. If there are many sortings in the program, please use C language to save the programming time and scanning time.
  • Page 96 D1[D21] D2[D21] //exchange the two neighbouring data //M8000 is always ON coil //increase one for D21 NEXT //match the second FOR NEXT //match the first FOR 4-3-5 [FEND] and [END] 1)Summary FEND means the main program ends, while END means program ends; main program ends [FEND] Execution Suitable Models...
  • Page 97 If program the tag of CALL instruction behind FEND instruction, there must be SRET instruction. If the interrupt pointer program behind FEND instruction, there must be IRET instruction. After executing CALL instruction and before executing SRET instruction, if execute FEND instruction;...
  • Page 98 4-4 Data compare function Mnemonic Function Chapter LD= LD activates when (S1)= (S2) 4-4-1 LD> LD activates when (S1)> (S2) 4-4-1 LD< LD activates when (S1)< (S2) 4-4-1 LD activates when (S1)≠ (S2) LD<> 4-4-1 LD activates when (S1)≤ (S2) LD<=...
  • Page 99 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M,HM,SM;S includes S,HS;T includes T,HT;C includes C, HC. Description 16 bits instruction 32 bits Activate Condition Not Activate Condition instruction (S1)≠...
  • Page 100 Operands Function Data Type Being compared number address 16/32bit, BIN Comparand address 16/32bit, BIN 3)Suitable soft components Operan Word soft elements Bit soft elements System Consta Module System X Y M S T C Dn. ● ● ● ● ● ●...
  • Page 101 The comparison of32 bits counter should use32 bits instruction. If using16 bits instruction, the program or operation will be error. 4-4-3 Parallel Compare [OR] 1)Summary OR: parallel connection comparison instruction. Parallel Compare [OR] 16 bits As below 32 bits As below Execution Suitable Models XD, XL...
  • Page 102 S1· S2· K100 OR= K68899 DOR> Note Items When the source data’s highest bit (16 bits: b15,32 bits: b31) is 1, it is seemed to negative  number. The comparison of32 bits counter should use32 bits instruction. If using16 bits instruction, ...
  • Page 103 4-5 Data Move Instructions Mnemonic Function Chapter Data compare 4-5-1 Data zone compare 4-5-2 Move 4-5-3 BMOV Data block move 4-5-4 PMOV Data block move (with faster speed) 4-5-5 FMOV Fill move 4-5-6 EMOV Float number move 4-5-7 FWRT FlashROM written 4-5-8 MSET Zone set...
  • Page 104 ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M,HM,SM;S includes S,HS;T includes T,HT;C includes C, HC. Description S· S1· D10 > D20 D10 = D20 D10 <...
  • Page 105 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M,HM,SM;S includes S,HS;T includes T,HT;C includes C, HC.
  • Page 106 2) Operands Operands Function Data Type Specify the source data or register’s address 16 bits/32 bits/64 bits, BIN code Specify the target soft component’s address 16 bits/32 bits/64 bits, BIN code 3) Suitable soft component Operan Word soft elements Bit soft elements System Consta Module...
  • Page 107 <read the counter or timer current value> (The current value of T0)→(D20) The same as counter <indirect set the timer value> (K10) (D20) D20=K10 D20=K10 4-5-4 Data block Move [BMOV] 1) Summary Move the data block to other soft component Data block move [BMOV] 16 bits BMOV...
  • Page 108 Move the source data block to the target data block. The data quantity is n. <word move> S· D· BMOV <bit move> S· D· BMOV As shown in the figure below, when the transmission number range overlaps, in order to prevent the transmission source data from being overwritten without transmission, according to the method of number overlap, this instruction will be carried out in the order of ①...
  • Page 109 4-5-5 Data block Move [PMOV] 1)Summary Move the specified data block to the other soft components Data block mov[PMOV] 16 bits PMOV 32 bits Execution Normally ON/OFF coil, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement 2) Operands Operands Function Data Type...
  • Page 110 4-5-6 Fill Move [FMOV, DFMOV] 1) Summary Move the specified data to the other soft components Fill Move [FMOV, DFMOV] 16 bits FMOV 32 bits DFMOV Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement 2) Operands Operands Function...
  • Page 111 Move D0.D1 to D10.D11:D12.D13:D14.D15.  <16 bits data transfer > <32 bits data transfer > D0、D1 4-5-7 Floating move [EMOV, EDMOV] 1)Summary Move the float number to target address Floating move [EMOV, EDMOV] 16 bits 32 bits EMOV Execution Normally ON/OFF, Suitable Models XD, XL condition...
  • Page 112 Execution Normal ON/OFF/falling or Suitable Models XDH, XLH condition rising pulse edge Hardware Version V3.7.1 or later Software Version V3.7.4a or requirement requirement later 2)Operands Operand Function Type Source soft element address 32 /64bits, BIN Destination soft element address 32 /64bits, BIN 3)Suitable soft element Word soft elements Bit soft elements...
  • Page 113 (K500)→(D13,D12,D11,D10) If constant value K, H is source soft element, they will be converted to floating number.  K500 will be converted to floating value.  The addresses of operands in EDMOV instructions must be even.  4-5-8 FlashROM Write [FWRT, DFWRT, QFWRT] 1) Summary Write the specified data to FlashROM register.
  • Page 114 < Written of single word > S· D· Write value from D0 to FD0 FWRT <Written of double words> S· D· Write value from D0,D1 to FD0,FD1 DFWRT <Written of four words> Write value from D0,D1,D2,D3to FD0,FD1,FD2,FD3. <Written of multi-word> S·...
  • Page 115 2)Operands Operands Function Data Type Start soft element address End soft element address 3) Suitable soft components Operan Word soft elements Bit soft elements System Consta Module System X Y M S T C Dn. ● ● ● ● ● ● ●...
  • Page 116 Operan Word soft elements Bit soft elements System Consta Module System X Y M S T C Dn. ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM;...
  • Page 117 3) Suitable soft components Word soft elements Bit soft elements Operan System Consta Module System X Y M S T C Dn. ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM;...
  • Page 118 3) Suitable soft component Word soft elements Bit soft elements Operands System Consta Module System X Y M S T C ● ● ● ● ● ● ● ● ● ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM;...
  • Page 119 4-6 Data Operation Instructions Mnemonic Function Chapter Addition 4-6-1 Subtraction 4-6-2 Multiplication 4-6-3 Division 4-6-4 Increment 4-6-5 Decrement 4-6-5 MEAN Mean 4-6-6 WAND Logic Word And 4-6-7 Logic Word Or 4-6-7 WXOR Logic Exclusive Or 4-6-7 Compliment 4-6-8 Negation 4-6-9 4-6-1 Addition [ADD, DADD, QADD] 1) Summary Add two numbers and store the result...
  • Page 120 3) Suitable soft components Word soft elements Bit soft elements Operan System Consta Module System X Y M S T C Dn. Three operands ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●...
  • Page 121 The source and target address can be the same. In the above example, when X0 is ON, the  instruction will be executed in every scanning period. <Two operands> D· S1· (D10)+ (D12) → (D10) Two source data do binary addition and send the result to addend data address. Each data’s ...
  • Page 122 4-6-2 Subtraction [SUB] 1) Summary Two numbers do subtraction, store the result Subtraction [SUB, DSUB, QSUB] 16 bits 32 bits DSUB Execution Normally ON/OFF/rising or Suitable XD, XL condition falling pulse edge Models Hardware Software requirement requirement 64 bits QSUB Execution Normal ON/OFF/falling or Suitable Models...
  • Page 123 S1· S2· D· (D10) — (D12) → (D14)  S1 appoint the soft unit’s content, subtract the soft unit’s content appointed by S2 algebraically. The result will be stored in the soft unit appointed by D.  The action of each flag, the setting method of 32/64 bits operation’s soft units are both the same with the preceding ADD instruction.
  • Page 124 Execution Normally ON/OFF / pulse Suitable XD, XL condition edge Models Hardware Software requirement requirement 64 bits QMUL Execution Normal ON/OFF/falling or Suitable Models XDH, XLH condition rising pulse edge Hardware Version V3.7.1 or later Software Version V3.7.4a or requirement requirement later 2) Operands...
  • Page 125 <32 bits Operation > S1· S2· D· (D1, D0) × (D3, D2) → (D7, D6, D5, D4) DMUL 32 bits 32 bits → 64 bits  When use32 bits operation, the result is stored at the destination device in the format of64 bits.
  • Page 126 3)Suitable soft components Operan Word soft elements Bit soft elements System Consta Modul System X Y M S T C Dn. ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●...
  • Page 127 If the value of the divisor is 0, the instruction will be error.   The highest bit of the result and remainder is the symbol bit (positive:0, negative: 1). When any of the dividend or the divisor is negative, then the result will be negative. When the dividend is negative, then the remainder will be negative.
  • Page 128 64 bits QDEC Execution Normal ON/OFF/falling or Suitable XDH, XLH condition rising pulse edge Models Hardware Version V3.7.1 or later Software Version V3.7.4a or later requirement requirement 2) Operands Operands Function Data Type The increase or decrease data address 16 bits / 32 bits/64 bits,BIN 3) Suitable soft components Operan Word soft elements...
  • Page 129 Note: When the edge instruction is triggered, the automatic addition and subtraction operation is performed for each trigger. If it is triggered by normally open/normally closed, the operation of auto-addition and auto-subtraction will be performed in each scanning period after the conduction. 4-6-6 Mean [MEAN, DMEAN] 1)Summary Get the mean value of data...
  • Page 130 4-6-7 Logic AND [WAND, DWAND], Logic OR[WOR, DWOR], Logic Exclusive OR [WXOR, DWXOR] 1)Summary Do logic AND, OR, XOR for data Logic AND [WAND, DWAND] 16 bits WAND 32 bits DWAND Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software...
  • Page 131 S1· S2· D· 0&0=0 0&1=0 WAND 1&0=0 1&1=1 <Logic OR > S1· S2· D· 0 or 0=0 0 or 1=1 1 or 0=1 1 or 1=1 < Logic WXOR > S1· S2· D· 0 xor 0=0 0 xor 1=1 WXOR 1 xor 0=1 1 xor 1=0 If use this instruction along with CML instruction, XOR NOT operation could also be executed.
  • Page 132 4-6-8 Logic converse [CML, DCML] 1) Summary Logic converse the data Converse [CML,DCML] 16 bits 32 bits DCML Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement 2)Operands Operands Function Data Type Source data address 16 bits/32 bits, BIN Result address 16 bits/32 bits, BIN...
  • Page 133 M8000 The sequential control instruction in the left could be denoted by the following CML  instruction. 4-6-9 Negative [NEG, DNEG] 1) Summary Get the negative data Negative [NEG,DNEG] 16 bits 32 bits DNEG Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models...
  • Page 134 data address.  For example, the source data D10 is 20, when M0 rising edge is coming, D10 become -20. The following two instructions are the same. SUB K0 D10 D10 4-7 Shift Instructions Mnemonic Function Chapter Arithmetic shift left 4-7-1 Arithmetic shift right 4-7-1...
  • Page 135 3) Suitable soft components Operan Word soft elements Bit soft elements System Consta Modul System X Y M S T C Dn. ● ● ● ● ● ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM;...
  • Page 136 4-7-2 Logic shift left [LSL], Logic shift right [LSR] 1) Summary Do logic shift right/left for the data Logic shift left [LSL, DLSL] 16 bits 32 bits DLSL Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement Logic shift right [LSR,DLSR]...
  • Page 137 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M,HM,SM;S includes S,HS;T includes T,HT;C includes C, HC. Description After executing LSL once, the lowest bit is filled with 0; the last bit is stored in carry flag. ...
  • Page 138 Hardware Software requirement requirement 2) Operands Operands Function Data Type Source data address 16 bits/32 bits, BIN Shift right or left times 16 bits/32 bits, BIN 3)Suitable soft components Operan Word soft elements Bit soft elements System Consta Modul System X Y M S T C Dn.
  • Page 139 4-7-4 Bit shift left [SFTL] 1) Summary Bit shift left Bit shift left [SFTL] 16 bits SFTL 32 bits Execution rising/falling edge Suitable XD, XL condition Models Hardware Software requirement requirement 2) Operands Operands Function Types Source soft element head address Target soft element head address Source data quantity(no more than 1024) 16 bits, BIN...
  • Page 140 X 3~X 0→M3~M0 M 3~M 0→M7~M4 M 7~M 4→M11~M8 M11~M 8→M15~M 12 M15~M12→Overflow ⑤ 4-7-5 Bit shift right [SFTR] 1) Summary Bit shift right Bit shift right [SFTR] 16 bits SFTR 32 bits Execution rising/falling edge Suitable XD, XL condition Models Hardware Software...
  • Page 141 Description  Move n2 bits right for the object which contains n1 bits.  When X0 changes from OFF to ON, the instruction will move n2 bits for the object.  For example, if n2 is 1, the object will move 1 bit right when the instruction executes once. ①...
  • Page 142 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M, HM, SM; S includes S, HS; T includes T, HT; C includes C, HC. Description ...
  • Page 143 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M, HM, SM; S includes S, HS; T includes T, HT; C includes C, HC. Description Move n2 words right for the object which contains n1 words.
  • Page 144 ASCI Hex. converts to ASCII 4-8-11 ASCII converts to Hex 4-8-12 DECO Coding 4-8-13 ENCO High bit coding 4-8-14 ENCOL Low bit coding 4-8-15 Binary converts to gray code 4-8-16 GBIN Gray code converts to binary 4-8-17 4-8-1 Single word integer converts to double word integer [WTD.DWTD] 1) Summary Single word integer converts to double word integer [WTD.DWTD] 16 bits...
  • Page 145 <16 bits instruction> S· D· (D0) → (D11, D10) Single Word Double Word When single word D0 is positive integer, after executing this instruction, the high bit of  double word D10 is 0. When single word D0 is negative integer, after executing this instruction, the high bit of ...
  • Page 146 2) Operands Operands Function Data Type Specify the source data or register’s address 32 bits ,BIN code Specify the target soft component’s address 64 bits ,BIN code Specify the value of the transfer point 16 bits ,BIN 3) Suitable soft components Operan Word soft elements Bit soft elements...
  • Page 147 4-8-3 Integer converts to float point [FLT, DFLT,FLTD] 1)Summary bit integer converts to float point [FLT, DFLT,FLTD] 16 bits 32 bits DFLT 64 bits FLTD Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement 2) Operands Operands Function Data Type...
  • Page 148 The inverse transformation instruction is INT.  FLTD can change the64 bits integer to32 bits floating value.  The S operand of the FLTD instruction does not support constant K/H.  FLT D0 D10 D0 is integer 20, after executing the instruction, D10 is floating value 20. Note: Before using floating number operation instructions such as EADD, ESUB, EMUL, EDIV, EMOV and ECMP, make sure that all operation parameters are floating number.
  • Page 149 <64 bits instruction> (D13,D12,D11,D10)→(D17,D16,D15,D14) BIN integer Binary float point An instruction to convert binary integer values to binary floating-point values. Constants  K and H are automatically converted in each floating-point operation instruction, and FLT instruction can not be used. The inverse transformation of this instruction is DINTD/QINTD.
  • Page 150 <16 bits instruction> (D11,D10) → (D20) S· D· Binary Float BIN integer Give up the data after the decimal dot <32 bits instruction> (D11,D10) → (D20,D21) S· D· DINT Binary Float BIN integer Give up the data after the decimal dot The binary source number is converted into a BIN integer and stored at the destination device.
  • Page 151 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M, HM, SM; S includes S, HS; T includes T, HT; C includes C, HC. Description <32 bits instruction>...
  • Page 152 D FD TD CD DX DY DM DS ID QD X Y M S T C Dn.m ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M, HM, SM; S includes S, HS; T includes T, HT;...
  • Page 153 ● ● ● ● ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M, HM, SM; S includes S, HS; T includes T, HT;...
  • Page 154 3) Suitable soft components Operands Word soft elements Bit soft elements System Constant Module System D FD TD CD DX DY DM DS ID QD X Y M S T C Dn.m ● ● ● ● ● ● ● ● ●...
  • Page 155 4-8-10 Binary convert to BCD [BCD] 1) Summary Convert binary data to BCD code Binary convert to BCD [BCD] 16 bits 32 bits Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement 2) Operands Operands Function Data Type Source soft element address...
  • Page 156 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M, HM, SM; S includes S, HS; T includes T, HT; C includes C, HC. Description S·...
  • Page 157 2) Operands Operands Function Data Type Source soft element address 2 bits, HEX Target soft element address ASCII code Transform character quantity 16 bits, BIN 3)Suitable soft components Operands Word soft elements Bit soft elements System Constant Module System D FD TD CD DX DY DM DS ID QD X Y M S T C Dn.m ●...
  • Page 158 4-8-12 ASCII convert to Hex [HEX] 1)Summary ASCII converts to Hex [HEX] 16 bits 32 bits Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement 2) Operands Operands Function Date type Source soft element address ASCII Target soft element address 2 bits, HEX...
  • Page 159 · D102 D101 D100 (S·) ASCII code convert ···0H D200 low Not change to be ··0AH D200 high ·0ABH D201 low 0ABCH D201 high ···0H ABC1H D202 low ··0AH BC12H D202 high D203 low ·0ABH C123H D203 high 0ABCH 1234H D204 low ···0H 2345H...
  • Page 160 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M, HM, SM; S includes S, HS; T includes T, HT; C includes C, HC. Description <...
  • Page 161 executed. N = 3, so the decoding object in D0 is bit2-bit0, and the maximum value it represents is 4 + 2  + 1 = 7. N = 3, so in D1, 2 = 8 bits are needed to represent the decoding result, that is, bit7 ~ bit0. ...
  • Page 162 3) Suitable soft components Operan Word soft elements Bit soft elements System Constant Module System X Y M S T C Dn.m ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●...
  • Page 163 Ignore the 1 of bit 2 If multiple bits in the source address is 1, the low side is ignored, and if the source address is  0, the instruction will not be executed. When the driver input is OFF, the instruction is not executed and the coding output is ...
  • Page 164 Low bit coding [ENCOL] 16 bits ENCOL 32 bits Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement 2) Operands Operands Function Data Type Soft element address need coding 16bit,BIN Soft element address to save coding result 16bit,BIN The bit quantity of coding result 16bit,BIN...
  • Page 165 unchanged. When n = 16, if the of encoding instruction is a bit element, its point is 2 ^ 16 = 65536.  S· n = 3, the encoded object has 2 = 8 bits, which are M17 ~ M10, and the encoding results are ...
  • Page 166 If multiple bits in the source address is 1, the high bit side is ignored, and if the source  address is 0, the instruction will not be executed. When the driver input is OFF, the instruction is not executed and the coding output is ...
  • Page 167 Each bit of D10 will XOR with the bit on its left side. As the related gray code, the left bit will not change (the left bit is 0); the transformation result is stored in D100. D100 Transform the binary value to gray code. ...
  • Page 168 S· D· Source (GRY) → target (BIN) GBIN D100 From the left second bit of D10, XOR each bit with the value after decoding, as the bit value after decoding (the left bit will not change). The transformation value will be stored in D100 D100.
  • Page 169 2) Operands Operands Function Data Type Soft element address need compare 32/64 bits, BIN Soft element address need compare 32/64 bits, BIN Compare result 3) Suitable soft components Word soft elements Bit soft elements Operands System Constant Module System ID Q X Y M S T C Dn.m ●...
  • Page 170 (K500) :(D101, D100) →M10,M11,M12 Binary converts Binary floating ECMP K500 D100 to floating <64 bits operation> (K500) :(D103,D102,D101,D100)→ M10,M11,M12 Binary converts Binary floating to floating 4-9-2 Floating Zone Compare [EZCP] 1) Summary Floating Zone Compare [EZCP] 16 bits 32 bits EZCP Execution Normally ON/OFF,...
  • Page 171 Description Compare the source data with the range S1· S2· S3· D· EZCP (D1, D0) < (D11, D10) Binary Floating Binary Floating (D11, D10) ≤ (D1, D0 ) ≤ (D21, D20) ON Binary Floating Binary Floating Binary Floating (D1, D0) >...
  • Page 172 Operands Function Data Type Addition operation data address 32/64 bits, BIN Addition operation data address 32/64 bits, BIN Result address 32/64 bits, BIN 3) Suitable soft components Word soft elements Bit soft elements Operands System Constant Module System X Y M S T C Dn.m ●...
  • Page 173 <64 bits operation> (K1234) ( D103, D102, D101, D100) →(D113, D112, D111, D110) Binary converts Binary Floating Binary Floating to Floating The source data and result address can be the same. Please note that when X0 is ON, the  instruction will be executed in every scanning period.
  • Page 174 Description <32 bits operation> S1· S2· D· ESUB (D11,D10) - (D21,D20) → (D51,D50) Binary Floating Binary Floating Binary Floating <64 bits operation> (D13, D12,D11, D10)-(D23,D22,D21,D20) →(D53, D52,D51, D50) Binary Floating Binary Floating Binary Floating The binary floating value S1 subtract S2, the result is stored in the target address. ...
  • Page 175 4-9-5 Floating Multiplication[EMUL,EDMUL] 1)Summary Floating Multiply [EMUL, EDMUL] 16 bits 32 bits EMUL Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement 64 bits EDMUL Execution Normal ON/OFF/falling Suitable XDH, XLH condition or rising pulse edge Models Hardware Version V3.7.1 or later...
  • Page 176 <64 bits operation> (D13, D12,D11, D10)×(D23, D22,D21, D20)→(D53, D52,D51, D50) Binary Floating Binary Floating Binary Floating The floating value of S1 is multiplied with the floating value point value of S2. The result of  the multiplication is stored at D as a floating value. If a constant K or H used as source data, the value is converted to floating point before the ...
  • Page 177 Hardware Version V3.7.1 or later Software Version V3.7.4a or later requirement requirement 2) Operands Operands Function Data Type Division operation data address 32/64 bits, BIN Division operation data address 32/64 bits, BIN Result address 32/64 bits, BIN 3) Suitable soft components Word soft elements Bit soft elements Operands...
  • Page 178 <32 bits operation> EDIV D100 K100 D110 (D101, D100)÷ (K100) → (D111, D110) Binary converts Binary Floating Binary Floating to Floating <64 bits operation> (D103, D102,D101, D100)÷(K100)→(D113, D112,D111, D110) Binary converts Binary Floating Binary Floating 4-9-7 Float Square Root [ESQR] to Floating 1) Summary Floating Square Root [ESQR]...
  • Page 179 S· D· (D11,D10) → (D21,D20) ESQR Binary FloatingBinary Floating A square root is performed on the floating point value S; the result is stored in D.  If a constant K or H used as source data, the value is converted to floating point before the ...
  • Page 180 S· D· (D51,D50) → (D61,D60)SIN Binary Floating Binary Floating This instruction performs the mathematical SIN operation on the floating point value in S  (angle RAD). The result is stored in D. RAD value (angle×π/180) S· Assign the binary floating value SIN value D·...
  • Page 181 Description S· D· (D51,D50)RAD → (D61,D60)COS Binary Floating Binary Floating This instruction performs the mathematical COS operation on the floating point value in S  (angle RAD). The result is stored in D. RAD value (angle×π/180) S· Assign the binary floating value COS value Binary Floating D·...
  • Page 182 Description (D51,D50) RAD → (D61,D60) TAN S· D· Binary Floating Binary Floating This instruction performs the mathematical TAN operation on the floating point value in S.  The result is stored in D. S· RAD value (angle×π/180) Assign the binary floating value TAN value D·...
  • Page 183 Description (D51,D50)ASIN → (D61,D60)RAD S· D· Binary Floating Binary Floating ASIN This instruction performs the mathematical ASIN operation on the floating point value in S. The result is stored in D. ASIN value S· Binary Floating RAD value (angle×π/180) Assign the binary floating D·...
  • Page 184 Description S· D· (D51,D50)ACOS → (D61,D60)RAD ACOS Binary Floating Binary Floating Calculate the arcos value(radian), save the result in the target address S· ACOS value Binary Floating RAD value (angle×π/180) Assign the binary floating value D· Note: Before the instruction is executed, the data in parameter S must be floating number; otherwise, the execution result will be wrong.
  • Page 185 Description S· D· (D51,D50)ATAN → (D61,D60)RAD ATAN Binary Floating Binary Floating Calculate the arctan value ( radian), save the result in the target address ATAN value S· Binary Floating RAD value (angle×π/180) Assign the binary floating D· value Note: Before the instruction is executed, the data in parameter S must be floating number; otherwise, the execution result will be wrong.
  • Page 186 4-10-1 Read the clock data [TRD] 1) Summary Read the clock data: Read the clock data: [TRD] 16 bits 32 bits Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Software requirement requirement 2) Operands Operands Function Data Type Register address to save clock data 16 bits, BIN 3) Suitable Soft Components...
  • Page 187 After reading the RTC by TRD instruction, the value will show in decimal format.  After reading the RTC by TRD, the value becomes decimal value.  after executing TRD instruction, D0 to D6 are occupied.  4-10-2 Write Clock Data [TWR] 1) Summary Write the clock data: Write clock data [TWR]...
  • Page 188 Unit Item Clock data Unit Item Year 0-99 SD018 Year Month 1-12 SD017 Month Date 1-31 SD016 Date Hour 0-23 SD015 Hour Minute 0-59 SD014 Minute Second 0-59 SD013 Second Week 0 (Sun.)-6 (Sat.) SD019 Week After executing TWR instruction, the time in real time clock will immediately change to be the new time.
  • Page 189 4-10-3 Accurate clock BD board data read [MOV] 1) Summary Accurate clock BD board data read [MOV] 16 bits 32 bits Execution Normally ON/OFF, Suitable XD, XL condition rising/falling edge Models Hardware Version V3.4.6 (or V3.5.3a) Software Version V3.5.3 or later requirement or later requirement...
  • Page 190 and week, it is not recommended to use BMOV or PMOV commands to read the clock data in batches if the read clock data is used for comparison and calculation. 4-10-4 Accurate clock BD board data write [TO] 1) Summary Accurate clock BD board data write [TO] 16 bits 32 bits...
  • Page 191 Source #1 BD board Description Clock Data Remark data address ID20000(K0) Second 0~59 Decimal → ID20001(K1) Minute 0~59 Decimal ID20002(K2) Hour 0~23 Decimal → ID20003(K3) Date 1~31 Decimal ID20004(K4) Month 1~12 Decimal → ID20005(K5) Year 00~99 Decimal ID20006(K6) Week Decimal →...
  • Page 192 Note: Module number K20000 stands for #1 BD, K20001 stands for #2 BD; Module addresses are numbered from K0, corresponding to ID20000, ID20001..ID20006. 4-10-5 Clock data add [TADD] 1) Summary Clock data add [TADD] 16 bits TADD 32 bits Execution Normally ON/OFF, Suitable...
  • Page 193 Note: the correspondence of registers is fixed, that is, they are stored in order of hours, minutes and seconds. If the operation result is 0 hour, 0 minute, 0 second, SM20 will be set ON. The operands S1, S2, and D each occupy three registers. Do not use them for other purposes. Example 1: <General condition>...
  • Page 194 2) Operands Operands Function Data Type Soft element header address of the clock data 16 bits, BIN (hour, minute, second) Soft element header address of the clock data 16 bits, BIN (hour, minute, second) The result address 16 bits, BIN 3) Suitable soft components Word soft elements Bit soft elements...
  • Page 195 Example 3: 《Less than 0 minutes》 Example 4: 《Less than 0 hours》 4-10-7 Convert hour, minute, and second data to seconds [HTOS] 1) Summary Convert hour, minute, and second data to seconds [HTOS] 16 bits HTOS 32 bits Execution Normally ON/OFF, Suitable XD, XL condition...
  • Page 196 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M, HM, SM; S includes S, HS; T includes T, HT; C includes C, HC. Description (HD,HD1,HD2)→(HD10,HD11) Hour, minute ,second →...
  • Page 197 (HD0, HD1)→(HD10,HD11,HD12) second → hour,minute,second When the M0 switches on, it converts clock data (hours, minutes and seconds) in three  consecutive registers led by HD0 into second data, which is stored in register HD10 (double word). Note: the correspondence of registers is fixed, that is, they are stored in order of hours, ...
  • Page 198 Description M100 from OFF to ON, TCMP worked. Compare the three registers starting from S4 to three  registers S1, S2, S3 (year, month, day). When S1, S2, S3 is larger than S4 clock, M0 is ON. When S1, S2, S3 is equal to S4 clock, M1 is ON. When S1, S2, S3 is smaller than S4 clock, M2 is ON.
  • Page 199 2) Operands Operands Function Model Soft component address for years 16 bits, BIN Soft component address for months 16 bits, BIN Soft component address for days 16 bits, BIN PLC real time clock information first address 16 bits, BIN The compare result first address 3) Suitable soft component Operands Word soft elements...
  • Page 200 For example The present clock is 15:32:49 7,30,2014 Wednesday. So D30=14, D31=7, D32=30. If the setting time is 1,6,2015, D20=15, D21=1, D22=6, Then Y0=ON.If the setting time is 7,30,2014, D20=14, D21=7, D22=31, then Y1=ON. If the setting time is 6,31,2014, D20=14, D21=6, D22=31, then Y2=ON.
  • Page 201 5 HIGH SPEED COUNTER (HSC) This chapter will introduce high speed counter’s functions, including high speed count model, wiring method, read/write HSC value, reset etc. Instructions List for HSC Instruction Function Instruction Chapter name HSC read/write No 24-segments single 5-7-1 phase CNT_AB No 24-segments AB phase...
  • Page 202 Count input Rotary encoder Sensor (2) The high-speed counting input of XD5-48D4T4 can receive differential signal (DIFF), please be sure to choose differential signal (DIFF) encoder. (3) When the counting frequency is higher than 25Hz, please select a high-speed counter. 5-2 HSC Mode XD, XLseries high speed counter has two working mode: Single-phase increasing mode and AB phase mode.
  • Page 203 AB Phase Mode Under this mode, the HSC value increase or decrease according to two differential signal (A phase and B phase). According to the multiplication, we have 2-time frequency and 4-time frequency, but the default count mode is 4-time frequency mode. 2-time frequency and 4-time frequency modes are shown below: 2-time Frequency 4-time Frequency...
  • Page 204 A phase input B phase input Counter current value 5-3 HSC Range HSC’s count range is: K-2,147,483,648 ~ K+2,147,483,647. If the count value overflows this range, then overflow or underflow appears; Overflow means the count value jumps from K+2,147,483,647 to K-2,147,483,648, then continue counting;...
  • Page 205 5-5 HSC ports assignment 1)XD series PLC HSC channels list: HSC channel PLC model Increasing AB phase mode mode 16/32 XD2/XD3 16/24/32/42/48/60 16/24/32/42/48/60 24T4/32T4/48T4/60T4 24D2T2 48D4T4 48T6/60T6 60T10 24T4/32T4/48T4/60T4 60T10 24/32/48/60 XD5E 24/30/48/60 30T4 60T4 60T6 60T10 XDME 30T4/60T4 60T10...
  • Page 206 X can use as normal input terminals when there are no high speed pulses input. In the following table, 2 means double frequency; 4 means quadruple frequency; 2/4 means that double frequency and quadruple frequency can be adjusted. XD2-16 Increasing mode AB phase mode HSC0 HSC2 HSC4 HSC6 HSC8 HSC10 HSC12 HSC0 HSC2...
  • Page 207 X007 X010 XD5-24T4/32T4/48T4/60T4, XDM-24T4/32T4/60T4/60T4L, XDC-24/32/48/60T XD5E-30T4/60T4, XDME-30T4/60T4, XL5-32T4, XL5E-32T4, XLME-32T4, XLH- 24A16/24A16L Increasing mode AB phase mode HSC0 HSC2 HSC4 HSC6 HSC8 HSC10 HSC0 HSC2 HSC4 HSC6 HSC8 HSC10 frequency Quadruple frequency Counter √ √ √ √ √ √ √ √...
  • Page 208 XD5-48D4T4 Increasing mode AB phase mode HSC0HSC2HSC4HSC6HSC8HSC10HSC12HSC14HSC0HSC2HSC4HSC6HSC8HSC10HSC12HSC14 XDH-30A16/30A16L/60T4/60A32 Increasing mode AB phase mode HSC0 HSC2 HSC4 HSC6 HSC8 HSC10 HSC0 HSC2 HSC4 HSC6 HSC8 HSC10 200K 200K 200K 100K 100K 100K 100K 200K frequency Quadruple frequency Counter √ √ √ √...
  • Page 209 XD5-48T6/60T6, XD5E-60T6, XL5E-64T6 Increasing mode AB phase mode HSC0 HSC2 HSC4 HSC6 HSC8 HSC10 HSC0 HSC2 HSC4 HSC6 HSC8 HSC10 Max frequency 80K Quadruple frequency Counter √ √ √ √ √ √ √ √ √ √ √ √ interruption X000 X001 X002 X003...
  • Page 210 X030 X031 X032 X033 X034 XD5-60T10, XDM-60T10, XD5E-60T10, XDME-60T10, XL5E-64T10, XLME-64T10 AB phase mode HSC0 HSC2 HSC4 HSC6 HSC8 HSC10 HSC12 HSC14 HSC16 HSC18 HSC20 HSC22 Max frequency 50K Quadruple frequency Counter √ √ √ √ √ √ √ √ √...
  • Page 211 doubling 4 frequency doubling 2 frequency doubling HSC4 frequency SFD322 doubling 4 frequency doubling 2 frequency doubling HSC6 frequency SFD323 doubling 4 frequency doubling HSC8 frequency 2 frequency doubling SFD324 doubling 4 frequency doubling 2 frequency doubling HSC10 frequency SFD325 doubling 4 frequency doubling 2 frequency doubling...
  • Page 212 3)Suitable Soft Components Operands Word soft elements Bit soft elements System Constant Module System Dn.m Only can be HSC ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M,HM,SM;S includes S,HS; T includes T,HT;C includes C, HC.
  • Page 213 requirement requirement 2)Operands Operands Function Type Specify HSC code (Eg. HSC0) 32 bits, BIN Specify the comparison value (Eg. K100, D0) 32 bits, BIN 3)Suitable Soft Components Operands Word soft elements Bit soft elements System Constant Module System Dn.m Only can be HSC ●...
  • Page 214 As shown above, when M0 is ON, HSC0 begins to count the pulse input of X0 port; when M1 changes fromOFF to ON, HSC0 is reset, and the count value in HSCD0 (double words) is cleared. 5-7-4 Read HSC value [DMOV] 1)Instruction Summary Read HSC value to the specified register;...
  • Page 215 CNT_AB HSC0 K999999999 DMOV HSC0 CNT_AB HSC2 K999999999 DMOV HSC2 D10 K1000 D≥ ( ) D20 K1000 D≥ 5-7-5 Write HSC value [DMOV] 1)Instruction Summary Write the specified register value into HSC; Write HSC value [DMOV] 16 bits 32 bits DMOV Instruction Instruction...
  • Page 216 When the trigger condition is established, The value in the double-word data register D20 is  written into the accumulative register HSCD0 (double-word) corresponding to the HSC0 of the high-speed counter, and the original data is replaced.  High-speed counter can not directly participate in any application instructions or data comparison instructions (such as DMUL, LD >...
  • Page 217 Since the high-speed count value is 32-bit, the instructions here are all 32-bit instructions.Such as DMOV,DLD<, DLD≥ When SM0 is on, HSC0 counts X0 port in single-phase incremental mode, the setting  value is K888888, and reads the high-speed counting value to D0 (double-word) in real time.
  • Page 218 Since the high-speed count value is 32-bit, the instructions here are all 32-bit instructions.Such as DMOV,DLD<, DLD≥ When the rising edge of the original forward pulse coil SM2 comes, that is, at the  beginning of each scanning cycle, HSC0 is reset and the counting value in HSCD0 is cleared.
  • Page 219 In this panel, we can configure the parameters related to high speed count interruption. Take the settings in above figure as an example to explain each parameter function. Parameter Function single phase 100 High Speed Counting in Single Phase segments high speed Incremental Mode counting 100 segments AB...
  • Page 220 stored in the registers starting from HD100, and the set values are stored in the double-word registers HD100, HD102, HD104…. It must be used in relative mode. When all interrupts are over, high- Interruption cycle speed counting interrupts can still be generated circularly.
  • Page 221 *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M,HM,SM;S includes S,HS; T includes T,HT;C includes C, HC. Description When the high-speed counter HSC0 counts in single-phase mode, high-speed ...
  • Page 222 Operands Word soft elements Bit soft elements System Constant Module System Dn.m Only can be HSC ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M,HM,SM;S includes S,HS; T includes T,HT;C includes C, HC.
  • Page 223 5-9-4 Interruption flag of HSC The 100 segments interruption flags of each HSC are in the following table. For example, the 100 segments interruption flags of HSC0 are I2000, I2001, I2002….. I2099. Interruption flag Segment 2 Segment 3 … Segment N Segment 100 Segment 1 …...
  • Page 224 See graph below: Example 2: HSC2 current value is 10000, the segment one preset value is 10000, the preset value of segment 2 is 5000, the preset value of segment 3 is 20000. When starting to count, when the counter's current value is 20000, it generates the segment 1 interruption I2100; when the counter's current value is 25000, it generates the segment 2 interruption I2101;...
  • Page 225 In absolute mode, interruption occurs when the count value equals the set value of each section of the counter. N interrupt markers correspond to N interrupt settings. The N+1 interrupt settings register is reserved for other purposes. Example 1: The current value of counter HSC0 is 0, the setting value of segment 1 is 10000, the setting value of segment 2 is 15000, and the setting value of segment 3 is 20000.
  • Page 226 Note: When absolute counting is performed in non-cam mode, counting interrupts are generated sequentially, i.e.,segment 1 interruption, segment 2 interruption, segment 3 interruption... When a segment interrupt occurs, no interrupt occurs even if the count value reaches the set value of the segment again. As in the example above, if the count value is increased from 4000 to 5000 and 10000 after the interruption of segment 1 and 2, the interruption of segment 1 and 2 will not occur again, and the interruption of segment 3 will occur when the count value continues to increase to...
  • Page 227 Note: CAM function is only fit for absolute counting mode. Cam function can be set by configuration panel in XINJE PLC software, or by special Flash register SFD332: (Note: Drive condition must be set OFF and ON again to make...
  • Page 228 5-9-8 Interruption using notes and parameter address LD M0 //HSC trigger condition M0 (also interruption counting condition) CNT_AB HSC0 K2000 HD0 //HSC and 100-segment head address setting //HSC reset trigger condition HSC0 //HSC and 100-segment reset (also reset the interruption) As shown in the above example (note: the interrupt sub-program is omitted, see the application example in chapter 5-9-9).
  • Page 229 Some parameters can be modified in special Flash registers, as shown in the following table: Parameter Register address Setting value Counting mode SFD330 0: relative 1: absolute Execution mode SFD331 0: execution once 1: interruption cycle CAM function SFD332 0: not enable 1: enable cam function The above parameters can also be configured by the configuration panel in the following way: Move the mouse over the high-speed counting instruction and right-click it.
  • Page 230 Configure item Function High speed counter Choose HSC, the range is from HSC0 to HSC18 Frequency Choose the HSC frequency doubling (2 or 4) Compare value The value can be register or constant, in this example, when the counting value reaches compare value, HSC0 is ON. here the compare value is 200000 which is saved in D10.
  • Page 231 //D0= D0+1 IRET //interruption return flag I2001 //segment 2 interruption flag //SM0 is normally ON coil //D1= D1+1 IRET //interruption return flag Application 2: knit-weaving machine (continuous loop mode) The machine principle: Control the inverter via PLC, thereby control the motor. Meantime, via the feedback signal from encoder, control the knit-weaving machine and the precise position.
  • Page 232 HSC2: Back-forth times accumulation counter; HSC0: AB phase HSC;...
  • Page 233 Instruction List: //SM2 is initial ON coil //set ON Y2 (forward run) // Back-forth times activate condition Y2 CNT HSC2 K1000000 //HSC2 starts counting //SM000 is normal ON coil CNT_AB HSC0 D0 D100 //HSC 100 segments first address DMOV HSC0 D200 //read HSC0 counting value to D200 FEND //main program end...
  • Page 234 6 Communication Function This chapter mainly includes: basic concept of communication, Modbus communication and free communication. Relative Instruction Mnemonic Function Circuit and soft components Chapter MODBUS Communication COLR Coil Read 6-2-3 COLR INPR Input coil read INPR 6-2-3 COLW Single coil write COLW 6-2-3 MCLW...
  • Page 235 In the series of " " PLCs, there may be some models that do not support COM2-COM5. ※2: √ See Appendix 5 for details. The distribution of XD series communication ports is as follows: COM4 COM5 COM1/RJ45 Xinje Electronic Co.,Ltd SN:201208021525 ●...
  • Page 236 Appearance Definition protocol Function Download program, set the X-NET port parameters through COM0 RS232 port Modbus software or xinje config tool Modbus RTU Download program and Modbus ASCII connect external devices, COM1 RS232 port Free set the port parameters communication...
  • Page 237 Left extension ED Modbus RTU port (for connect external devices, Modbus ASCII extending set the port parameters COM3 Free RS232/RS485 through software or xinje communication port) config tool X-NET Above extension Modbus RTU COM4 BD port/ connect external devices, Modbus ASCII...
  • Page 238 XINJEConfig software, the USB driver will be installed automatically after the XINJEConfig software is installed. After installing the xinje config tool and usb driver, please switch to Xnet mode in the PLC software: (1) Open XDPPro software, click option/software serial port config (2) The window of "Communication Configuration"...
  • Page 239 (3) Select USB as the square port communication interface, XNET as the communication protocol, and device type as the search method. After restarting the service, click OK. (4) After the connection status is changed to ‘in use’, click OK:...
  • Page 240 (5) If "Successfully connected to the local PLC" is displayed, the connection is successful. Note: (1) If it shows the error “find device timeout”, you can click "Restart Service" to try to reconnect, or restart the programming software and PLC to reconnect. If you still can't connect, you need to check whether the PLC is power on, whether the USB download cable is connected properly, whether the USB driver and XINJEConfig software are installed properly.
  • Page 241 PLC, download functions, and communication with other TCP IP devices in the network through the Internet. RJ45 port can be configured in "PLC Config-Ethernet" of XINJE PLC programming software, or through XINJEConfig tool. Refer to the relevant manual for details.
  • Page 242 The above extension port can connect BD card which contains RS232 mode (XD-NS-BD), RS485 mode (XD-NE-BD) and optical fiber mode (XD-NO-BD). XD series 24/32 I/O PLC can extend one BD card, XD series 48/60 I/O PLC can extend 2 BD cards, XD series 16 I/O PLC cannot extend BD card.
  • Page 243 Free format communication parameters can be set by programming software, refer to chapter 6-3-2 for details. X-NET communication parameters can be set by Xinje Config tool. Refer to X-NET fieldbus manual for details. Note: For the A, B terminal on the PLC body, 1Mbps and higher baud rate is only fit for X-...
  • Page 244 MODBUS-RTU or MODBUS-ASCII protocol via Modbus instructions; it also can change data with other devices. For example: Xinje XD3 series PLC can control inverter by Modbus. Slave mode: When PLC is set to be slave, it can only response with other master devices.
  • Page 245 6-2-2 Changing of Modbus instruction Modbus instruction handling mode has changed in XD/XL series PLC, users can write Modbus instructions directly in program, the protocol station will queue up Modbus requests, which is not the same task with communication; It means users can use one triggering condition to trigger multiple Modbus instructions at the same time.
  • Page 246 X10500~X10577 5240~527F 21056~21119 (#6 module) X10600~X10677 5280~52BF 21120~21183 (#7 module) X10700~X10777 52C0~52FF 21184~21247 (#8 module) X11000~X11077 5300~533F 21248~21311 (#9 module) X11100~X11177 5340~537F 21312~21375 (#10 module) X20000~X20077(#1 58D0~590F 22736~22799 Y0~77(main unit) 6000~603F 24576~24639 Y10000~Y10077 6100~613F 24832~24895 (#1 module) Y10100~Y10177 6140~617F 24896~24959 (#2 module) Y10200~Y10277 6180~61BF...
  • Page 247 ID10200~ID10299 51C8~522B 20936~21035 (#3 module) ID10300~ID10399 522C~528F 21036~21135 (#4 module) ID10400~ID10499 5290~52F3 21136~21235 (#5 module) ID10500~ID10599 52F4~5357 21236~21335 (#6 module) ID10600~ID10699 5358~53BB 21336~21435 (#7 module) ID10700~ID10799 53BC~541F 21436~21535 (#8 module) ID10800~ID10899 5420~5483 21536~21635 (#9 module) ID10900~ID10999 5484~54E7 21636~21735 (#10 module) ID20000~ID20099 (#1 BD) 58D0~5933...
  • Page 248 FS0~FS47 F4C0~F4EF 62656~62703 ※2 2) XD5, XDM, XDC, XD5E, XDME, XL5, XL5E, XLME series PLC Modbus address and internal soft component table: Modbus Modbus Type component Address numbers address address (hex) (decimal) M0~M20479 20480 0~4FFF 0~20479 X0~X77(main unit) 5000~503F 20480~20543 X10000~X10077 5100~513F 20736~20799...
  • Page 249 Y10400~Y10477 6200~623F 25088~25151 (#5 module) Y10500~Y10577 6240~627F 25152~25215 (#6 module) Y10600~Y10677 6280~62BF 25216~25279 (#7 module) Y10700~Y10777 62C0~62FF 25280~25343 (#8 module) Y11000~Y11077 6300~633F 25344~25407 (#9 module) Y11100~Y11177 6340~637F 25408~25471 (#10 module) Y11200~Y11277 6380~63BF 25472~25535 (#11 module) Y11300~Y11377 63C0~63FF 25536~25599 (#12 module) Y11400~Y11477 6400~643F 25600~25663...
  • Page 250 (#7 module) ID10700~ID10799 53BC~541F 21436~21535 (#8 module) ID10800~ID10899 5420~5483 21536~21635 (#9 module) ID10900~ID10999 5484~54E7 21636~21735 (#10 module) ID11000~ID11099 54E8~554B 21736~21835 (#11 module) ID11100~ID11199 554C~55AF 21836~21935 (#12 module) ID11200~ID11299 55B0~5613 21936~22035 (#13 module) ID11300~ID11399 5614~5677 22036~22135 (#14 module) ID11400~ID11499 5678~56DB 22136~22235 (#15 module) ID11500~ID11599 56DC~573F...
  • Page 251 (#16 module) QD20000~QD20099(#1 68D0~6933 26832~26931 SD0~SD4095 4096 7000~7FFF 28672~32767 TD0~TD4095 4096 8000~8FFF 32768~36863 CD0~CD4095 4096 9000~9FFF 36864~40959 ETD0~ETD39 A000~A027 40960~40999 HD0~HD6143 6144 A080~B87F 41088~47231 ※1 HSD0~HSD1023 1024 B880~BC7F 47232~48255 ※1 ※1 HTD0~HTD1023 1024 BC80~C07F 48256~49279 HCD0~HCD1023 1024 C080~C47F 49280~40303 ※1 HSCD HSCD0~HSCD39 C480~C4A7...
  • Page 252 Modbus Modbus Type component Address numbers address address (hex) (decimal) X11700~X11777(#16 54C0~54F 21696~21759 module) X20000~X20077(#1 58D0~590 22736~22799 X20100~X20177(#2 5910~594F 22800~22863 X30000~X30077(#1 5BF0~5C2 23536~23599 Y0~77(main unit) 6000~603F 24576~24639 Y10000~Y10077(#1 6100~613F 24832~24895 module) Y10100~Y10177(#2 6140~617F 24896~24959 module) Y10200~Y10277(#3 6180~61BF 24960~25023 module) Y10300~Y10377(#4 61C0~61F 25024~25087 module)
  • Page 253 Modbus Modbus Type component Address numbers address address (hex) (decimal) B000~BFF C0~C4095 4096 45056~49151 C000~C02 ET0~ET39 49152~49191 C080~C0F SEM0~SEM127 49280~49407 C100~D8F ※1 HM0~HM6143 6144 49408~55551 D900~DCE HS0~HS999 1000 55552~56551 ※1 E100~E4F HT0~HT1023 1024 57600~58623 ※1 E500~E8F HC0~HC1023 1024 58624~59647 ※1 ※1 HSC0~HSC39 E900~E927...
  • Page 254 Modbus Modbus Type component Address numbers address address (hex) (decimal) ID20000~ID20099(#1 58D0~5933 22736~22835 ID20100~ID20199(#2 5934~5997 22836~22935 ID30000~ID30099(#1 5BF0~5C5 23536~23635 QD0~QD99(main unit) 6000~6063 24576~24675 QD10000~QD10099(#1 6100~6163 24832~24931 module) QD10100~QD10199(#2 24932~25031 6164~61C7 module) QD10200~QD10299(#3 61C8~622 25032~25131 module) QD10300~QD10399(#4 25132~25231 622C~628F module) QD10400~QD10499(#5 25232~25331 6290~62F3 module)
  • Page 255 The program can be written directly by using PLC internal soft components (Y0 / M0); for the second type, Modbus RTU or Modbus ASCII is selected if there is no Xinje driver, and then use the addresses in the table above to define the data variables.
  • Page 256 No input signal ≧ 10ms 2. Modbus address: 00H:All the Xinje XC series PLC broadcast—— slave stations don’t response. 01H:Communicate with address 01H PLC. 0FH:Communicate with address 15H PLC. 10H:Communicate with address 16H PLC and so on. Up to 254(FEH).
  • Page 257 4. Data content is the value in D2. 5. CRC CHECK High / CRC CHECK Low is high and low bit of CRC check value. If 2 pieces of Xinje XD3 series PLC communicate with the other one, write K5000 to D2. R E G W...
  • Page 258 Function code 01H/02H Function code 01H/02H Coil address Byte number Coil number Data contents CRC CHECK CRC CHECK Low CRC CHECK CRC CHECK High High As the status of Y0 and Y1 is ON, the data contents are 03H (0000 0011). (3)Function code 03H: read register Eg.
  • Page 259 RTU mode: Asking format Response format Address Address Function code Function code Coil address Coil address Coil number Coilnumber Byte number Data contents (low byte is before high byte) CRC CHECK CRC CHECK Low CRC CHECK CRC CHECK High High The data contents are 0103H, the binary format is 0000 0001 0000 0011, write in corresponding Y17~Y0, so Y0, Y1, Y10 are set ON.
  • Page 260 End mark: END low bit END Hi=CR(0DH),END Lo=CR(0AH) 2. Communication address: 00H:All Xinje XC series PLC broadcast—— slave stations do not response. 01H:Communicate with address 01H PLC. 0FH:Communicate with address 15H PLC. 10H:Communicate with address 16H PLC. And so on, up to 254(FEH).
  • Page 261 4. Data content is the value in D2. 5. LRC CHECK Low / CRC CHECK High is low and high bit of CRC check value. If two pieces of Xinje XD3 PLC communicate with each other, write K5000 to D2. REGW K1 H0002 K5000 K2 M0 is trigger condition (rising edge).
  • Page 262 Assign remote coil/register number: the start coil/register ID of PLC read and write, it is normally used with ‘assigned coil/register number’. E.g.:PLC read Xinje inverter’s output frequency (H2103), output current(H2104), bus voltage(H2105), then remote register/coil start ID is H2103, assigned coil number is K3.
  • Page 263 2) Operands Operands Function Type Specify the remote communication station no. 16 bits, BIN Specify the remote coil start address 16 bits, BIN Specify the coil quantity 16 bits, BIN Specify the local coil start address bits Specify the serial port no. 16 bits, BIN 3) Suitable soft components Operands...
  • Page 264 Input coil read[INPR] 16 bits INPR 32 bits instruction instruction Execution Normally ON/OFF, rising Suitable XD, XL condition edge models Hardware Software requirement requirement 2)Operands Operands Function Type Specify remote communication station no. 16 bits, BIN Specify remote coil start address number 16 bits, BIN Specify coil number 16 bits, BIN...
  • Page 265 This instruction cannot read XINJE PLC input coil.  Single Coil Write [COLW] 1)Summary Write local device specified coil to remote station no’s coil. Single Coil write [COLW] 16 bits COLW 32 bits instruction instruction Execution Normally ON/OFF, edge Suitable...
  • Page 266 SM160(serial port2) is set ON, SM160 is set OFF when the execution is completed. If a communication error occurs and the number of resend is set, it will be automatically resend. Users can check the relevant registers to determine the cause of the error. The execution result of Modbus read and write instructions of serial port 2 is in SD160.
  • Page 267 Write multiple coils, Modbus function code is 0FH.  Serial port: K0~K5. K0: Port0 (RS232), K1: Port1(RS232), K2: Port2(RS485), K3:  Port3(left extension port), K4: Port4(above extension port 1), K5: Port5(above extension port 2). Operand D3: max coil number is 1976. ...
  • Page 268 Function S1· S2· S3· D1· D2· REGR K500 Read register, Modbus function code is 03H.   Serial port: K0~K5. K0: Port0 (RS232), K1: Port1(RS232), K2: Port2(RS485), K3: Port3(left extension port), K4: Port4(above extension port 1), K5: Port5(above extension port 2). Operand S3: max register number is 125.
  • Page 269 ● ● ● ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM; DS includes DS, DHS. M includes M,HM,SM;S includes S,HS;T includes T,HT;C includes C, HC. Function S1·...
  • Page 270 3)Suitable soft components Word soft elements Bit soft elements Operands System Consta Module System X Y M S T C ● ● ● ● ● ● ● ● ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM;...
  • Page 271 3)Suitable soft components Word soft elements Bit soft elements Operands System Consta Module System X Y M S T C ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM;...
  • Page 272 (2) Open the programming software, click configure/PLC com port settings. It will show below figure: (3) Click add, it will show two modes, modbus mode and free mode, please select modbus mode, it will show below figure. Port No.: It refers to Port of PLC, COM0 refers to Port 0 (RS232), COM1 refers to Port 1 (RS232), COM2 refers to Port 2 (RS485) or Port 2-RS232 (RS485) or Port 2-RS485 (RS485), COM3 refers to Port 3 (left extended ED port), COM4 refers to Port 4 (upper extended BD port 1), COM5 refers to Port 5 (upper extended BD port 2).
  • Page 273 PLC sends data to the slave PLC again, which easily leads to the error of the slave PLC; In XD series PLC, it has send delay to solve the problem. That is, after receiving data from the slave station, it must delay a certain time to receive the next communication data, so as not to cause the above problems.
  • Page 274 (3) Click config/find device: Choose the com port connecting PC and PLC, click ok. Click config/single device/comport.
  • Page 275 (5) It will show below window. Serial port: K0 ~ K5. Port0 (RS232), Port1 (RS232), Port2 (RS485) or Port2-RS232 (RS232) or Port2-RS485 (RS485), Port3 (left extension port), Port4 (upper extension port 1), Port5 (upper extension port 2). Here, we can set the communication mode and parameters of each communication port. (6) When the com port parameters setting is completed, click writeconfig.
  • Page 276 Connect all A terminals, connect all B terminals. A is RS485+, B is RS485-. Application:One xinje XD3 series PLC controls 3 XC series PLCs, slave PLCs follow the master’s action. (Master PLC Y0 ON, then slave PLC Y0 ON; Master PLC Y0 OFF, then slave PLC Y0 OFF) Precondition: on-off of Y0 makes communication have enough time to react.
  • Page 277 (4) Read slave PLC 2 D10~D19 to master PLC D20~D29 (5) So as slave PLC 3 and 4 The following is a comparison of XC and XD series Modbus-RTU communication programs for reference. The communication programs in XC series are as follows:...
  • Page 278 M8002 //send station no.2 to D100, D100 execute the process S0 D100 K5 ( S ) STL S0 //set ONY0~Y11 of master station, ( S ) write the master status to Y0~Y11 of slave PLC 2, 3, 4. Enter process MCLW D100 K24576 K10 Y0 K2 S1 when the communication M8138...
  • Page 279 Instructions are queued according to the protocol station by Modbus-RTU, which will not cause communication errors when multiple communication instructions are executed at the same time as the original XC series PLC. XD series program: M200 MOV H3FF DY0 //at the rising edge of M200, set...
  • Page 280 The so-called free communication, i.e. custom protocol communication, now many intelligent devices on the market support RS232 or RS485 communication, but the protocols used by various products are different, such as: Xinje PLC uses standard Modbus-RTU protocol, some temperature controller manufacturers use custom protocols; if using Xinje PLC to...
  • Page 281 software to communicate. 6. Timeout: frame timeout (ms), reply timeout (ms) Frame: A data string. Frame timeout: refers to the time interval between two frames of data received by the PLC, which ensures that the PLC can distinguish the end time of receiving a frame. It is usually used to judge whether a frame of data in PLC has been received or not.
  • Page 282 Note: Versions V3.4 and above can be configured in Modbus communication mode (RS232 port); Versions V3.4 and below XD series PLC must use X-NET communication mode when downloading and uloading serial configuration data, that is, downloading and uploading...
  • Page 283 6-3-3 Suitable occasion When does free communication need to be used? As an example, the situation described in the above section is that XINJE PLC communicates with the temperature control instrument, and the instrument uses its own communication protocol, which stipulates that the reading temperature should be sent four characters: "R", "T", "CR".
  • Page 284 3) Suitable soft component Word soft elements Bit soft elements Operands System Consta Module System X Y M S T C ● ● ● ● ● ● ● ● ● ● *Notes: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM;...
  • Page 285 Receive data [RCV] 1) Summary Write the specified remote station no’s data to local device. Send data [RCV] 16 bits 32 bits instruction instruction Execution Normally ON/OFF, rising Suitable XD, XL condition edge triggering model Hardware V3.2.3 and higher version Software V3.2.2 and higher version 2)Operands...
  • Page 286  When the buffer number is 8 bits, the received data is only stored in low bytes, so D200 = the number of bytes to be received * 2, for example, to receive 8 bytes of data, stored in the low bytes of the eight registers D20-D27 in turn, at this time, D200 should be set to 16.
  • Page 287 RCVST instructions for other communication operations. 6-3-5 Free communication example Example 1: In chapter 6-3-3, we give an example of communication between Xinje PLC and temperature control instrument when explaining why to use free communication. Here is an example.
  • Page 288 3. make the program according to the descriptions in chapter 6-3-3. Read temperature: “ : ”“R”“T”“CR” “ : ” -------------- data start “R” --------------- read “T” --------------- temperature “CR” ------------- enter, data end Program: When trying to communicate between PLC and other intelligent devices, it is suggested to use serial debugging tool to determine the data format of communication, that is, protocol.
  • Page 289 program is written according to the data format obtained, which is often twice the result with half the effort. In fact, Modbus-RTU protocol can be regarded as a special kind of free protocol. The relationship between them is similar to ellipse and circle. We can try to use free format to realize the function of Modbus instruction.
  • Page 290 XDM program: Sometimes the data of user communication is stored in multiple registers in the form of ASCII code. Users need to take this value out, store it in a register and display it on the HMI. Customers often consider using HEX (ASCII to hexadecimal) instructions to achieve it. But HEX instructions are difficult to use and understand.
  • Page 291 value collected by PLC is stored from D0, and seven registers are stored in turn. However, the value of the seven registers combination needs to be taken out and stored in D46 in the form of decimal. Through the data monitoring of PLC, ASCII codes in D0~D6 registers can be monitored as follows: Switch to decimal format and show as below: By comparing the relationship between ASCII codes and decimal values, we can find the rule...
  • Page 293 6-4 Communication flag and register Communication flag Serial Register address Function Explanation port SM140 Modbusread-write When the instruction starts to instruction execution flag execute, set ON When execution is completed, Port 0 set OFF SM142 Free communication sending When the instruction starts to flag execute, set ON When execution is completed,...
  • Page 294 Port 4 SM180 Modbusread-write When the instruction starts to instruction execution flag execute, set ON When execution is completed, set OFF SM182 Free communication sending When the instruction starts to flag execute, set ON When execution is completed, set OFF SM183 Free communication received When receiving a frame of data...
  • Page 295 416: no end symbol SD144 free communication Count as byte, not include start receiving data number symbol and end symbol …… SD149 SD150 Modbusread and write 0: correct instruction execution result 100: receive error 101: receive timeout 180: CRC error 181: LRC error 182: station number error Port 1...
  • Page 296 2: memory error 3: receive CRC error SD162 Free communication 0: correct sending result 410: free communication buffer overflow SD163 Free communication 0: correct receiving result 410: send data length overflow 411: receive data short 412: receive data long 413: receive error 414: receive timeout 415: no start symbol 416: no end symbol...
  • Page 297 6-5 Read write serial port parameters In addition to modifying communication parameters through serial configuration panel, it can also be realized by reading instruction [CFGCR] of serial parameters and writing instruction [CFGCW] of serial parameters. 6-5-1 Read serial port parameters [CFGCR] 1)Summary Read the serial port parameters to local specified registers.
  • Page 298 Read 8 parameters of serial port 2 to HD0~HD7. See sections 6-5-3 for the names and  definitions of specific parameters. 6-5-2 Write serial port parameters [CFGCW] 1)Summary Write the local specified register value to specific serial port. Write serial port parameters[CFGCW] 16-bit CFGCW 32-bit...
  • Page 299 6-5-3 Serial port parameter name and setting Assuming that HD0-HD14 corresponds to serial port parameters, the parameter names and settings represented by registers are shown in the table below. Para Parameter name and settings meter MODBUScom Free X-NET communication Ethernet addre munication(HD communication...
  • Page 300 station number is Gateway address low 2- byte Note: The table does not contain "buffer digits" in free communication mode, so "buffer digits" can not be read and written through CFGCR and CFGCW instructions, but can be read and written using MOV instructions. The address of "buffer digits" is shown in Appendix 3. Table 1: baud rate Value Baud rate Value Baud rate...
  • Page 301 7 PID Control Function In this chapter, we mainly introduce the applications of PID instructions for XD, XL series, including: call the instructions, set the parameters, items to notice, sample programs etc. 7-1 PID Introduction PID instruction and auto tune function are added into XD/XL series PLC basic units. Via auto tune method, users can get the best sampling time and PID parameters and improve the control precision.
  • Page 302 3)Suitable soft components Word soft elements Bit soft elements Operands System Consta Module System X Y M S T C ● ● ● ● ● ● ● ● ● ● ● ● ● ● *Note: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD; DM includes DM, DHM;...
  • Page 303 Here, e(t) is offset value, r ( t ) is the setting value, c ( t ) is actual output value and the u(t) is the control value; In function (1-2), Kp is the proportion coefficient, Ti is the integration time coefficient, and TD is the differential time coefficient.
  • Page 304 V3.2 and higher version software can choose auto tune mode: step response or critical oscillation. 7-3-1 Register and their functions PID control instruction’s relative parameters ID, please refer to the below table: Function Description Memo Sampling time Whatever it is manual or auto 32bits without sign, mode, all needs to set Unit: ms...
  • Page 305 mode) 00:PID control 01:PI control 10:P control bit15:0:regular mode; 1:advanced mode; S3+3 Proportion Gain (Kp) 0~32767[%] S3+4 Integration time (TI) 0~32767[unit: 100ms] 0 is taken as no integral. S3+5 Differential time ( TD) 0~32767[unit: 10ms] 0 is taken as no differential.
  • Page 306 S3+17 PID max output 0~32767 Internal use parameters of the system for monitoring purposes only S3+18 PID min output 0~32767 Internal use parameters of the system for monitoring purposes only S3+19 Last time sampling time 0~sampling time (unit: ms) 16-bit no sign, Internal use parameters of the system for...
  • Page 307 system S3+38 Last sampling -32767~32767 Internal usage temperature parameters of the system S3+39 The time from auto- -32767~32767 (unit: ms) Internal usage tuning PID operation to parameters of the inflection point system S3+40 Starting sampling value -32767~32767 Internal usage of auto-tuning PID parameters of the operation system...
  • Page 308 parameters of the system S3+26 Number of times to 0~65535 Internal usage reach target parameters of the temperature system S3+27 PID upper limit of -32767~32767 Internal usage operational range parameters of the system S3+28 PID lower limit of -32767~32767 Internal usage operational range parameters of the system...
  • Page 309 Advanced Mode Parameters register range: S3~S3+69, among them S3~S3+7 and S3+8~S3+11 need to be set by users; S3+16~S3+69 are occupied by system, users can’t use them. Sample time[S3] The system samples the current values according to some certain interval and compares them with the output value.
  • Page 310 Suppose: we see the death region value to be 10. Then in the above graph, the difference is only 2 comparing the current value with the last value. It will not do PID control; the difference is 13 (more than death region 10) comparing the current value with the next value, this difference value is larger than control death region value.
  • Page 311 For critical oscillation method: user needs to set the sampling time at the beginning of the auto tune process. For slow response system, 1000ms. For fast response system, 10-100ms. For critical oscillation method: the system can start the auto tune at any state. For object temperature, the current temperature doesn’t need to be same to ambient temperature.
  • Page 312 ※1:If users have no experience, please use the default value 10, set PID sampling time (control period) to be 0msthen start the auto tune. PID auto tune overshooting permission setting [S3+13] If set 0, overshooting is permitted, and the system can study the optimal PID parameters all the time.
  • Page 313 Over target value times in auto-tuning end transition stage when limiting the overshoot[S3+15] This parameter is valid only when [S3+13] is 1; If entering into PID control directly after auto tune, small range of overshoot may occur. It is good to prevent the overshoot if increasing this parameter properly. But it will cause responselag if this value is too large.
  • Page 314 7-6 Application outlines Under the circumstances of continuous output, the system whose effect ability will die down with the change of the feedback value can do auto tune, such as temperature or pressure. It is not suitable for flux or liquid level. Under the condition of overshooting permission, the system will get the optimal PID parameters from auto tuning.
  • Page 315 Soft element function comments: HD2.7: Auto tune bit HD2.8: Successful flag of auto tune M0: Normal PID control M1: Auto tune control M2: Enter PID control after auto tune Operation steps: 1. Send the actual temperature to PID collection register 2.
  • Page 316 3. The result curve Explanation:...
  • Page 317 The target temperature is 60 degree, PID calculation range is 10 degree, PID control dead area is 0.2 degree, auto tune period changing value is 10. When the PID control works in normal atmospheric temperature, the PID output terminal will heat the temperature from 28 to 100 degree, then the output stops, the temperature keeps increasing to 110 degree (max temperature) as the remaining warmth.
  • Page 318 3. The result curve...
  • Page 319 Explanation: The target temperature is 60 degree, PID calculation range is 10 degree, PID control dead area is 0.2 degree, auto tune period changing value is 10. When the PID control works in normal atmospheric temperature, the PID output terminal will heat the temperature from 28 to 48 degree, then the output stops, the temperature keeps increasing to 70 degree (max temperature) as the remaining warmth.
  • Page 320 We also attach the common function list. 8-1 Summary XD/XL series supports to write function blocks in C language in the Xinje PLC software and call them where needed. It supports almost all C language functions (compared with XC series, XD/XL series also supports global variables), which enhances the confidentiality of the program.
  • Page 321 Function and Action S1· S2· S3· NAME_C S1 is the function name. It consists of numbers, letters and underlines. The first character can’t be number, and the name length should be <=9 ASCII characters. The name can be the same with PLC’s self instructions like LD, ADD, SUB, PLSR etc. The name can’t be the same with the function blocks existing in current PLC;...
  • Page 322 Function Block Name Editor Name Function Block name is the name we use to call the BLOCK. For example: the diagram of FUNC1 should be written as below: 3. After creating the new Function Block, you can see the edit interface as shown below: Main function’s name (it’s function block’s name, this name can’t be changed freely, and users should modify in the edit window.)
  • Page 323 parameters in the ladder are HD0, HM0, then W[0]=HD0,B[0]=HM0; if the parameters in the ladder are D100, HM100, then W[0]=D100, B[0]=HM100. So, word and bit components start address are defined in PLC program by the user.  Note: The local variable defined inside the C function cannot be more than 100 words. Parameter W: represent Word soft component, use it in the form of data group.
  • Page 324 BOOL; //BOOL Quantity INT8U; //8 bits unsigned integer INT8S; //8 bits signed integer INT16U //16 bits unsigned integer INT16S //16 bits signed integer INT32U //32 bits unsigned integer INT32S //32 bits signed integer FP32; // single precision floating FP64; //double precision floating Examples: #defineDHD*(INT32S*)&HD //DHD means double word HD...
  • Page 325 (2) Export Format a) Edit: Export the source codes out and save as a file. If import again, the file is editable; b) No edit: Don’t export the source code, if import the file, it’s not editable. Ethernet models and non Ethernet models cannot be used in common. You only need to modify the model before exporting it.
  • Page 326 The information list According to the information shown in the output blank, we can search and modify the grammar error in C language program. Here we can see that in the program there is no ‘;’ sign behind W [2] =W [0] + W [1]. Compile the program again after modifying the program.
  • Page 327 (4) Download program into PLC, run PLC and set M0. (5) From Free Monitor in the toolbar, we can see that D2 changes to be 30, it means assignment is successful; Free Monitor 8-6 Program Example If PLC needs to do complicated calculation (including plus and minus calculation), the calculation will be used for many times, C language function is easy to use.
  • Page 328 Note: 1. The result of MUL is Dword, the result is stored in D14~D15. 2. The result of DIV has quotient D16 and remainder D17. If D17 has value, the calculation precision will decrease. Please use float format to ensure the precision. 3.
  • Page 329 C program Method 2 can simplify the program. The above C language function is similar to ladder chart of method 1, whose precision is not high. If it needs to get the high precision, please use float calculation. Example 2: Calculate CRC parity value via Func Block CRC calculation rules: (1)Set 16-bit register (CRC register) = FFFF H (2)XOR (Exclusive OR) the first 8-bit byte message and the low 16-bit CRC register.
  • Page 330 Edit PLC ladder program, D0: Check byte number of data, D1~D5: Check data content. See graph below: Download to PLC, then RUN PLC, set M0, via Free Monitor, we can find that values in D6 and D7 are the highest and lowest bit of CRC parity value; 8-7 New functions (1) Format Click the advanced/editor support setting menu to open the C editor support options window.
  • Page 331 (2) Local code auto format  Auto format completed statements when entering ‘;” When the user enters the character ";" format the statement of the current row.  Auto format completed sequence when entering “}” When the user enters "}", format the contents in "{}". (3) Handling special characters The full width characters entered by the user into the editor need to be converted to half width characters because they are not recognized by the compiler.
  • Page 332  Access tips for member variables When the user enters "." "or" - > ", the code prompt function will help the user prompt the members in the structure or consortium type of the defined variable, as shown in the following figure.
  • Page 333 8-8-1 New function 8-8-1-1 Classification of Libraries Function library are divided into project library and global library. Project library: the functions in the user's project library are saved under the project and can be used directly. Global Library: the function functions in the user's global library are saved in the local directory for user's convenience.
  • Page 334 Note: if the library name is the same as any library name in the current library, the following pop-up window will appear: 8-8-3-2 Create global library Select "Function library" in the "Project" toolbar on the left, right-click and select "Create Global Library", and you can edit the name, version, description, author and other information of the global library in the pop-up interface, as shown in the following figure: Note: if the global library directory is not set, the prompt message shown in the following...
  • Page 335 After setting the path, the new library file window is displayed, and the library information (name, version, description, author) is filled in. If the library name is the same as any library name in the current library, the following pop-up window will appear: 8-8-3-3 Create new source In the "project"...
  • Page 336 Click "next" after filling in to configure parameter information: After completing the parameter configuration, click "next" to display the preview interface of the source file. If there is a problem, click "previous" to reset the parameters. If there is no problem, click "OK"...
  • Page 337 8-8-3-4 Create new header In the "Project" toolbar on the left, select the project library or global library to which the source file needs to be added in the "Function Library", right-click and select "New header file" to edit the name of the header file in the pop-up interface, as shown in the following figure: 8-8-4 Edit 8-8-4-1 Edit library information...
  • Page 338 1) Basic information Library name: only letters and numbers are allowed for the library name. Version: the format of the library information version is "V primary. Secondary. Revision". 2) Files information Add the source file / header file under the selected function library, and the file ...
  • Page 339 8-8-4-2 Source file information Click the source file to edit information in the project bar: In the pop-up source file interface, click information to modify the source file information, the source file function signature is modified, and the code is modified accordingly. 8-8-4-3 Header file information Click the header file to edit information in the project bar:...
  • Page 340 In the pop-up header interface, click information to modify the head file information, the header function signature is modified, and the code is modified accordingly. 8-8-5 Export 8-8-5-1 Export the function library Click "Project library" or "Global library" in the project bar on the left to edit the information, and click "Export"...
  • Page 341 Or click the source file / header file to be exported in the project column on the left, and click "export" in the editing interface on the right: Select the export mode (editable or not) in the pop-up file information. Click OK after setting and select the file saving path.
  • Page 342 8-8-6-2 Import function files Right click the "Project Library" or "Global Library" in the project bar on the left to import files, and select "Batch import files": Select the function file to be imported in the "select file" interface, and click "open" to complete the file import.
  • Page 343 Click settings to change the Global Library Directory: 8-8-7-2 Delete library file In the "function library management window" of the previous chapter, check the corresponding library file and click Delete to delete the library file in the current project.
  • Page 344 8-8-7-3 Remove library file Right click the "Project Library" or "Global Library" in the project bar on the left to import the file, and select "Remove Library file": Note: Remove the library file means to cancel the application of the file from the current project without deleting it.
  • Page 345 Check the files to be deleted and click "batch delete": Click "Apply" and a prompt message "successfully applied" will appear. The file has been deleted. 8-8-7-5 Transfer The "global library" and "project library" can be converted to each other, and the editing interface of the function library can be opened (for specific steps, refer to chapter 8-8-7-4, method 2).
  • Page 346 8-8-7-6 Compile Click the source file in the project bar on the left, and click "compile" in the editing interface on the right.
  • Page 347 8-8-7-7 Set Global Library Directory There are three methods to set the global library: Method 1:Open the library management interface (please refer to 8-8-7-1. Library manager for specific steps). If the global library directory has not been set, the prompt to set the global library directory will appear.
  • Page 348 8-9 Application notes In one Func Block file, you can write many functions, and they can be called by each  other. Each Func Block file is independent, the function in other function block cannot be  called. Func Block files can call C language library function in form of floating, arithmetic ...
  • Page 349 Take FP64 type as an example: As shown in the figure above, the global pointer GlobalV is declared outside the function, and then initialized in the main function to point to the space of the software component. The first address of the space is the address where W[0] is located. Finally, the value of the variable can be obtained through pointer operation in other functions.
  • Page 350  XDPPro software v3.3 and later version keep C function library: In this function block, user can call the C function directly: For example: click TUE, the function name will show on the project bar: User can call it in the ladder chart editing window at any time.
  • Page 351 8-10 Q&A of C language (1)second macro definition for the coil Some users have further extended the software component type after defining it, as shown in the following code: #define SysRegAddr_HD_D_HM_M_X_Y #define OUT Y[1] OUT = 100; The second macro definition of coils such as Y is not allowed because the reading and writing of coil data is not simply a pointer, but through a function.
  • Page 352 There is no compilation function in the header file. Only the source file can be compiled. The header file cannot be compiled separately. (6)When two source files call the header file, you only need to write a declaration in one source file.
  • Page 353 8-11 Function Table The default function library Constant Data Description _LOG2 (double)0.693147180559945309417232121458 Logarithm of 2 _LOG10 (double)2.3025850929940459010936137929093 Logarithm of 10 _SQRT2 (double)1.41421356237309504880168872421 Radical of 2 (double)3.1415926535897932384626433832795 _PIP2 (double)1.57079632679489661923132169163975 PI/2 _PIP2x3 (double)4.71238898038468985769396507491925 PI*3/2 String Function Description Return the first c position among void * memchr(const void *s, int c, size_t n);...
  • Page 354 Double-precision math Single-precision math Description function function double acos(double x); float acosf(float x); Inverse cosine function double asin(double x); float asinf(float x); Inverse sine function double atan(double x); float atanf(float x); Inverse tangent function double atan2(double y, float atan2f(float y, float Inverse tangent value of double x);...
  • Page 355 Flash register operation special function library Flashregister operation special Explanation function A function that copies data to a flash register. DST: the starting address of the target register flash_copy ( void *dst, void *src, copied to; size_t len ); SRC: source data address; Len: number of bytes copied;...
  • Page 356 Example 2: set value in Flash register flash_set_int16 ( void* dst, int16 data ); The advantage offlash_set_int16compared to flash_copy: If using flash_copyto set value in flashregister. It is very inconvenient to use. int temp_val = 1000; flash_copy(&FD[1000], &temp_val, sizeof(temp_val)); If using flash_set:flash_set_int32(&FD[1000], 1000); See line 13~18 in the below example: Note: (1) flash_ move function requires the support of the PLC firmware version of the lower...
  • Page 357 9 Sequence BLOCK This chapter mainly introduces sequence block instruction and the application. Sequence Block instruction: Mnemonic Function Ladder chart Chapter Sequence Block SBSTOP Pause BLOCK 9-6-1 SB STO P Go to execute SBGOON 9-6-1 SB G O O N BLOCK 9-1 Concept of the BLOCK Sequence block whose brief name is BLOCK is a program block to realize some functions.
  • Page 358 ※1: Firmware version below V3.4.5: the XD series PLC allows up to eight BLOCKs. Firmware version V3.4.5 and above: XD/XL series PLC can write up to 100 BLOCKs, but at the same time can only run 8. ※2: When the trigger condition of the BLOCK is triggered by the closure of the normally open coil, it will be executed from the top of the BLOCK to the bottom in turn.
  • Page 359 You can edit the BLOCK in the window, Upwards/Downwards are used to change the position of instructions in the block. Click ‘insert’ button, some instructions list under the menu:...
  • Page 360 Take ‘Pulse Item’ for example: After click ‘OK’, you will find information in the configuration: Click ‘OK’, the following instructions are added in the ladder:...
  • Page 361 Meantime, a new sequence block is added in the left of the project bar: 9-2-2 Move the BLOCK If you want to move the BLOCK to other place, you have to select the original BLOCK and delete it (select all, then delete): Move the cursor to the new place, and then right click the BLOCK and select ‘add to lad’: Now the BLOCK is moved to the new place:...
  • Page 362 9-2-3 Delete the BLOCK You can select the called BLOCK and delete it. If you want to completely delete the BLOCK, right click the function block and select ‘delete sequence block’. After this operation, you can’t call this BLOCK any more: 9-2-4 Modify the BLOCK There are two methods to modify the BLOCK.
  • Page 363 (B) Double click the middle part to modify : 9-3 Edit the instruction of the BLOCK 9-3-1 Command item Use ‘command item’ to edit the program:...
  • Page 364 An ‘instruction list’ will jump out after click the ‘command item’: Users can add instructions in the frame. Skip: to control the stop and run of the instructions. If you select skip and input control coil in the frame, then when the control coil is ON, the command will not be executed. If not select, the default action is execution.
  • Page 365 In the above figure, the command segment is not expanded in the ladder diagram, but its annotation can be modified according to the function of the segment, as shown in the following figure: The modified block phrase has also changed accordingly, as shown in the following figure: 9-3-2 Pulse Item Open the ‘pulse item’...
  • Page 366 9-3-3 Wait Item ‘Wait Item’: to wait coil flag or timer bit. Open ‘Wait Item’ in the same way. There are two waiting modes: flag bit and timer wait. (A) Flag bit SEM corresponding ladder diagram is as below: POST SEM0 (B) Timer wait (C) Corresponding ladder diagram:...
  • Page 367 Note: Do not add normal coil after WAIT instruction in XD/XL series PLC sequence BLOCK, and add XD, XL series PLC special signal SEM bit(SEM0~SEM31); SEM cannot be controlled by set or reset. It can only be set by POST instruction and reset by WAIT SEM instruction.
  • Page 368 9-4 Running form of the BLOCK 1. If there are many blocks, they run as the normal program. The block is running when the condition is ON. (A) The condition is normal ON, normal OFF coil SBLOCK Sequence block 1 SBLOCK Sequence block 2 SBLOCK...
  • Page 369 When M1, M2, M3 is from OFF to ON, all these blocks will run once. 2. The instructions in the block run in sequence according to the scanning time. They run one after another when the condition is ON. (A) Without SKIP condition The instructions running sequence in block 1 is shown as below: (B) With SKIP condition Explanation:...
  • Page 370 E) After Y0 pulse sending completed, check M4. If M4 is OFF, check Y1 block, if M4 is ON, check M5. If M5 is OFF, module commmunication will run. 9-5 BLOCK instruction editing rules In the BLOCK, the instruction editing should accord with some standards. (1)Do not use the same pulse output terminal in different BLOCK.
  • Page 371 (4)The SKIP condition only can use M, X, can not use other coil or register. NO(×) YES(√) (5)The output instructions cannot be CNT_AB(CNT), PWM. NO(×) YES(√) (6)BLOCK is not recommended to put in the STL, because if one STL ends, while the BLOCK doesn’t end, then big problem will happen.
  • Page 372 9-6 BLOCK related instructions 9-6-1 Instruction explanation Stop running the BLOCK [SBSTOP] 1)Summary Stop the instructions running in the block [SBSTOP] 16 bits SBSTOP 32 bits Condition NO,NC coil and pulse edge Suitable XD, XL types Hardware Software V3.2 2)Operands Operand Function Type...
  • Page 373 K0: stop the BLOCK slowly, if the pulse is outputting, the BLOCK will stop after the pulse outputting is finished. K1: stop the BLOCK immediately; stop all the instructions running in the BLOCK. K2: Destructive slow stop BLOCK, that is, when the pulse is being sent, the SBSTOP condition holds, then the pulse will slow down along the slope, without to use with the SBGOON instruction, so the remaining instructions will not be executed.
  • Page 374 Function S1· S2· SBGOON ↑ S2 is the mode to continue running the BLOCK. Operand: K0, K1. K0: continue running the instructions in the BLOCK. For example, if pulse outputting stopped last time, SBGOON will continue outputting the rest pulse; K1: continue running the BLOCK, but abandon the instructions have not finished last time.
  • Page 375 When M0 is from OFF→ON, run “PLSR HD0 HD100 K1 Y0” in the BLOCK to output the pulse; When M2 is from OFF→ON, the BLOCK stops running at once; When M4 is from OFF→ON, abandon the rest pulse. SBSTOP(K1 K1)+SBGOON(K1 K0)
  • Page 376 Scanning period 1 Scanning period 2 Scanning period 3 Scanning period 4 Scanning period 5 Condition M0 Condition M2 Condition M3 PLS Y0 PLS Y0 When M0 is OFF→ON, run ‘PLSR HD0 HD100 K1 Y0’ in the BLOCK to output the pulse; When M2 is OFF→ON, the BLOCK stops running, the pulse output stops at once;...
  • Page 377 When M0 is from OFF→ON, run ‘PLSR HD0 HD100 K1 Y0’ in the BLOCK to output the pulse; When M1 is from OFF→ON, stop running the BLOCK, the pulse will stop slowly with slope; When M4 is from OFF→ON, abandon the rest pulses. SBSTOP(K1 K0)+SBGOON(K1 K0)
  • Page 378 When M0 is from OFF→ON, run ‘PLSR HD0 HD100 K1 Y0’ in the BLOCK to output the pulse; When M1 is from OFF→ON, suspend running the BLOCK, the pulse will stop slowly with slope; When M3 is from OFF→ON, output the rest pulses. Please note that by the SBSTOP stops the pulse with slope, there may be still some pulses;...
  • Page 379 10 Special Function Instructions This chapter mainly introduces PWM (pulse width modulation), FRQM, precise timing, interruption etc. Special Function Instructions List: Chapt Mnemonic Function Circuit and soft components Pulse Width Modulation, Frequency Detection Output pulse with the specified duty cycle and 10-1 frequency Fixed pulses frequency...
  • Page 380 Function and Action S1· D· S2· K100 Duty cycle n: 1~65535. Output pulse f: 1~100KHz XD series PLC PWM output need transistor type terminal: PLC model PWM terminal XD2-16T/RT -24T/RT -32T/RT -48T/RT -60T/RT Y0、Y1 XD3-16T/RT -24T/RT -32T/RT -48T/RT -60T/RT Y0、Y1 XD5-16T/RT -24T/RT -32T/RT -48T/RT -60T/RT Y0、Y1...
  • Page 381  Duty cycle of PWM output =n /65535×100%  PWM use the unit of 0.1Hz, so when set S2 frequency, the set value is 10 times of the actual frequency (10f). E.g.: to set the frequency as 72 KHz, and then set value in S2 is 720000.
  • Page 382 pressed. 50% brightness button, X3 is ON when pressed. 75% brightness button, X4 is ON when pressed. 100% brightness button, X5 is ON when pressed. PWM duty ratio register PWM frequency register Defaulted 100Hz Program: Program explanation: 1. HD0 will control the LED voltage. The voltage = 24*HD0/65535, pulse output frequency is 100Hz.
  • Page 383 10-2 Frequency measurement [FRQM] 1) Summary Measure the frequency. Frequency measurement [FRQM] 16 bits 32 bits FRQM instruction instruction execution Normally ON OFF coil suitable XD/XL (except condition models XD1/XL1/XDH/XLH) hardware software requirement requirements 2)Operands Operands Function Type Sampling pulse numbers 16 bits, BIN The display precision 16bits, BIN...
  • Page 384 The measurement precision is 0.001%.  The pulse input terminal for FRQM: Model X terminal Max frequency (Hz) 16 I/O X0、X3、X6 XD2 series X0、X3 24/32/48/60 I/O 16/24/32 I/O X3、X6 XD3 series X0、X3 48/60 I/O X0、X3 16/24/32/48/60 I/O X0、X3、X6、 XD5 series 24T4/32T4/48T4/48D4T4/60T4 X0、X3、X6、...
  • Page 385 Example Asynchronous motor drives the conveyor to transfer the work piece. It needs to real-time display the work piece moving speed. The diameter of the transmission shaft is 100mm, the gear numbers on the transmission shaft are 100, the speed unit is m/min. Component explanation: Control explanation Mark...
  • Page 386 rotation), the result is shaft rotate numbers per second (float number). 3. Calculate the diameter of the transmission shaft and save in register D6 (float number), then calculate the transfer distance per second and save in D10 (float number). 4. the transfer distance per second multiply by 60 is the speed (m/min). 10-3 Precise Timing [STR] 1) Summary Read and stop precise timing when precise timing is executed...
  • Page 387 D1· D2· K100 :Timer’s number. Range: ET0~ET30 (ET0, ET2, ET4……all number should be even) D1· :Timing value D2· Precise timer works in unit of 1ms.  Precise timer32 bits, the counting range is 0~+2,147,483,647.  When executing STR, the timer will be reset before start timing. ...
  • Page 388 PreciseTiming Interruption When the precise timing reaches the count value, it will generate an  interruption tag, interruption subprogram will be executed. Can start the precise timing in precise timing interruption;  Every precise timer has its own interruption tag, as shown below: ...
  • Page 389 Component explanation: Control explanation Mark component Start button, X0 is ON when the button is pressed Precise timer Control the liquid valve, Y0 ON when the valve opened, Y0 OFF when the valve closed Program: Program explanation: 1. When X0 is ON, the liquid valve Y0 and precise timer ET0 open at once. 2.
  • Page 390 Program explanation: 1. When X0 is ON, the precise timer interruption will work, Y2 will output the pusle wave. 2. When X0 is OFF, shut down the precise timer interruption, Y2 stop outputting. Example 3 As the FRQM calculating the time for fixed pulse numbers, we will change the way to calculate the pulse numbers in fixed time.
  • Page 391 Program explanation: 1. Set the high speed counter sampling period register HD0, the unit is ms. 2. Set ON M0 to start the precise timer interruption and high speed counter, calcuate the frequency The frequency range is 0-80KHz, the precision is 0.005%. 10-4 Interruption [EI], [DI], [IRET] XD/XL series PLC have interruption function, including external interruption and timing interruption.
  • Page 392 I0300 I0301 SM053 I0300 I0301 SM053 I0400 I0401 SM054 I0400 I0401 SM054 I0500 I0501 SM055 I0500 I0501 SM055 XD series 10 I/O I0600 I0601 SM056 Pointer No. Disable I0700 I0701 SM057 Input Rising Falling interrupt termi Interrupt interrupt I0800 I0801...
  • Page 393 Interruption Instruction Enable Interruption [EI], Disable Interruption [DI], Interruption Return [IRET]  If use EI instruction to allow interruption, then when scanning the program, interruption input changes from OFF to ON, then execute subroutine ① 、 ②. Return to the original main program. ...
  • Page 394 Disable the Interruption  Every input interruption is equipped with special relays (SM50~SM69) disable interruption.  In the left program, if use M0 to set SM50 “ON”, then disable the interruption 0. Example 1 The positions of A, B, C are unknown. The speed of the three segments are different. The application can be perform by PLSF instruction and external interruption.
  • Page 395 Component explanation Control explanation Mark component Start button, PLSF will send pulse when the button is pressed the PLSF pulse frequency register Program Program explanation 1. SM2 is ON, set HD0 to 10000, set on M0, PLSF instruction will send 10000Hz pulse, the object will move from origin to A.
  • Page 396 improve the working efficiency, the product sending speed is very fast, the sensor X2 detects the product time is 8ms, PLC input terminal filter time is 10ms, the normal counter cannot detect the products. We can use the external interruption to count the products. Component explanation: Control explanation Mark...
  • Page 397 Y0 and C0 are reset, M0 is OFF, wait for the next packing process. 10-4-2 Timing Interruption Function and Action Under the circumstance that the main program execution cycle is very long, when you have to handle with special program or execute specific program every once in a while when program is scanning in sequence control, the timing interruption is very useful.
  • Page 398 I49** I59** SM089 function is only supported SM079 by PLC firmware version V3.4.6 or later. Interruption range’s limitation Timing interruption is usually on ‘allow’ status.  Can set interruption allow and forbidden area with EI、DI instructions. As shown in  below pictures, all timing interruptions are forbidden between DI and EI, and allowed beyond DI~EI.
  • Page 399 10-5 SD card reading and writing XD5 (except XD5-16), XDM series PLC body can be extended with an SD card for data storage and backup. The SD card slot is located on the CPU board of the PLC. When using, you need to lift the BD cover plate and insert the SD card into the card slot.
  • Page 400 10-5-2 File name and storage location SD card supports storing ".csv" format files, which must be stored in the root directory of SD card. All ".csv" files must be named after "dataxxx.csv", and "xxx" is the index number of the file, ranging from 001 to 999.
  • Page 401 2)write SD card Add a write SD card instruction in the sequence function block, as shown in the following figure: The SD card instruction : WRITESD D30 D40 D50, and the function meanings of each parameter are as follows: D30: file index number / column / line beginning address, D30~D32 represent file index number, column number and line number respectively.
  • Page 402 3)Limit the number of reading and writing data of word A piece of data cannot be read only part of it. For example, the format is defined as W, DW, S8. If you read from the first column W and the number of words read is 10, S8 cannot be read completely, and the program will report an error (the correct number of words is 3, or 11).
  • Page 403 SD453 Explanation Reason Reading file There are tasks reading files Writing file There are tasks writing files Read/write error Unplug SD card while reading and writing Insufficient SD card space Insufficient SD card space Reserve SD card is not inserted properly, or the SD card FAT32 error is not formatted as FAT32 Reserve...
  • Page 404 (4)Click 【Browse】and select the 【Format conversion.xla】file extracted previously. (5)【Format conversion】 is added to the available add ins and checked in the front. (6) After [OK], the 【add in】column and the 【format conversion】option are added to the excel toolbar, as shown in the following figure: (7) Open the existing csv file and click format conversion to complete the conversion.
  • Page 405 10-6 Multi station control[MSC] 1) Summary Grab the encoder value according to the trigger input, calculate and save the entry value and exit value of the workpiece in each station, compare the stored value of each workpiece in each station with the current value of the encoder, and output the comparison result. Multi station control[MSC] 16 bits 32 bits...
  • Page 406 S1: it is the command trigger input point, which can select the external interrupt input  point or ordinary input point, trigger the command at the rising edge and falling edge, and grab the encoder value. S2: it is the number of the high-speed counter used together, which is used for encoder ...
  • Page 407 D1: continuously occupy 2n 16 bits registers (single word), 2m × n 32-bit registers  (double word) are used to store the workpiece forward index value, follow index value, entry comparison value and departure comparison value of each station. The specific register address allocation is as follows: Name Station 1...
  • Page 408 The comparison value of workpiece m entering station n = the grab count value of  workpiece m (at the rising edge) + the reference value of station n + the workpiece entering deviation value of station n. The departure comparison value is automatically calculated and stored in the D1 data ...
  • Page 409 counter is HSC0), the width of each workpiece is 100, the distance between workpieces is 1500, the distance between workpieces is 1000, the distance between workpieces is X4, 2000, and the distance between workpieces is 4000. The procedure is as follows: Soft component address Function description Trigger input point...
  • Page 410 Workpiece 1 leaves the HD112 HD114 HD116 comparison value(double word) Workpiece 2 entry HD118 HD120 HD122 comparison value(double word) Workpiece 2 departure HD124 HD126 HD128 comparison value(double word) Workpiece 3 entry HD130 HD132 HD134 comparison value(double word) Workpiece 3 departure HD136 HD138 HD140...
  • Page 411 Forward X4 rising edge:5 X4 rising edge:5 X4 rising edge:5 index value X4 falling edge:6 X4 falling edge:6 X4 falling edge:6 M10 rising edge:5 M11 rising M12 rising edge:5 Follow edge:5 index value M10 falling edge: M11 falling edge: M12 falling edge: Workpiece Entry HD130=5200...
  • Page 412 This chapter mainly introduces XD/XL series PLC common questions and answers. Q1:How to connect PLC with PC? A1:XD series PLC with firmware version V3.2 or later supports USB port, COM1 port (RS232), and COM2 port (RS485) to connect. Ethernet PLC also supports Ethernet port (RJ45) to connect.
  • Page 413 If the notebook does not have 9-pin serial port, users can use USB converter to realize connection between PLC and notebook USB port. Make sure to install USB converter drive software (Xinje special USB converter module COM-USB is recommended,USB converter drive software can be downloaded on Xinje official website)! 3.
  • Page 414 4.Connect via RJ45 port 1)Computer configuration After the network cable is plugged in, open "control panel" → "network and Internet" → "network connection". Find the Ethernet that has been successfully connected. Right click the Ethernet and click properties. The Ethernet properties interface pops up. Then follow the steps below: (1) Double click "Internet Protocol Version 4 (TCP/IPV4)".
  • Page 415 At first, use Xinje XVP cable to connect PC and PLC; After confirming the connection cable is the Xinje special XVP cable and USB convertor has been used, you can use it to try to connect desktop PC with 9-needle serial port to PLC. If the desktop PC can be connected correctly, please change the USB converter cable with higher performance or install the USB converter serial driver software again.
  • Page 416 Click ‘Stop when PLC reboot’ from the drop-down menu; Following window will jump out; By this time, cut off PLC power for 2-3s and power on again, then a ‘PLC has been stopped successfully’ window will normally jump out; if the window do not jump out after power on, try again a few times until the information window of successful stop jump out.
  • Page 417 ‘XD series PLC download program tool’ and ‘system file’ (*.sys file) Close all the programs which may occupy the serial port Cut off the power of PLC, open the XD series update tool (if user use this tool at the first time, please open the enrollment first)
  • Page 418 Click "Open File", choose the PLC model for updating.(Note: XD3_16.sys fit for PLC model XD3-16, XD3_60.sys fit for PLC model XD3-32 and XD3-60): Set the parameters:...
  • Page 419 Click “set parameter”, it will show the parameter window: Note: set the com port, the baud rate is default setting, no need to change. Click “download”, the window will show below words:...
  • Page 420 Power on the PLC, the update tool will show below words: Cut off the power of PLC, connect the short jumper, then power on the PLC again. PLC start to update, the updating will take few minutes.
  • Page 421 After finishing the update, cut off the PLC power, take off the short jumper, then power on the PLC again. PLC hardware version The PLC hardware version can be seen in “CPU detail” on the left window in XDPpro software (PLC online status)
  • Page 422 Short jumper XD, XL series PLC no need to short the jumper when updating. Note: Do not cut the power of PLC when it is updating. If it show the error “send data failed, ID not match…) please contact us for help. The PLC program will be deleted after updating.
  • Page 423 Q5: What’s the use of execution instruction LDD/OUTD etc? When PLC executes program, state of input point state will map to image register. From then on, PLC will refresh input state at the beginning of every scan cycle; if we use LDD instruction, then the state of input point will not need map to image register;...
  • Page 424 M0 is ON, Y will keep outputting ( S ) M1 is ON, Y0 is OFF ( R ) Q8: Check and change the button battery in the PCB of PLC The rated voltage of button battery is 3V. The voltage can be measured by multimeter. If the value of power-loss retentive register is very large, it means the battery is low.
  • Page 425 running inside PLC. Contact us for help. 1. PLC input power supply has Check the input power supply of Three LED all OFF short circuit PLC. Contact us for help. 2. PLC power PCB damaged 1. PLC input voltage is not Check the power supply voltage, stable check if there is dead loop in the...
  • Page 426 Q14: Why data errors after using DMUL instructions? A14: DMUL operation instruction is 32 bits*32 bits=64 bits operation, the result occupies 4 words, such as: EMUL D0 D2 D10, two multiplier both are 32bit (D1,D0) and (D3, D2), the result is 64 bits (D13, D12, D11, D10), so D10~D13 will be occupied.
  • Page 427 Q18: C language advantages compared to ladder chart? A18: (1) XD/XL series PLC supports almost all C language functions. When it comes to complex mathematical operations, the advantage of C language is more obvious. (2) Enhance the confidentiality of the program (when using file-advanced storage mode, C language can not upload);...
  • Page 428 Q23: What’s the advantage that XD series PLC replaces DVP download cable with Bluetooth? A23: XD series PLC Bluetooth function can perform PLC program download and upload, monitor and Twin configuration software online simulation. The Bluetooth can replace the cable to transfer the data.
  • Page 429 Sometime the PLC I/O terminals are broken. User don’t have to change the program, PLC I/O terminal exchanging function can solve the problem. User can exchange the terminal through XINJE Touchwin HMI. Open Touchwin software, jump to screen no. 60004 (X terminals) or screen no. 60005 (Y terminals) to set the I/O exchanging.
  • Page 430 Q26: How does XD/XL series PLC connect to the network? A26: XD/XL series PLC can connect to network by Xinje T-BOX, G-BOX, W-BOX, S-BOX, A- BOX expansion modules or expansion BD boards which have their own communication characteristics. Details please refer to the user manual of communication module or BD board.
  • Page 431 Click “Modify reg comment” to add element notes in below window: Line note Line note starts from “;”. Double click the line, then input semicolonand the contents.
  • Page 432 Q28: Do not have clock function?Why is the clock inaccurate? A28: XD/XL series PLC clock function is optional, and if you want to buy the PLC with clock function, please confirm when purchasing. Otherwise, the default PLC when it leaves factory does not have clock function.
  • Page 433 Appendix Special soft components Appendix mainly introduces the functions of XD/XL series PLC special soft element, data register, FlashROM and the address distribution of expansions for users to search. Appendix 1 Special Auxiliary Relay Initial Status(SM0-SM7) Function Description Coil ON when SM000 keeps ON SM000 running...
  • Page 434 0.5s SM013 1s frequency cycle 0.5s SM014 1min frequency cycle Mark(SM20-SM22) Function Description SM020 Zero bit SM020 is ON when plus/minus operation result is 0 SM021 Borrow bit SM021 is ON when minus operation overflows SM022 Carry bit SM022 is ON when plus operation overflows PC Mode(SM30~M34) Function Description...
  • Page 435 Interruption ban(SM50-SM90) Address Function Description SM050 I0000/I0001 Forbid input interruption 0 After executing EI instruction, SM051 I0100/I0101 Forbid input interruption 1 the input interruption couldn’t SM052 I0200/I0201 Forbid input interruption 2 act independently when M SM053 acts, even if the interruption is I0300/I0301 Forbid input interruption 3 allowed.
  • Page 436 Address Function Note SM110 HSC0 direction flag SM111 HSC2 direction flag SM112 HSC4 direction flag SM113 HSC6 direction flag SM114 HSC8 direction flag SM115 HSC10 direction flag SM116 HSC12 direction flag SM117 HSC14 direction flag SM118 HSC16 direction flag SM119 HSC18 direction flag High speed counter error(SM120-SM129) address...
  • Page 437 Communication(SM140-SM193) Address Function Note Serial SM140 Modbus instruction execution When the instruction starts to port 0 flag execute, set ON When execution is complete, set SM141 X-NET instruction execution When the instruction starts to flag execute, set ON When execution is complete, set SM142 Free format communication When the instruction starts to...
  • Page 438 port 5 SM191 X-NET instruction execution Same to SM141 flag SM192 Free format communication Same to SM142 sending flag SM193 Free format communication Same to SM143 receive complete flag Sequence Function BLOCK(SM300-SM399) Function Description SM300 BLOCK1 running flag SM300 will be ON when block1 is running SM301 BLOCK2 running flag SM301 will be ON when block2 is running...
  • Page 439 Error Message(SM450-SM463) Function Description SM450 System error check SM451 Hardfault interrupt flag …… SM453 SD card error SM454 Power supply is cut off SM455 Power down keeps data error SM456 Online download error flag bit …… SM460 Extension module ID not match SM461 BD/ED module ID not match SM462...
  • Page 440 SD018 Year (clock) 2000~2099 (BCD code) SD019 Week (clock) 0(Sunday)~6(Saturday)(BCD code) Flag (SD020-SD031) Function Note SD020 Model type SD021 model(low-8)series(high-8) SD022 Compatiable system version(low)system version(high) SD023 Compatiable model version(low)model version(high) SD024 Model info SD025 Model info SD026 Model info SD027 Model info SD028 Suitable software version...
  • Page 441 SD108 Current segment (No. n segment) HSC16 SD109 Current segment (No. n segment) HSC18 High speed counter error(SD120-SD129) Function Note SD120 HSC0 error info HSC2 error info SD121 HSC4 error info SD122 HSC6 error info SD123 HSC8 error info SD124 HSC10 error info SD125 HSC12 error info...
  • Page 442 SD144 Free format In bytes, there are no start and stop communication receive characters data numbers …… SD149 SD150 Modbus read write 0: correct instruction execution 100: receive error result 101: receive overtime 180: CRC error 181: LRC error 182: station error 183: send buffer overflow 400: function code error 401: address error...
  • Page 443 3: receive CRC error SD162 Free format 0: correct communication send 410: free format send buffer result overflow SD163 Free format 0: correct communication receive 410: send data length overflow result 411: receive data short 412: receive data long 413: receive error 414: receive overtime 415: no start character 416: no end character...
  • Page 444 Error Check(SD400-SD413) Function Note SD400 Extension module no. of SD401 communication error Means module no.n is error BD/ED module no. of SD402 communication error SD403 FROM/TO error type SD404 PID error type SD405 No user program SD406 User program error type SD407 SSDF error type SD408...
  • Page 445 SD456 SD460 Extension module ID not match SD461 BD/ED module ID not match SD462 Extension module communication overtime SD463 BD/ED module communication overtime SD464 Communication data overflow of expansion module number SD465 BD/ED module number communication data overflow Expansion Modules, BD Status(SD500-SD516) Function Description Module number...
  • Page 446 write SD864 Error times of module read Module address error. Module accepted data length error. Module CRC parity error when PLC SD865 Error types of module read is accepting data. Expansion Module ID error. module 2 Module overtime error. Error times of module SD866 write Error types of module...
  • Page 447 Maximum BD1 read/write SD944 duration SD945 BD1 read/write error times Total number of BD2 read SD946 and write (low16 bits) Total number of BD2 SD947 reads and writes (high16 bits) Version info(SD990~SD993) Function Explanation Note SD990 Firmware version date Low 16-bit Firmware version SD991 High 16-bit...
  • Page 448 HSD105~HSD109 Article 6 error message (1) XDC series PLC only supports the HSD110~HSD114 Article 7 error message storage of 4 error history messages; (2) This function requires programming HSD115~HSD119 Article 8 error message software version v3.5.3 (20190326) and HSD120~HD124 Article 9 error message above.
  • Page 449 0: the system clears it; 1: No processing. Bit1: Execute user program in external interrupt subroutine. 0: execute in task; 1: Execute in interrupt (in this mode, the user interrupt subroutine cannot contain C language function block). This mode is generally used in occasions that require high real-time performance of external signals.
  • Page 450 0: rising edge count, HSC2 single phase counting SFD311 1: Falling edge count, edge configuration 2: Both rising and falling edges are counted 0: rising edge count, HSC4 single phase counting SFD312 1: Falling edge count, edge configuration 2: Both rising and falling edges are counted 0: rising edge count, HSC6 single phase counting SFD313...
  • Page 451 SFD360 Extension module configuration Configuration of Extension Module 2 SFD369 SFD500 Configuration of Extension Module Extension module configuration SFD509 SFD510 BD module configuration Configuration of BD Module 1 SFD519 SFD520 BD module configuration Configuration of BD Module 2 SFD529 SFD530 ED module configuration Configuration of ED Module 1 SFD539...
  • Page 452 Appendix 4 PLC resource conflict table When PLC is used in practice, conflicts may arise because some resources are used at the same time. This section will list the resources that may cause conflicts in each PLC model. This part mainly refers to high-speed counting, accurate timing and pulse output. Accurate timing High speed counting Pulse output...
  • Page 453 HSC6 HSC4 HSC2 HSC0 ET10 ET12 ET14 ET16 ET18 ET20 ET22 ET24 ※1:This form should be read horizontally. Any two resources in each row cannot be used at the same time. Otherwise, it will cause conflict. Appendix 5 PLC function configuration list This part is used to check each model’s configurations.
  • Page 454 HSC channel Pulse output RJ45 Extension Extension Left External Single/AB phase (T/RT) Model port port port port module extension ED interruption Differential normal Differential XD5-24 × × × XD5-32 × × × XD5-42 × × × XD5-48 × × × XD5-60 ×...
  • Page 455 HSC channel Pulse output RJ45 Extension Extension Left External Single/AB phase (T/RT) Model port port port port module extension ED interruption Differential normal Differential XDH-60A32 × × × XDH-60T4 × × × XL1 series XL1-16 × × × × × ×...
  • Page 456 WUXI XINJE ELECTRIC CO., LTD. No.816, Jianzhu West Road, Binhu District, Wuxi City, Jiangsu Province, China Tel: 400-885-0136 Fax: 86-510-85111290 Wechat ID Email: fiona.xinje@vip.163.com www.xinje.com...