Jump to content
OMRON Forums

Is there a way to find the index of the PLC a subroutine is being called from?


maxvoxel8
 Share

Recommended Posts

I ask because we've been using Sys.CdTimer as recommended in the manual and we realized that there could be race conditions if a subroutine using a given timer is being called from multiple PLCs. So ideally we would use a different timer based on which PLC we are being called from.
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Here's a sample subroutine that worked for me. It should show you the concept at least.

 

open subprog SetTimer(TimerStart)

local idx;

idx = 0;

while (idx < 32)

{

Ldata.GoBack=32;

if (Plc[idx].Active == 1)

{

Sys.CdTimer[idx] = TimerStart;

idx = 32;

}

else idx++;

}

close

Link to comment
Share on other sites

This gives me the index of the first active PLC, not necessarily the one the code is being called from. I thought maybe Plc.Running would work, but for some reason it refuses to let me evaluate this. It says "Error : ( error #31) invalid parameter number in conditional : if (Plc[L0]. 4 == 1)" on build and download, or ILLEGAL CMD: Plc[6].4 on the command line. This seems like a bug.

 

What works for me is testing Plc[idx].Ldata.Address == Ldata.Address with the rest of the code the same.

Link to comment
Share on other sites

Ah, yes, the default NC UI machine state Running #define. When I get rid of that, yes, Running has the same issue. What I would need is a property that says the Plc is currently in a scan. But the Ldata.Address approach seems to work.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...