Jump to content
OMRON Forums

UserAlgo.CaptCompIntr has no effect


zros
 Share

Recommended Posts

I am attempting to create a 'one-shot' Capture/Compare ISR. I have written the CaptCompISR(), and set UserAlgo.CaptCompIntr = 0 as part of my global definitions file. My expectation is that upon download, the ISR should not be called, even if the triggering conditions are met, since the UserAlgo.CaptCompIntr is set to 0. However, this is not what I am experiencing. As soon as I download the project to the PPMAC, I am seeing the effects of the ISR code. Specifically, the counter (sentinel, see code) value at Sys.Idata[65536] immediate starts counting up. I have placed the UserAlgo.CaptCompIntr in a watch window to verify that it is still set to 0.

 

Background: I am setting up a system that has an externally controlled motor driving an incremental quadrature encoder that I have wired into channel 0 of the the only ACC-24E3 card in my rack. I want to capture the encoder count at the positive index.

 

I want to capture the encoder count on just the first of 100's of index pulses that will occur. For now, I am just trying to get the ISR to run once, then disable itself. I have written a PLC to enable the ISR, but I don't even get to the point of running the PLC before the ISR starts running.

 

I have done 2 things that I think should disable the ISR or the interrupt that acts as the source for the ISR call. 1) I clear the Gate3[].IntCtrl register (after making this register writable). Specifically, I want the clear the LSB of the interrupt enable byte of this register. This should, I think, disable the Channel 0 PosCapt interrupt. 2) I also set the UserAlgo.CaptCompIntr to zero, which should prevent the ISR from being called, even if the interrupt occurs.

 

Finally, if I run the motor, I do get the *currentSpindlePos to change once every index pulse.

 

Any ideas on what I'm doing wrong? Or how best to go about debugging this?

 

My ISR code:

void CaptCompISR(void)

{

/* declare pointers/variables */

volatile GateArray3 *Gate3IC; // Gate pointer declared

int *currentSpindlePos; // pointer for position log of spindle encoder at trigger

int *sentinal; // declare pointer to an integer

 

/* initialize pointers */

Gate3IC = GetGate3MemPtr(0); // initialize pointer to Gate3[0]

currentSpindlePos = (int *)pushm + 65535; // Sys.Idata[65535] (initialize pointer)

sentinal = (int *)pushm + 65536; // Sys.Idata[65536] (initialize pointer)

 

/* functional code */

*currentSpindlePos = Gate3IC->Chan[0].HomeCapt; // log the position of the encoder

(*sentinal)++; // increment value at pointer

Gate3IC->WpKey = 0xAAAAAAAA; // unlock write-protection

Gate3IC->IntCtrl = 0; // disable further interrupts, SRM Pg 654, UM Pg 798

Gate3IC->WpKey = 0x0; // write-protect

pshm->UserAlgo.CaptCompIntr = 0; // disable future calls to this ISR (enable in a plc that triggers at M50)

}

 

My Global Definitions code:

Sys.Idata[65535] = 0 // initialize

Sys.Idata[65536] = 0 // initialize

Sys.Idata[65537] = 10 // initialize

Sys.Idata[65538] = 20 // initialize

EncTable[1].type=1

EncTable[1].pEnc = Gate3[0].Chan[0].ServoCapt.a

EncTable[1].pEnc1=Sys.pushm

EncTable[1].index1=0

EncTable[1].index2=0

EncTable[1].index3=0

EncTable[1].index4=0

EncTable[1].ScaleFactor = 1.0/256.0

EncTable[1].MaxDelta = 0

EncTable[1].SinBias = 0

EncTable[1].CosBias = 0

Gate3[0].Chan[0].CaptCtrl = 1 // 15 for index high and user flag // 1 for capture on index high only

Gate3[0].Chan[0].EncCtrl = 3 // x4 quadrature decode CW (use 7 for x4 with CCW)

Sys.WpKey = $AAAAAAAA

Gate3[0].IntCtrl = $10100 // enable interrupt and set source on Chan[0].PosCapt

Sys.WpKey = $0

UserAlgo.CaptCompIntr = 0; // disable capt/comp ISR

 

My one-shot PLC that I would run to enable the ISR, but I'm not getting that far...

open plc 4

Sys.Idata[65535] = Sys.Idata[65537] + 1 // initialize spindle capture

Sys.Idata[65536] = Sys.Idata[65538] + 1

UserAlgo.CaptCompIntr = 1 // enable capture/compare ISR

disable plc 4

close

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

This should not run if "UserAlgo.CaptCompIntr = 0". Note that having "start-up" settings in Global Script header files is not recommended especially any "Gaten" settings because of power-on timing differences. This is better done in a "start-up" plc that has better control over timing.

 

We would need to see the full project to better comment on your issue. Send this to support@deltatau.com.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...