The
GSV and SSV instructions are the PLC getters and setters of the PLC and are part of the
Input / Output instruction group. Through them it is possible to get / set
system data such as time, scan times, failure status, among others. In this
post we will show some common applications.
Enabling
the PLC clock during the first scan and reading and writing of the date and
time:
Note:
A more elegant way to use the PLC_DateAndTime variables would be to create a
UDT of array of DINTs with size 7. The index (from 0 to 6) represents the Year,
Month, Day, Hour, Minute, Second and micro Second.
The
SSV EnableTimeSync command during the first scan of the PLC is used to enable /
disable (1/0) via LAD logic the PTP (Precision Time Protocol) protocol on the
PLC, which could also be enabled in the Controller Properties window Date /
Time tab by clicking on the "Time Sync" house Enable Time Sync. The
Attribute Name of GSV and SSV can be LocalDateTime or DateTime, according to
the time zone preference. This data can be seen in the Controller Properties
window Data / Time tab.
Another
function of GSVs is to alert Faults, which can be Major (non-recoverable,
for example CPU hardware failure (rare but it can happen), or recoverable that
needs to be reset on Studio 5000) or Minor (for example, electronic key error,
module not assembled correctly, GSV and SSV problems, connection timeout, among
others). Note: When Major Faults the PLC stops executing the program and the
outputs, the outputs are placed in the Program mode state.
In
the example below, GSV is used to alert if a Minor Fault event occurs,
accessing the FaultLog class and the MinorEvent and MinorFaultBits attributes.
It is noted that to decrease the load on the PLC with this routine, a TON timer
with preset of 1 minute was created, so the GSV is executed every minute
instead of every scan of the PLC.
Another
application is to record the scan times of programs, with the Task Class and
the selected instance, in this case the Main and the Motion Control Task,
selecting the desired MaxScanTime attribute in this case, and configuring the
destination, in this case an Array of DINTs.
The
Fault type can also be seen by clicking on the CPU properties and opening the
Minor Fault tab:
In
the Module object, it is possible to have the status of a module, such as
Running, Shutting Down, Waiting, applying a mask in the first 12 bits, that is,
considering only the last 4 bits of the 16 bits of an INT variable.
The
purpose of this post is to show some features of the GSV and SSV instructions.
There are several possible configurations and applications that can and should
be explored by the programmer.
No comments:
Post a Comment