Yaskawa
eLearning
You're watching the PLCopen Basics
Video Tutorial Series
This video shows how to Stop Motion
and how to Diagnose and Clear Alarms
Hi, I'm Matt Pelletier
We'll use three fundamental PLCopen
instructions in this section
those are MC_Stop, MC_Reset and MC_ReadAxisError
we'll also see how these tie-in
specifically to the Yaskawa servo hardware.
So here's the Program map as we're progressing
and it's time to add the Program POU called Stop
into the Slow Task of our project
you can work along with me here we'll just
right-click Insert a Program called Stop
get Ladder diagram language
we said we'd run it in this Slow Task
so right down here Insert > Program Instance
Stop and Stop
and let's open that Stop Program
and like we've done before with the other
Program POU's
we'll use the existing HMI_I
Toggle Boolean Interface to Stop
both the Screw and the Rotary Motor
at the same time.
MC_Stop is pretty straightforward
not really any fancy features
there's the Execute Input and the Decelerate
and we'll just Stop both Axes at the same time
so please go ahead and build this
and test it out
and then I'll do the same and demonstrate a few points.
Okay let's build a couple MC_Stops
MC_Stop for the Screw
and we'll use G_StopScrew
for that one
and we have somewhat of an arbitrary long
Decel time we'll call it StopDecel
it's just a Local VAR
and we'll give it a value of 1 million
that's one with six zeros
point zero because it's an LREAL
you can put these underscores in there
to hold the place value, OK
now the same thing for the Rotary Axis
Rotary
G_StopRotary these already exist from the HMI
POU
we'll use that same StopDecel
and you know as long as we're at it here
let's add one for the Virtual
MC_Stop
for the Virtual Axis
G_StopVirtual
and we'll use the same StopDecel
on here also
so that along with the HMI
looks like I had a G_StopVirtual but don't
have it in the code that's not too hard
you can right-click
if it's not in there I may end up dating it in there
add a Parallel Contact here
with this or this one Parallel
and we'll put in G_StopVirtual
to stop them all with one Input.
All right let's Download those changes
Okay now if we want to have something to Stop
we need to start it first
so I'll Start the Motion that we had before
and now let's see if we can
cancel it during one of the Moves
so there I stopped right during the Move
and you notice that it didn't finish the
Move like it did before when we just
turned off the Start Input.
Additionally, notice that if you try to restart the Motion
it cannot
Start OFF
Start ON
and in fact if you look at the Positioning POU
you'll see that it has an error
it can't start and we know I can't start
it can't start because the Stop Block is ON
and if you look at the Help
and scroll down
to the errors you'll see that 4370
says the Move could not be started
because Motion is prohibited
why could this be?
could not be Enabled
maybe the Stop execute is held high
because no other Block can override the Stopping State
and that's exactly what we're seeing happen here
is the Stop Block is on for that axis and
so we can't Start
so this is an important distinction because we had
said earlier that PLCopen activates at the Rising Edge
and while that is true
Stop is a special case where if it's Executing
no other Motion can be initiated on that axis.
Second part of this video is to both Read
and Reset Alarms that you might have
and so let's make another Program POU
called Reset
also in the Slow Task
we'll insert a new program called Reset
and add it to the Fast Task
insert a Program Instance, Reset
Reset, Reset
let's open that POU
and the HMI_I POU has coils
to reset the Screw, the Rotary in the Controller
so there's the two real axes and the controller
PLCopen covers Reading and Resetting the axes
and those are the MC_Reset MC_ReadAxisError
again very simple blocks you just give it the axis
and tell it whether it should Execute the Reset
or whether it should Enable the Reading of the error
we'll typically set that to True
if you just want that to constantly Read the error
and these will Read axis related errors like
Over-torque, Over-speed
but for controller related errors
such as a Battery Controller that's dead
or a network communication failure
and that's going to be here through the
Read Alarm and Clear Alarm
directly on the controller
and those are Y_ Blocks
so they're not part of PLCopen
but nonetheless it's a good time to introduce those
so like before why don't you go ahead
and enter this code in
and then we will work with it
and produce some Alarms and clear them.
So I've got an MC_Reset here
for the Screw Axis
and we'll tell that one here
to reset with G-Reset
to go down here to Reset Screw
put another one for the rotary
MC_Reset Rotary
Rotary
and that one's got a variable called G_Reset
down to Rotary
the counterparts to those are
MC_ReadAxisError
for the Screw Axis
and you could leave these Enabled
I could also see the wisdom in connecting this
Error Output to Enable only if
you do have an error
and ReadAxisError also
for the rotary
and then in case there's any problems with the controller
we have Y_ClearAlarms
that one can be executed with G_ResetController
and its counterpart is Y_ReadAlarm
we'll leave that one as True
and let's Download Changes for this one
so now the question becomes how can we test this
and one way to test this
is to set both your Speed and Distance
to an amount that's too high
and on these motors a 40_000 will be sufficient
but you have to set both Speed and Distance
and I'm recommend to do it in that order
so open up the Positioning POU
and let's set this Velocity to 40_000
and the Distance also to 40,000
and then we'll use the HMI here we'll remove the Stop
and Start it again
and you'll see that it kind of moved
but there's this alarm light out you can
kind of tell it's red
there's a Controller Alarm
definitely in the webpage
if you wanted to look at the Alarm Status
you could see that there is
an alarm A 510 that's Overspeed
if you still don't believe me you could look at
the servo itself it's flashing A.510
A510 so we've got an Overspeed A510
and we can confirm that here
in the Reset POU
but curiously it says that the error ID is 1296
and that's because it's displaying a
Hexadecimal Error Code
in decimal but we can to force this to display in
Hexadecimal just open any of these Variables
like maybe G_ResetScrew
and there's this value display
which can be forced to Hexadecimal
this is a software setting
and now we see in Hexadecimal 16#0510
with the ErrorClass 16#3303
and since I did have the webpage up
you'll see that those alarm codes are
are listed and there's even a Tooltip here
3303
so this is all vendor-specific
these codes themselves are up to Yaskawa
and there's two parts to the code
there's the AxisError and the ErrorClass
so one thing that I like to do
sometimes is not go to everything Hexadecimal
leave it in Standard
and then you can make a little modification
to this program we can convert these
AxisErrorID and ErrorClass
using the Type Convert functions
and if you hover on it it says here it's a UINT
and a UINT
so we can go here type U for UINT
UINT_TO_WORD because really the way that
Yaskawa alarms are defined are as WORDS
so we'll pull out a UINT_TO_WORD
okay, I have the EN/ENO
I'm going to go to the Objects Menu and turn that OFF
I can Update that function
and get a little room here
hit Control here and spawn a copy
and you could call this AlarmScrew
and this one
ErrorClassScrew
let's Download Changes
all right, so we still have this Alarm
and now in Debug Mode we'll see it
because the word Data Type defaults to Hex
but what we really do need to do here is to reset it
so let's prove that that works
by going to the ResetScrew
we reset them all at once
and did that reset anything?
It sure did that alarm is gone
we could even refresh the webpage
and the Alarm Status shows it's gone
of course the Alarm History shows that it did happen
and that's your basic functionality for
Reset and Reading Axis Errors
and now a little bit about Yaskawa going
beyond PLCopen
PLCopen uses the term Error
and Yaskawa it tends to use the
word instead Alarm and Warning
and so just to clarify what those terms mean
Alarm means that the servo will stop
because Motion cannot continue and the
and the servo will be disabled
and you'll have an Alarm Code starting with A
here's a few examples Overvoltage, Overspeed,
Overload, Encoder Overheat
there's a lot of different Alarms and you can
look at the Alarm Displays in Chapter 9
of the current Sigma 5 User Manual
but we have a lower level Warning code system
which tells you that there's a future Alarm
pending if you continue the current conditions
but at this time the Servo remains enabled
although you will get a code
starting with A.9 and two more digits
and a few examples here are
Position Error Overflow Warning or
Overload Warning or Command Warning
or an Undervoltage Warning
so we're warning you that an alarm will soon happen
so that you hopefully could
change the operating conditions from the
controller side and avoid this shutdown
for that axis when the alarm happens
and one final housekeeping order of business
is the Task Order
if you look at our SlowTask we've added quite a few of
these program POU's into the SlowTask
and it's time to really think critically
and logically about the order that these
POUs are in there
and if you look at the order we have it's really not
the most ideal
because while the commands
starts with the HMI we have that at the bottom
so it's not even looking for
the Inputs until the very end of the scan
it's really when I turn on one of
the inputs an HMI_I
it doesn't take effect until the next scan
so there could be a slight delay
so it's time that we do some reordering of it here
be sure you are out of Debug Mode
also please be sure that you close this resource
even if you have the resource open
good practice is to keep closing that thing
and we'll put the HMI_I
up at the top
and then maybe the next most important
thing is do we need to Stop?
and then perhaps the next most important thing is
do we need to Enable?
and if there's any problem maybe then Reset
so these are still cyclic, they're happening
every Slow Task cycle
but it makes a little more sense to put them in
an order like this than it does to have the
HMI inputs at the bottom
so this is a change to the code
you do need to Download Changes
Remake it and Redownload it
and with this simple code you
probably won't see any performance changes
but it brings up a few important
points like that you can easily drag and drop
these Task order and now we have a
more logical sequence within this code
where the Human touches the physical inputs
the Inputs are read by these assigned Tasks
and I know we don't have physical I/O
we're just clicking on the Global Variables
so with our setup we're starting right about here
but if you'd add the Real Inputs
you'd have to consider the Input modules also
and then finally writing the Globals
to actually do the Motion
so it should go in the correct order
and it's just a good practice to think about that
not just be blind to the order of the POUs
in your tasks.
So let's just wrap it up here and Save
a copy of this
as a Zip
that was number 7 Stop an Alarm
Zip it!
and that'll be it for this video.