How to. 2 or more motors on one axis. Gantry

More
27 Jul 2017 20:25 - 27 Jul 2017 20:33 #96594 by joel0407
Ok so this is written by a layman in layman terms. I will explain with the least amount of errors as I can. If a developer or Mod tells me I’ve explained something wrong, please tell me so I can make changes. This is primarily written for someone who wants to use 2 (or more) motors on 1 axis on a simple XYZ CNC Gantry Machine.

Most of this assumes you are able to get LinuxCNC to work with one motor per Axis but you want to add one or more motors to one or more axis.

First of all, I suggest you have a working HAL and INI file handy and have a look at it. That was a mistake I made as I was trying to understand what to do just reading the manual as I was at work and didn’t have access to these files.

Now you will need to know what a Cartesian coordinate system is. It’s pretty much XYZ, each letter represents a plane (axis) in a 3 dimensional system. The Cartesian coordinate system can have more or less planes (axis) but if you are building a Gantry CNC machine, you’ll most probably need to know XYZ.



LinuxCNC 2.8 doesn’t refer to motors, it refers to joints. My guess is because a joint is not necessarily a motor. It could be a hydraulic ram for all LinuxCNC cares. So no motors, joints. I think that’s a bit hard to understand when you are building a Gantry CNC machine but just accept it.

Now this is the part that can be a bit difficult to get your head around. LinuxCNC 2.8 does not directly correlate axis to motors. That sounds simple but it can be confusing when if you have built a Gantry CNC machine that has a motor with a direct correlation to each axis.

One way to really see the separation is the Maslow CNC machine. I don’t know if it runs on LinuxCNC but it clearly shows 2 motors that don’t directly correlate to the X and Y axis. (Watch the youtube video now) It has 2 motors, one in each corner. It sits slightly off vertical, the router moves down the axis with gravity. Lets say up and down is X axis and left and right is Y. Now if the router is to move left to right, across the Y axis, each step the requires a Trigonometry calculation depending on the angle and distance between the motor in the corner and the router to calculate how far and what direction the motor needs to turn. As the router moves left to right it is not moving directly toward or directly away from the motors in the corner however it is moving straight along the Y axis. This isn’t really relevant for a simple Gantry CNC machine however it explains why LinuxCNC joints don’t necessarily correlate directly to an axis. This is called Non-trivial kinematics and you can see page 694 of the manual is you are really interested.

Maslow CNC machine

Now you should have the Cartesian coordinate system defines the point in a 3 dimensional space with 3 axis, LinuxCNC calls motors joints, joints and axis are not the same thing.
Last edit: 27 Jul 2017 20:33 by joel0407.
The following user(s) said Thank You: pommen, ikkuh, Jalfrezi19, jackman0

Please Log in or Create an account to join the conversation.

More
27 Jul 2017 20:26 - 27 Jul 2017 20:38 #96595 by joel0407
On to the INI file. The StepConf GUI that I presume was fine for creating the INI and HAL files in LinuxCNC 2.7 is greatly lacking for creating the files for LinuxCNC 2.8. However it creates some great starting files for editing. So run stepconf, hook up a stepper, driver and power supply and follow the instructions to get it going. Setup each axis with the settings required for the motor or motors on that axis. You’ll need one motor for each axis because providing the second motor on the axis is the same, you’ll be copying these details later. There is plenty of other help out there for this.

You will only need to set it up as a XYZ machine. There is other topics out there that suggest you setup a XYZA machine but I hope to give you enough understanding that you want need that and it may just confuse you more as you'll have a random rotary axis that needs to be changed to a linear axis. It also mean the extra joint will just be tacked on the end which I think is a bit untidy.
Last edit: 27 Jul 2017 20:38 by joel0407.

Please Log in or Create an account to join the conversation.

More
27 Jul 2017 20:27 - 27 Jul 2017 20:43 #96596 by joel0407
Now edit your INI file.

Skip to the KINS section. You’ll know it because it has KINS in square brackets. It will look something like this:

[KINS]
JOINTS = 4
KINEMATICS = trivkins coordinates=XYYZ

Change the joints to the number of motors you have. For example if you have 2 motors on each axis, change it to 6 or 2 motors on 2 axis and one on the other, change it to 5. Whatever your setup is. The example has 4

Next line. Set coordinate letters to match the motors. The example is 1 motor on the X axis, 2 on the Y represented by YY and one on the Z.

Scroll down a bit further to the TRAG section. It will look something like this:

[TRAJ]
COORDINATES = X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 10.00
MAX_LINEAR_VELOCITY = 100.00


Just make sure the coordinates are set at X Y Z. The other stuff would have been set when you went through the stepconf process.

Now the bit that’s slightly tricky.

This is the bit that sets what joints make up which axis.

You should have 3 titles [AXIS X], [AXIS Y] and [AXIS Z]. Immediately under that you’ll have some settings, MAX_VELOCITY and stuff. Don’t worry about that stuff. You should have set that when you did the stepconf process.

Under each title [AXIS X], [AXIS Y] and [AXIS Z] and below the immediate stuff there should be a title [JOINT_0] for X, [JOINT_1] for Y and [JOINT_2] for Z. These are what you have to copy, paste and make a slight change.

