Jump to content
OMRON Forums

Gate3 pointers and WpKey


daves

Recommended Posts

I was trying to use nice pointers directly:

 

ptr R1CaptCtrl->u.io:$908068.6.4; // Gate3[2].Chan[0].CaptCtrl

 

Is the following as expected? It doesn't explain this situation in the documentation that I can see, it only says you need to use the Gate structure in C code:

 

This doesn't work:

open plc 1
Sys.WpKey = $AAAAAAAA;
R1CaptCtrl = 2;
Sys.WpKey = $0;
disable plc 1;
close

 

This DOES work:

Gate3[2].WpKey = $AAAAAAAA;
R1CaptCtrl = 3;

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Daves,

 

Let me explain this by giving a bit of a background:

In C programs, it is code's/user's responsibility to set the Gate3.WpKey before writing to any protected registers or else the register stays unchanged.

In PMAC Script the same can be done, but in order to make life easier for the users, Sys.WpKey was implemented. In PMAC Script before a write to a GSPGate3 protected register, the contents of Sys.WpKey is copied into corresponding Gate3.WpKey. This ensures that the write process is authorized by the DSPGate3.

 

In your first example, the script doesn't know that you're writing to a DSPGate3 register since you're using a pointer and not a DSPGate3 structure. This means that the automatic write to Gate3.WpKey is not performed.

In the second example, you're performing the same step that the firmware would have done, had it known the target is a protected register in a DSPGate3, and that's why it is working.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...