User Manual
PD42-1240 TMCL
™
Firmware Manual • Firmware Version V1.45 | Document Revision V1.02 • 2018-DEC-03
82 / 132
3.6.41 DJNZ (Decrement and Jump if not Zero)
Decrement a given user variable and jump to the given address if the user variable is greater than zero.
This command can for example be used to easily program a counting loop, using any user variable as the
loop counter. This command is intended for standalone operation only.
Internal function:
The user variable passed to this command is decremented. If it is not zero then the
TMCL program counter is set to the value passed to this command.
Related commands: JC, WAIT, CSUB.
Mnemonic: DJNZ <var>, <label>
Binary Representation
Instruction Type Motor/Bank Value
49 <user variable> (0. . . 255) 0 (don’t care) <jump address>
Example
A counting loop in TMCL, using user variable #42:
SGP 42, 2, 100
2
Loop:
MVP ABS , REL , 51200
4
WAIT POS , 0, 0
WAIT TICKS , 0, 500
6
DJNZ 42, Loop
Binary form of the DJNZ 42, Loop command when the label Loop is at address 1:
Binary Form of DJNZ Loop (as-
suming Loop at address 1)
Field Value
Target address 01
h
Instruction number 31
h
Type 64
h
Motor/Bank 00
h
Value (Byte 3) 00
h
Value (Byte 2) 00
h
Value (Byte 1) 00
h
Value (Byte 0) 01
h
Checksum 97
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved.
Download newest version at www.trinamic.com