Jump to content
OMRON Forums

Break motion program line into a few lines


bmartins

Recommended Posts

Hi,

 

I have a simple question: is it possible to group motion program commands on different lines as the same command? For instance, say I have:

 

X(10) Y(20)

 

But what I want to have is:

 

X(10)

Y(20)

 

As the same command (i.e., X and Y move together). Is it possible to group them together (maybe using parenthesis or something similar)? Another case would be something like this:

 

X(10)

if(moveY) {

Y(20)

}

 

I know I could make it:

 

if(moveY) {

X(10) Y(20)

}else{

X(10)

}

 

Which would work for this toy example, but not for 4 motors and their potential combinations... What I am doing right now is to have variables for those ending positions and set the one corresponding to Y to zero if moveY is false.

 

From the manual I got:

 

"All separate axis moves specified on the same command line (e.g. X10.34 Y20) will execute simultaneously in a coordinated fashion, starting at the same time, and in all modes except possibly rapid mode, ending at the same time. Axis moves specified on separate lines will execute sequentially, with or without stops in between, depending on the mode(s) in effect at the time."

 

But I thought I might ask here if there is a workaround.

 

Thanks!

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

as you read in the manual, there is no way around it.

commands in separate lines will execute separately.

 

could you be more specific about what you want to achieve ?

We may be able to find another solution for you.

Link to comment
Share on other sites

I want to achieve 3 things:

 

1. Clearer code

 

I like to have descriptive variable names and I end up with very long lines when doing something like this (in pvt mode):

 

X(VectorEndPos(0)):(VectorSpeed(0)) Y(VectorEndPos(1)):(VectorSpeed(1)) Z(VectorEndPos(2)):(VectorSpeed(2)) A(VectorEndPos(4)):(VectorSpeed(4)) B(VectorEndShutterPos):(VectorShutterSpeed)

 

2. Conditionally pick which motors will move

 

Sometimes I only want to move a subset of those motors. Currently for the motors that won't move I calculate their positions so they will stay put.

 

3. Build the motion command in a loop:

 

Something along the lines:

 

i=0

while(i < 4) {

{some var corresponding to axis i pos on coord system 1} = VectorEndPos(i)

{some var corresponding to axis i speed on coord system 1} = VectorSpeed(i)

i = i+1

}

Link to comment
Share on other sites

My suggestion for clearer code is make more use of subprograms. You could give a subprogram name to each type of move you are trying to achieve (like that long PVT move you showed), and then calling then condenses to a single line in your motion program.

 

You can also throw your conditionals inside the subprograms so they do not clutter up the top level motion program.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...