Interrupts

Interrupts are signals sent by the controller to the PC when certain events occur. They are used as logical switches to direct the flow of execution based on what is happening. They are the only mechanism with which the controller is communicating and commanding execution to the Host PC.


When to use Interrupts – You will want to use Interrupts when you have need of specific execution based on signals received from the application. Most commonly, you will execute a block of code when the event occurs. Occasionally, you will use interrupts to exit a block of code that you have been iterating on.


Diagnosis your Interrupts – At times, you will desire more than just execution based on an interrupt event. You can use InterruptSourceNameGet, InterruptSourceNumberGet, and InterruptSampletimeGet to get information about interrupts.


Unhandled Interrupts – In many cases, you will only be waiting for specific interrupts such as MOTION_DONE. When interrupts are enabled, the lions share is largely unneeded and left unhandled. These do not affect the execution of code unless watched for and handled.


Code Example – Enabling Interrupts: <- Enable Interrupts for this application. -> // controller->InterruptEnableSet(true);


Code Example – Holding Execution until Condition is met: <- Wait (sleep) until motion done interrupt occurs. -> // while (axis->InterruptWait(RSIWaitFOREVER) != RSIEventTypeMOTION_DONE) { } <- Shutdown the axis. -> // axis->Abort(); axis->ClearFaults(); axis->AmpEnableSet(false);


Code Example – Continue Execution unless Condition occurs: <- Command an axis to a trapezoidal move. -> // axis->MoveTrapezoidal(POSITION, VELOCITY, ACCELERATION, DECELERATION);


<- The following while loop will hold further execution until motion is done. -> while (axis->InterruptWait(RSIWaitFOREVER) != RSIEventTypeMOTION_DONE) { Printf(“Moving towards Relative Position.\r”); }


Code Example – Diagnosing an Interrupt: long interruptType; <- Wait for an interrupt. -> // interruptType = controller->InterruptWait(TIMEOUT);


printf(“IRQ ld
”, interruptType); printf(“s
”, controller->InterruptNameGet()); printf(“InterruptSourceNumber=ld
”, controller->InterruptSourceNumberGet()); printf(“InterruptSampleTime = ld
”, controller->InterruptSampleTimeGet()); printf(“
”);


The following are Interrupts used with Rapidcode… RSIEventTypeAMP_FAULT Amp Fault. RSIEventTypeHOME Home. RSIEventTypeLIMIT_ERROR Position Error Limit. RSIEventTypeLIMIT_HW_NEG Hardware Negative Limit switch. RSIEventTypeLIMIT_HW_POS Hardware Positivie Limit switch. RSIEventTypeLIMIT_SW_NEG Software Negative Limit. RSIEventTypeLIMIT_SW_POS Software Positive Limit. RSIEventTypeENCODER_FAULT Encoder fault. RSIEventTypeMOTION_DONE Motion Done (settled). RSIEventTypeMOTION_AT_VELOCITY At velocity. RSIEventTypeRECORDER_FULL Recorder full. RSIEventTypeRECORDER_DONE Recorder done. RSIEventTypeLIMIT_USER0 User Limit 0. RSIEventTypeLIMIT_USER1 User Limit 1. RSIEventTypeLIMIT_USER2 User Limit 2. RSIEventTypeLIMIT_USER3 User Limit 3. RSIEventTypeLIMIT_USER4 User Limit 4. RSIEventTypeLIMIT_USER5 User Limit 5. RSIEventTypeLIMIT_USER6 User Limit 6. RSIEventTypeLIMIT_USER7 User Limit 7. RSIEventTypeLIMIT_USER8 User Limit 8. RSIEventTypeLIMIT_USER9 User Limit 9. RSIEventTypeLIMIT_USER10 User Limit 10. RSIEventTypeLIMIT_USER11 User Limit 11. RSIEventTypeLIMIT_USER12 User Limit 12. RSIEventTypeLIMIT_USER13 User Limit 13. RSIEventTypeLIMIT_USER14 User Limit 14. RSIEventTypeLIMIT_USER15 User Limit 15. RSIEventTypeMOTION_OUT_OF_FRAMES Out of frames. RSIEventTypeIN_POSITION_COARSE In Coarse Position. RSIEventTypeIN_POSITION_FINE In Fine Position. RSIEventTypeSETTLED Settled. RSIEventTypeAT_TARGET At Target. RSIEventTypeFRAME Frame Event. RSIEventTypeSYNQNET_DEAD SynqNet Dead. RSIEventTypeSYNQNET_RX_FAILURE SynqNet Rx Failure. RSIEventTypeSYNQNET_TX_FAILURE SynqNet Tx Failure. RSIEventTypeSYNQNET_NODE_FAILURE SynqNet Node Failure. RSIEventTypeSYNQNET_RECOVERY SynqNet Recovery event. RSIEventTypeSQNODE_IO_ABORT SqNode I/O Abort Event. RSIEventTypeSQNODE_NODE_DISABLE SqNode Node Disable. RSIEventTypeSQNODE_NODE_ALARM SqNode Node Alarm. RSIEventTypeSQNODE_ANALOG_POWER_FAULT SqNode Analog Power Fault. RSIEventTypeSQNODE_USER_FAULT SqNode User Fault. RSIEventTypeSQNODE_NODE_FAILURE SqNode Node Failure. RSIEventTypeTIMEOUT Interrupt Wait timeout.