MOULDLKnowledge BaseElectrical Knowledge Base3D Model DownloadsMembership
中文版Model Store »
Knowledge Base › Electrical Knowledge Base › How do you use the index registers V and Z on a Mitsubishi PLC?
HomeModels
Table of contents

On this page

PLC & Programming (100 articles)

Quick Reference

  • PLC & Programming
  • Electrical & Electronic Basics (monthly)(每月更新中)
  • Electrical Control & Drawings (monthly)(每月更新中)
  • Drives & Actuators (monthly)(每月更新中)
  • Sensors & Detection (monthly)(每月更新中)
  • Industrial Communication & Networks (monthly)(每月更新中)
  • HMI & Host Systems (monthly)(每月更新中)
  • Industrial Robots & Motion Control (monthly)(每月更新中)
  • Mechatronic System Integration (monthly)(每月更新中)
  • Fault Diagnosis & Standards (monthly)(每月更新中)

How do you use the index registers V and Z on a Mitsubishi PLC?

V and Z hold an offset that is added to a device number: writing D100Z0 accesses the register whose number is D100 plus the value in Z0. That lets one instruction walk across an entire block of data, which is a great convenience for recipe switching, moving multi-axis parameters and table lookups. On the FX series there are normally eight of each, V0 to V7 and Z0 to Z7, all 16-bit, and they are used in pairs for 32-bit operations.

Indexing changes the device number, not the data

An index register does not alter data, it alters the number of the device being accessed. If Z0 in MOV K10 D0Z0 holds 5, the value is written to D5, not to some bit of D0. Every change in the index value therefore points the same line of program at a different device. Numeric constants K and H cannot be indexed, and the constant part of an instruction is never shifted. Once this is clear, the classic symptom of a wrong index — an action appearing on the wrong station — explains itself.

What can be indexed, and how the numbering works

X inputs are numbered in octal, while Y, M, S, T, C and D are numbered in decimal; indexing a T or C shifts its own device number, with the contact and the time base following along, rather than shifting its present value. Digit-designated bit groups such as K1X0 and K4Y0 can be indexed too, and it is the head number that moves. The result must land inside the valid range of that device; when it does not, behaviour is model dependent — an operation-error flag may be set, or invalid data may be read — so work out the upper and lower limits first.

Pairing V with Z for 32-bit work

A 16-bit instruction uses one index register, but a 32-bit instruction such as DMOV or DADD treats V and Z together as a 32-bit pair. Which of the two holds the high word, and how the numbers correspond, is not written identically in every manual, so check the manual for the model at hand rather than relying on memory. Once the pair is in use for a 32-bit value, neither half can be used independently for 16-bit indexing without the two pieces of logic interfering with each other.

Out-of-range values and clearing

The legal range of the index value is set by the device being indexed: D can run from 0 up to the highest D number of that model, and the same applies to M and Y. Loops, accumulators and table scans must clamp the index between an upper and a lower limit with comparison instructions, or wrap it with modulo arithmetic, so that an overflow cannot escape into the neighbouring area. An index register is not reset when a program block ends, so a value left behind by earlier logic is carried forward; clear it when it is no longer needed, or write an explicit preset before use.

Three typical applications

Recipe switching is the most common one: multiply the recipe number by the words per recipe, put the result in Z, and a single MOV picks up the first register of that recipe group, so changing recipes means changing one number. The second is table lookup: put the lookup value in Z and read the matching entry straight out of the table, far shorter than a chain of comparisons. The third is moving multi-axis parameters: put the axis number in Z, align the parameter blocks to a fixed length, and one BMOV transfers a whole set into the positioning module.

How index registers are used, device by device

DeviceExampleWhat is actually accessedNumber base and ruleTypical use
D data registerD100Z0The register numbered 100 plus Z0Decimal, must not pass the last numberRecipe switching, table lookup
M internal relayM50Z0The bit numbered 50 plus Z0DecimalAddressing status bits by number
Y outputY10Z0The output after a decimal offsetDecimal; note that X is octalSelecting station outputs
X inputX0Z0The input after an octal offsetOctal, counted in pointsScanning inputs across stations
T timerT0Z0The timer at the shifted numberContact and time base shift togetherBatch timer parameters
C counterC0Z0The counter at the shifted numberKeep 16-bit and 32-bit numbering apartMultiple counting channels
Digit bit groupK4Y0Z0A 16-bit group from the shifted headThe offset moves the head numberDigit display, output word
Constants K and HNot indexableCannot be offsetThe constant part is fixedRoute through a data register
32-bit pairDMOV D0Z0 D100Two words accessed with a 32-bit offsetV and Z paired; check the manual for order32-bit counts and position values
Positioning module bufferTO with an indexData taken from the shifted blockThe offset must stay inside the parameter tableMoving multi-axis parameters

Notes

Indexing pays off when the same sequence of actions has to be repeated over many data sets. Once the data is arranged as equal-length, consecutive blocks with aligned heads, one indexed instruction replaces dozens of copied rungs. The price is readability: the specific device number is not visible on screen, and to find out where a line currently points you have to read the index value in monitor mode. If the table structure ever changes, every program block that depends on the offset has to change with it, so write the block length and head as constants or in the comments.

References

The number, width and combination rules of index registers with instruction operands form part of the programming system definition; see GB/T 15969.3 and IEC 61131-3 on directly represented variables and indirect addressing, with the exact device ranges as given in the Mitsubishi programming manual for the model concerned. Device numbering and graphical symbols follow GB/T 4728. Connection, protection and earthing of the PLC and its circuits follow GB 5226.1 and IEC 60204-1; general equipment requirements are given in GB/T 15969.2.

Points to watch

⚠️ Three common traps:
(1) Leaving the index value unclamped, so one step too many in a loop offsets into the neighbouring block and rewrites other parameters with nothing visible on site;
(2) Using one half of a 32-bit pair for 16-bit indexing as well, so the two pieces of logic overwrite each other and position values occasionally jump;
(3) Treating X devices as decimal when they are octal, so the offset crosses into numbering that does not exist by the eighth point.

Any index that can influence an output, a position or a safety action must be range-checked before use, and on an out-of-range value the fault bit should be set and the related action stopped. When commissioning indexed logic, first run it with a fixed offset to confirm the pointers, then let the loop run free. Record the table head, length and step in both the program comments and the drawings so that someone changing the table later does not forget to change the offset.

Related reading

Related 3D models: Ready to build it? Download free 3D models & CAD drawings at MOULDL »
MOULDL · Electrical Knowledge Base · free self-study reference for electrical & automation engineers, 3D CAD models at MOULDL