Reading Clock data in Mitsubishi PLC
Understanding the TRD Instruction for Reading Clock Data
in Mitsubishi PLCs
In industrial automation systems, accurate time tracking and
synchronization are crucial for scheduling, logging events, and controlling
processes based on time. Mitsubishi PLCs (Programmable Logic Controllers) are
equipped with built-in real-time clocks (RTC) that allow users to store and
retrieve time-related data. One of the most useful instructions in Mitsubishi
PLC programming for reading time data is the TRD (Time Read)
instruction.
The TRD instruction is designed to read the clock
data from the built-in real-time clock in the CPU module and store it in
specific device locations for use in the PLC program. This instruction makes it
easy to access critical time-based information such as the current year, month,
day, hour, minute, second, and day of the week, allowing the PLC to operate
based on time-dependent logic.
How the TRD Instruction Works
The TRD instruction reads clock data from the CPU's
built-in real-time clock and transfers it to specific device numbers (d).
The clock data is retrieved in binary code format, and each data type
(year, month, day, etc.) is stored in a designated memory area. Below is a
detailed breakdown of the clock data that the TRD instruction retrieves:
Reading Clock Data (SD210 to SD216)
When the TRD instruction is executed, it stores the
clock data in a series of SD registers (System Data registers) within
the PLC. These registers store the real-time clock data in the following binary
format:
- SD210:
Year – The four-digit year data is stored in binary code.
- SD211:
Month – The month data (from 1 to 12) is stored in binary code.
- SD212:
Day – The day of the month (from 1 to 31) is stored in binary
code.
- SD213:
Hour – The current hour (from 0 to 23) is stored in binary code.
- SD214:
Minute – The minute data (from 0 to 59) is stored in binary code.
- SD215:
Second – The second data (from 0 to 59) is stored in binary code.
- SD216:
Day of the Week – The day of the week is stored as a binary code
(0: Sunday, 1: Monday, ..., 6: Saturday).
These registers represent the entire time and date
information in a binary format, making it easy to access and manipulate the
data within the PLC program. For example, if you need to trigger specific
actions based on the current day or time, you can use the values stored in
these registers.
FX3 Compatible Area (SD8013 to SD8019)
For users working with Mitsubishi’s FX3 series PLCs,
there is a different memory area for storing the clock data. The FX3
series uses the SD8013 to SD8019 range to store real-time clock data.
Here’s how the clock data is structured in this area:
- SD8013:
Second – The current second data is stored in binary code.
- SD8014:
Minute – The current minute data is stored in binary code.
- SD8015:
Hour – The current hour data is stored in binary code.
- SD8016:
Day – The current day of the month is stored in binary code.
- SD8017:
Month – The current month data is stored in binary code.
- SD8018:
Year – The current year data (four-digit format) is stored in binary
code.
- SD8019:
Day of the Week – The day of the week is stored in binary code
(0: Sunday, 1: Monday, ..., 6: Saturday).
This memory area allows you to retrieve the real-time clock
data on FX3 series PLCs in the same manner as with the standard
Mitsubishi PLC models, but it uses a separate register range for compatibility
with the FX3 architecture.
Practical Applications of TRD Instruction
The TRD instruction is incredibly useful in various
automation scenarios where time-based logic is needed. Some common applications
include:
- Time-Dependent
Control: You can use the clock data to trigger actions or change
settings based on specific times of day or certain days of the week. For
example, you might schedule machine operations to only run during working
hours.
- Event
Logging: The TRD instruction can be used to record timestamps for
events or alarms, allowing for better tracking of system behavior and
diagnostics.
- Time-Based
Interrupts: Certain processes may need to be paused or adjusted at
specific times. Using the real-time clock data, you can create time-based
interrupts or delays.
- Shift
Management: In manufacturing environments, the TRD instruction can
help manage shift changes, log working hours, and ensure equipment is
running according to a set schedule.
The TRD instruction in Mitsubishi PLCs is a powerful
tool for accessing real-time clock data from the CPU module, which is crucial
for time-dependent automation tasks. By reading the clock data into SD210 to
SD216 (or SD8013 to SD8019 in FX3 series), PLC programs can make
decisions based on the current time, date, and day of the week. Whether you’re
scheduling machine operations, logging events, or implementing time-based
control, the TRD instruction offers a simple and effective solution for
incorporating time-sensitive logic into your Mitsubishi PLC projects.
If you found this guide helpful, make sure to share it with
others who may benefit from understanding how to work with the TRD instruction
in their automation systems.