For starters, create a duplicate of the joint title and all the information immediately underneath it, under the Axis title that has 2 motors.

For example if you have 2 motors on your X axis, it will look like this:

[AXIS X]
Blah, blah, blah

[JOINT_0]
Blah, blah, blah

[JOINT_0]
Blah, blah, blah

Except the “Blah, blah, blah” part will be the actual information that was set when you completed the Stepconf process.

Next, change each joint title so they count 0, 1, 2, 3, 4 and so on.

It should look like this:



[AXIS X]
Blah, blah, blah

[JOINT_0]
Blah, blah, blah

[AXIS Y]
Blah, blah, blah

[JOINT_1]
Blah, blah, blah

[JOINT_2]
Blah, blah, blah

[AXIS Z]
Blah, blah, blah

[JOINT_3]
Blah, blah, blah

Except the “Blah, blah, blah” will be relevant information as discussed previously.

If you have followed those instructions step by step, that’s the INI file done for now. We'll come back for homing.

Don’t cheat and try and copy Joints from different Axis. The Axis information and Joint information has to match. If it doesn’t, you’ll get an error.
Last edit: 27 Jul 2017 20:43 by joel0407.

Please Log in or Create an account to join the conversation.

More
27 Jul 2017 20:27 - 27 Jul 2017 20:46 #96598 by joel0407
Now the HAL file. This is the file I understand the least but I understand enough to get it to work.

I am using a parallel port break out board. For the performance it gives and for less than $15, I don’t know why anyone would use anything else. I have run out of inputs but I’ll add another parallel port as it’s the cheapest option I know.

Setting what information goes to which parallel port pin will be one of the settings we need to change.

First though we need to create the signal that will go to the pin so scroll down and you’ll find some sections that have 6 lines that start with “setp” followed by 6 lines that start with “net”

Find the section that you have more than 1 motor on and duplicate it below, yes there need to be a line in between the new duplicate section. Just copy and paste for now. You can identify the section you need as the first “net” line will have xpos-cmd for X, ypos-cmd for Y and zpos-cmd for Z. You will need to copy and paste the whole section, just use the “net” line to identify the section. If you have 2 motors on the X axis, copy and paste the whole X section.

Now this is a bit harder. You need to number the joints and related settings sequentially for each section. So section one needs all the references to the joint changed to 0, the next section 1 and so on.

In the below section I have placed a red asterisk in the place where the joint number for each section needs to be placed.

setp stepgen.*.position-scale [JOINT_*]SCALE
setp stepgen.*.steplen 1
setp stepgen.*.stepspace 0
setp stepgen.*.dirhold 25000
setp stepgen.*.dirsetup 20000
setp stepgen.*.maxaccel [JOINT_*]STEPGEN_MAXACCEL
net xpos-cmd joint.*.motor-pos-cmd => stepgen.*.position-cmd
net xpos-fb stepgen.*.position-fb => joint.*.motor-pos-fb
net xstep <= stepgen.*.step
net xdir <= stepgen.*.dir
net xenable joint.*.amp-enable-out => stepgen.*.enable
net home-x => joint.*.home-sw-in

Where ever you see a reference to an Axis in each of the sections, this is an arbitrary character. It doesn’t really matter what this is. When I tested this, I was eating jam on toast for breakfast and changed a whole section to “jam” and it still worked. They are named “x”, “y” and “z” just to make the file easier to understand. So you can call your second motor whatever you want but I’d recommend you make it something relevant. I have 2 motors on my Y axis so I changed mine to “y0” and “y1” but you can make it whatever you want. Maybe “ym” and “ys” for Y axis master and slave. I know the second motor is often referred to as a slave but it’s not really as they work together. You must make this change as you can’t have 2 signals with the same name and each joint needs a signal. Each character you have to change is just after “net” in the section and one after “home-“ on the last line.
Last edit: 27 Jul 2017 20:46 by joel0407.
The following user(s) said Thank You: samueldutradasilva

Please Log in or Create an account to join the conversation.

More
27 Jul 2017 20:28 #96599 by joel0407
So now we have Axis setup in the INI, joints setup for each Axis in the INI file, signals created for each joint in the HAL file, and names for each signal in the HAL file.

Now we need to use the names we have for the signals to send that signal out a pin on the parallel port and in for the home signal.

In the HAL file, toward the top you’ll find a section where most lines start with “net” and a few start with “setp”. Some of the lines will end with “parport.0.pin-02-out” but sequential pin numbers. What these are will depend on how you setup the stepconf process in the beginning.

I may be wrong but as far as I understand pins 2 – 9 are usually used as output pins and paired as 2-3, 4-5, 6-7 and 8-9. Pins

For each pair of output pins for a motor (joint) will need to following lines:

net xdir => parport.0.pin-02-out
net xstep => parport.0.pin-03-out
setp parport.0.pin-03-out-reset 1

You will already have some, possibly 3 depending on how you setup stepconf. If you have 3, you’ll have to add a forth or more if you have more motors. If you have more motors though, you’ll need a second parallel port or a different controller, mesa or the like.

