Jump to content
OMRON Forums

Programmatic Axis Definition


ricky_v8

Recommended Posts

I'm trying to define axis definitions in a way that allows me to use multiple machines that would traditionally have separate axis definitions. I'd also like to use the axis definitions to calculate scale factors. Initially I tried to use #if/#elif/#endif to #define relevant components of the axis definitions based on the machine, but the preprocessor doesn't perform macro expansion the way it does in the C preprocessor.

 

#define AXIS_BASE_COUNTS (1000)

#define X_AXIS_COMPENSATION (-0.5)

 

#1->(AXIS_BASE_COUNTS + X_AXIS_COMPENSATION)X

 

The axis definition gives an error when trying to download. Judging from the build output, it looks like the preprocessor is not doing macro expansion. Instead just does #1->((1000) + (-0.05))X. As expected, I get an error from that axis definition.

 

I then tried something slightly different, thinking the preprocessor might only allow a single #define in the axis definition, so

 

#define AXIS_BASE_COUNTS (1000)

#define X_AXIS_COMPENSATION (-0.5)

#define X_AXIS_DEF (AXIS_BASE_COUNTS + X_AXIS_COMPENSATION)

 

#1->(X_AXIS_DEF)X

 

I have the same problem with this approach.

 

Does anyone know if there is a way to conditionally or programatically do axis definitions? I can provide more and/or exact code if it helps.

 

Thanks in advance.

Link to comment
Share on other sites

An axis definition can contain only numeric literal arguments. After a definition is made you can modify the status elements of the motor’s axis-definition scale factor and axis offset:

 

Motor[x].CoordSf is the axis-definition scale factor. The value of “i” depends on the “axis name”. See the table in the “Power PMAC Software Reference Manual” under the description of Motor[x].CoordSf.

 

Motor[x].CoordSf[32] is the “axis offset” value.

  • Thanks 1
Link to comment
Share on other sites

An axis definition can contain only numeric literal arguments. After a definition is made you can modify the status elements of the motor’s axis-definition scale factor and axis offset:

 

Motor[x].CoordSf is the axis-definition scale factor. The value of “i” depends on the “axis name”. See the table in the “Power PMAC Software Reference Manual” under the description of Motor[x].CoordSf.

 

Motor[x].CoordSf[32] is the “axis offset” value.

 

Thanks Steve. I was able to get it working with this method. For anyone else looking to do the same, here is an example of what I did showing only one machine and configuring just the X axis:

 

#define MACHINE 2 // actually defined in different file

 

#define X_AXIS_DEF_PRIMARY Motor[1].CoordSf[6]

#define X_AXIS_Y_COMPONENT Motor[1].Coord[7]

#define X_AXIS_Z_COMPONENT Motor[1].Coord[8]

 

// Initial axis def with small Y/Z compensation.

// If Y and Z values aren't defined here, later assignment below will have no effect

#1->1000X + 0.1Y + 0.1Z

 

#if MACHINE == 2

#define X_AXIS_X_ADJ (0.55)

#define X_AXIS_Y_ADJ (-0.2)

#define X_AXIS_Z_ADJ (0.175)

#endif

 

X_AXIS_DEF_PRIMARY = X_AXIS_DEF_PRIMARY + X_AXIS_X_ADJ

X_AXIS_Y_COMPONENT = X_AXIS_Y_ADJ

X_AXIS_Z_COMPONENT = X_AXIS_Z_ADJ

 

What I've learned here is that although the PMAC preprocessor seems similar to the C preprocessor (CPP), it certainly does not behave the same way. In this case, macro expansion.

 

Also, it appears you cannot parenthesize #defines if you are going to use them in conditional preprocessor statements (i.e. "#if MACHINE == 2" evaluates to false if you do #define MACHINE (2).

 

It seems nested macro definitions are allowed in the PMAC preprocessor, but only if they are not used in conditionals like #if/#elif.

  • Thanks 1
Link to comment
Share on other sites

An axis definition can contain only numeric literal arguments. After a definition is made you can modify the status elements of the motor’s axis-definition scale factor and axis offset:

 

Motor[x].CoordSf is the axis-definition scale factor. The value of “i” depends on the “axis name”. See the table in the “Power PMAC Software Reference Manual” under the description of Motor[x].CoordSf.

 

Motor[x].CoordSf[32] is the “axis offset” value.

 

Thanks Steve. I was able to get it working with this method. For anyone else looking to do the same, here is an example of what I did showing only one machine and configuring just the X axis:

 

#define MACHINE 2 // actually defined in different file

 

#define X_AXIS_DEF_PRIMARY Motor[1].CoordSf[6]

#define X_AXIS_Y_COMPONENT Motor[1].Coord[7]

#define X_AXIS_Z_COMPONENT Motor[1].Coord[8]

 

// Initial axis def with small Y/Z compensation.

// If Y and Z values aren't defined here, later assignment below will have no effect

#1->1000X + 0.1Y + 0.1Z

 

#if MACHINE == 2

#define X_AXIS_X_ADJ (0.55)

#define X_AXIS_Y_ADJ (-0.2)

#define X_AXIS_Z_ADJ (0.175)

#endif

 

X_AXIS_DEF_PRIMARY = X_AXIS_DEF_PRIMARY + X_AXIS_X_ADJ

X_AXIS_Y_COMPONENT = X_AXIS_Y_ADJ

X_AXIS_Z_COMPONENT = X_AXIS_Z_ADJ

 

What I've learned here is that although the PMAC preprocessor seems similar to the C preprocessor (CPP), it certainly does not behave the same way. In this case, macro expansion.

 

Also, it appears you cannot parenthesize #defines if you are going to use them in conditional preprocessor statements (i.e. "#if MACHINE == 2" evaluates to false if you do #define MACHINE (2).

 

It seems nested macro definitions are allowed in the PMAC preprocessor, but only if they are not used in conditionals like #if/#elif.

 

Note that in your first method if you remove the parenthesis in the "#define" it will work as "fixed" axis definitions.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...