LD / LDI · 6 min · Free exercise
LD and LDI: start a rung open or closed
Load and Load Inverse
Every rung needs a first contact. In Mitsubishi instruction list that first contact is written LD when the rung should pass while the device is on, and LDI when it should pass while the device is off.
What it does exactly
LD, short for Load, starts a rung with a normally open contact on the named device: the rung is true while the device is on. LDI, Load Inverse, starts the rung with a normally closed contact: the rung is true while the device is off. The device can be an input X, an output Y, an internal relay M, a timer or counter contact, or another bit device.
LD and LDI only begin a rung and read a device. The contacts that follow on the same rung are written with AND, ANI, OR and ORI, and the rung ends with an output instruction. A new LD or LDI starts the next rung, which is how a program with many rungs is written one after another.
The IEC and editor equivalent
LD X0 is the IEC normally open contact | GATE_OPEN |, and LDI X0 is the normally closed contact | NOT GATE_OPEN |. IEC Instruction List also uses LD, with LDN for the inverse.
What the scan does with it
The device value read by LD or LDI is the value at that moment of the scan, which for an input X is the image captured at the start of the scan. For an output Y written by a rung above, it is the new value.
LD X0 OUT Y0 LDI X0 OUT Y1
Common mistakes
- Starting a rung with AND or OR. The first contact of a rung is always a load instruction.
- Thinking LDI is "pressed". It means the device is off, so a normally closed limit switch wired to X0 reads on at rest.
What you can now do: You can start a rung with LD or LDI and pick the right one for the state you want to detect.