Suppose I want to be notified when an axis/multiaxis gets a limit error (exceeds position error exceeds
ErrorLimitTriggerValueGet()). Can I turn on the
RSIEventTypeLIMIT_ERROR interrupt mask and receive an interrupt?
Which object(s) do I need to enable this on? Both the
MotionController and the
Axis? Only the axis? Do (or can) all the interrupts come in through the motion controller’s
InterruptWait() method or do I have to check on each object, too?
I’m not seeing an interrupt like this when I’ve set this via
InterruptMaskOnSet() and retrieved interrupts via
MotionController::InterruptWait(). There aren’t examples of doing this, so I’m trying to make an educated guess (but seem to be doing it wrong).
I found this in our automated tests. I believe it achieves what you are trying to do.
Hopefully this can be a use full example for you for now.
public void InterruptTestPositionLimit()
const int moveid = 1234;
Assert.AreEqual(moveid, axis.MotionIdGet(), "Motion ID not equal, this is a problem");
Console.WriteLine("MotionId is set to: " + moveid);
// move 30 counts in about one second
axis.MoveTrapezoidal((axis.CommandPositionGet() + 30), 1000, 1000, 10000);
Assert.AreEqual(moveid, axis.MotionIdExecutingGet(), "We commanded a motion with this ID, it should be executing.");
bool gotLimitError = false;
bool done = false;
RSIEventType myInterrupt = axis.InterruptWait(4000);
if (myInterrupt == RSIEventType.RSIEventTypeLIMIT_ERROR)
gotLimitError = true;
if (myInterrupt == RSIEventType.RSIEventTypeMOTION_DONE)
done = true;
Console.WriteLine("Axis Interrupt Test -- Got Motion Done");
Console.WriteLine("InterruptMotionId = " + axis.InterruptMotionIdGet());
Assert.That(moveid, Is.EqualTo(axis.InterruptMotionIdGet()), "Interrupt Motion ID does not match set value!");
else if (myInterrupt == RSIEventType.RSIEventTypeTIMEOUT)
done = true;
Console.WriteLine("InterruptTest failed with TIMEOUT");
Assert.Fail("InterruptTest failed with TIMEOUT");
Console.WriteLine("Axis IRQ " + myInterrupt);
Console.WriteLine("IRQ Type " + axis.InterruptNameGet());
Console.WriteLine("InterruptSourceNumber = " + axis.InterruptSourceNumberGet());
Console.WriteLine("InterruptSampleTimer = " + axis.InterruptSampleTimeGet());
// this added 20070808 -- failing with exception
Thanks for the good example.
Does this mean that I ought to spawn separate threads (one per axis, say) to wait for and handle these interrupts? I already have a thread that waits for interrupts on the motion controller, but I won’t see the axis interrupts, right?
Yes, ideally you would have a thread for each axis.
For the sake of offering constructive criticism, I did not find any clear direction about how to do this on the documentation portal. Here’s where I started looking:
Perhaps the problem is that I didn’t know where to start looking for information, but I couldn’t find any docs that provided any detail for the interrupt interface or how it worked. I suppose it’s a logical assumption to think that whatever object you
MaskSetOn(...) for would be the object that you
Wait() for, but I would prefer to have definitive answers as opposed to good guesses. (-8