Jump to content
OMRON Forums

RESOLVED - CaptCompISR freeze


Recommended Posts

Hi, this issue has been raised in this thread some years ago:




I applied the advises given there but could not improve the situation by that. However I discovered that the ISR does not crash anymore if I do read the Gate3[0].Chan[0].HomeCapt register while scanning for the first interrupt to start the motion. But because this is only a workaround I describe the problem I had.


I had the problem that while my program was running the ISR froze on random occasions. My Program consists of a motion from a) to b) getting repeated as many times as I like.

While the motor is jogging to position a) I have the CaptCompISR logging the position. The purpose of it is to check if the Motor was on the position corresponding to the number of the trigger that launches the ISR and then to induce a position correction if it isn't.

The position correction is calculated and induced by the custom phase algorithm assigned to Motor[0] while the Motion is carried out by Motor[1].

At first I had the code for storing the captured positon inside the ISR but moved it to the phasealgorithm in order to exclude it as a cause for the error and then moved back again.

I also made sure I had nothing else but "int"-variables in the ISR. If I iterated the motion loop 500 times the ISR froze at least 2 to 3 times. I could get it to work again by reading the "Gate3[0].Chan[0].HomeCapt" register from the terminal. I monitored the "Gate3[0].IntCtrl"-word and saw the "Gate3[0].Chan[0].Equ"-bit for turn high and low very often as my program was running. My first guess was that this was the cause for the freezing. Though the ISR did not always freeze when it turned high, every time it froze the bit was high. So I added some lines of code out of the Equ Compare example featured in the User's Manual which forces the Equ-State to zero. This had no effect on the freezing of the ISR. The only thing that made my ISR restart automatically was to read the "Gate3[0].Chan[0].HomeCapt"-Register from a plc. This too was not perfect because my Motion seemed to sometimes stop for 1/10 up to 5/10 of a second at the end of the move or just after having reached the starting position again, sometimes several times a row. Then again it ran smooth without pausing for while. I tried deactivating the Equ State inside the ISR and inside the plc but that too without effect. I had a plc runnning a code the guy posted in the old thread for making sure the Equ-state does not turn high, but that too did not have an effect.


I would be grateful for any further insights into this and would also like to know if there is a way to reliably stop the "Gate3[0].Chan[0].Equ"-bit to turn high.


This is the code I have in my ISR:


void CaptCompISR(void)



int MyFirstGate3Adr = pshm->OffsetGate3[0] ;


volatile int *MyFirstGate3IntCtrl = NULL ; // InCtrl direct register pointer declaration

MyFirstGate3IntCtrl = ( unsigned int * ) piom + ( ( MyFirstGate3Adr + 0x224 ) >> 2 ) ; // IntCtrl register adress calculation 4bytes Per Word



// Deactivate ISR

*MyFirstGate3IntCtrl = !( *MyFirstGate3IntCtrl | 0xffff00ff ) ; // ( NOR - Operation ) 24 Bit - Bit Nr.16 has to be set to zero

*MyFirstGate3IntCtrl = *MyFirstGate3IntCtrl | 0x00000001 ; // Clear interrupt source


int *CaptCounter = NULL ; // Logs number of triggers

CaptCounter = (int *)pushm + 60200 ;


volatile int *MyFirstGate3HomeCapt = NULL ; // HomeCapt direct register pointer declaration

MyFirstGate3HomeCapt = ( unsigned int * ) piom + ( ( MyFirstGate3Adr + 0x74 ) >> 2 ) ; // HomeCapt register adress calculation


int *CaptPosStore = NULL ; // Storage pointer

CaptPosStore = (int *)pushm + *CaptCounter + 65000 ;


// Determine Shared Memory-Pointer Adresses

int *StartScan_C = NULL ; // Pointer zum setzen des Flags für den Start der Scan-Fahrt

StartScan_C = ( int * ) pushm + 60100 ;


int *PulseInt_C = NULL ; // Switch for executing correction in PhaseRoutine

PulseInt_C = ( int * ) pushm + 60101 ;

*PulseInt_C = 1 ;


int *IsrCheck_C = NULL ;

IsrCheck_C = ( int * ) pushm + 60221 ;


(*CaptCounter)++ ; // Increment counter, starts at 0


(*IsrCheck_C)++ ; // Checking variable


if ( *CaptCounter != 0 ) *StartScan_C = 1 ; // Prompt plc 7 to start motion


Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic


It is the export of the UserShared Memory data that is causing these irregular pauses in the motion.

The only question left is why the source bit of the Gate3[0].Chan[0].Equ and Gate3[0].Chan[1].Equ output in the Gate3[0].IntCtrl-register flashes up

regularly when I do not use the inputs.

Link to comment
Share on other sites


I do only have to read the Gate3[0].Chan[0].HomeCapt - register once after having unmasked the CaptCompISR and enabled the UserAlgo.CaptCompISR.

Then it works reliably. Still the source and the enable bit of the Gate3[0].Chan[0].Equ output in the Gate3[0].IntCtrl-register flashes up regularly

Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...