Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selecting M variable for User Pointer
Lets say I have the following ptr definition:

ptr valve1->PowerBrick[0].GpioData[0].16.1;

If I want to manipulate that IO port in the NC interface I need to figure out which M variable the pointer is stored in and then create a Device Member with that M variable as the getter and setter.

Now if I build the code on slightly different hardware or with a slightly different configuration then that M variable number will change. Is there any way for me to select the number that the pointer will be stored under, so I can make sure my code works in different configurations?

If not, is there any way for me to manually define a P variable that points to the pointer? (i.e. P8001 -> addressOf(valve1))

NOTE: I know it is possible for me to define the getter/setter in the devices.xml and then make a custom xml file for every machine, I am trying to avoid having to do that.
You can define the M-variables directly instead of making them user-named pointers..


Keep in mind the way your project maps and defines the M-variables. By default, this mapping starts at M8192, so any M-variable below that can be used without it being overwritten once the ptr's are mapped. You can check this in the Properties of your project in the Solution Explorer.
I would use a group of P-Variables (verify they are unused in any other portion of the project) and use those in the NC interface as control bits. Then I would create a new control PLC which turns ON/OFF the actual hardware outputs based on those bits.

This way you can have a single location where the action (On/Off) happens. Then you can also use M-Codes (not to be confused with m-variables) to also write to those same control p-variables to control the I/O from your G-code program.

This way you have one location for logic which actually controls the I/O and you can set commands from wherever to control those outputs (HMI button, M-Code, other logic, etc.). Be sure to use #defines with actual P-variables, and not the auto assign 'Global' method to insure your HMI and pmac script code are locked together.

Forum Jump:

Users browsing this thread: 1 Guest(s)