At the end of the section, you’ll have to copy and paste another home line as well or as many as you have motors. The line will be similar to:

net home-z <= parport.0.pin-15-in

I think it’s pretty self-explanatory, you’ll need to change the pin number in “parport.0.pin-15-in” for each line. In this line the pin number is “15”.

In this section, you’ll see several “dir” and “step” preceded by what would be an arbitrary character which relates to a joint. These are usually “x”, “y” and “z”. There will also be one following each “home-“ toward the bottom of the section. These relate to the names we gave the signals previously. Each one has to be changed to match what we called the signals in the previous section. If you chose to call a signal for a joint “y0” and “y1” as I have or “ym” and “ys” you need to change the a character preceding a “dir” and a character preceding a “step” to the signal name you chose and also the character following the “home-“.

Please Log in or Create an account to join the conversation.

More
27 Jul 2017 20:28 #96600 by joel0407
Last but not least, we need to go back to the INI file and setup homing. There is a whole section on this in the manual that isn’t too hard to follow. Check out page 311.

If you have 2 motors driving the same axis, you’ll most likely want to synchronise those motors (joints) as if one was to home before the other, you might have a problem.

Without going into detail (I suggest reading the section in the manual). At the end of each joint section in the INI file there will be a line “HOME_SEQUENCE = 0” the number at the end designated the order for the joint to be homed. If you want them to home as joint 0, then joint 1 and so on, then change the “HOME_SEQUENCE =” number to 0, 1 and so on. If you want joint 0 to home then joints 1 and 2 together but not synchronised then change “HOME_SEQUENCE =” to 0 for joint 0 and “HOME_SEQUENCE =” for joints 1 and 2 to 1. If you want them synchronised then put a “-“ in front of the number as in “HOME_SEQUENCE = -1” and “HOME_SEQUENCE = -1” for both joints 1 and 2.

There are really quite a few options for homing in the manual and you really should read it to understand what’s going on and what to set.

What you have now should be enough to get you working with more than one motor on a single axis.

A problem I had was after I had everything setup as above, I ran LinuxCNC 2.8 only to find the axis with 2 motors wouldn’t move. Thank to Todd for pointing out the axis won’t move until after the axis is homed as the joints aren’t tied together until after they are homed. If you just want to simulate the setup, if you are confident enough, you can change the homing to manual homing. Then you can manually home it and the axis will move.

To change each joint to manual homing you just need to 4 lines at the end of each joint section in the INI file to read:

HOME_SEARCH_VEL = 0
HOME_LATCH_VEL = 0
HOME_USE_INDEX = NO
HOME_SEQUENCE = 0

You can simply copy and paste this. Then in front of the old homing settings place a “#” character. The “#” character will tell LinuxCNC to ignore the line. That will make it easier when you want to revert back. Just delete the “#” character and the 4 lines you added.

Special thanks to Todd and Rodw for all their help to get me to understand this.

Happy Days
The following user(s) said Thank You: andypugh, captain chaos, akb1212, pommen, superlen, Yannis, ikkuh, Dalbjerg, gloops, snoozer77 and 4 other people also said thanks.

Please Log in or Create an account to join the conversation.

More
10 Feb 2018 16:14 - 10 Feb 2018 16:17 #105711 by ikkuh
Thank you very much for this write-up. The LinuxCNC documentation is not really written with the 'handyman' in mind.

I now have a gantry cnc router which automaticaly homes it self, even both of the Y axes.

Your documentation was great, only thing that was not really clear was:
loadrt stepgen step_type=0,0,0
It needs another 0 for the extra motor on the Y axis. But thankfully rodw gave me the solution at: forum.linuxcnc.org/49-basic-configuratio...-8-pre-master#104933

Once again thank you, I had a lot of fun implementing your tips!
Last edit: 10 Feb 2018 16:17 by ikkuh.
The following user(s) said Thank You: rodw

Please Log in or Create an account to join the conversation.

More
08 Apr 2019 05:36 #130477 by Kitwn
Have just sucessfully upgraded my gantry CNC router to v2.8 and set up the long, dual-motor axis (X in my case) for automatic squaring (is that 'auto-racking' or 'auto-unracking') when it homes. Everything worked perfectly using your instructions. Many Thanks!

Kit

Please Log in or Create an account to join the conversation.

More
10 Apr 2019 15:42 #130603 by pl7i92
on your Homing sequenz
YOU might be adding
HOME_FINAL_VEL = 5
to all the [joint]
so it does not MAX speed to the Home point after it triggerd the switch

Please Log in or Create an account to join the conversation.

More
10 Apr 2019 23:59 #130633 by Kitwn
That's a good point, I've done that on my mahine.
For those readers (like me) who are not totaly fluent in LinuxSpeak I've put some additional notes on the whole upgrade and auto-squaring process on the MYCNCUK forum at:
www.mycncuk.com/threads/12687-Auto-Squar...?p=107985#post107985

Kit

Please Log in or Create an account to join the conversation.

Time to create page: 0.115 seconds
Powered by Kunena Forum