How interpreter tracks machine position

More
01 Apr 2016 22:02 #72533 by joshuadickerson
Hello,

I am new to LinuxCNC and really interested in how it works. From what I understand, LinuxCNC uses a standalone interpreter that issues canonical commands to a machine controller, usually with a 1:1 correspondence to what a typical commercial controller board might accept. My question is, does the interpreter maintain its own awareness of the machine controller's position? When issuing canonical commands for linear coordinated motion, does the interpreter use the previously specified words from the user as the starting point, or the current machining position?

Say we have the following situation with a linear delta machine.

1. Machine powered on.
2. Machine homed. New machine position is (0,0,585) in millimeters.
3. "G0 Z 20" command issued.
4. Machine rehomed.
5. "G0 Z 40"

At step 5, does the machine move from (0,0,585) to (0,0,40), or does it move from (0,0,20) to (0,0,40)?

My intuition tells me that to be consistent, it would have to always use the current machine position, instead of the last specified axis words. It still seems like interpreter would need to know the current machine position, since it is not necessary to specify an axis word if that coordinate hasn't change. But I could be wrong.

Say we issue "G0 X 10 Y 20 Z 30" and then later "G0 Z 0". How would it go from just receiving a "change Z coordinate to 0" to issuing a canonical command like STRAIGHT_FEED(10,20,0,0,0,0)

This also implies the machine controller has to keep track of the current position because the canonical commands do not have a starting coordinates. How does LinuxCNC keep the interpreter's machine position consistent between the two? Say the machine is jogged via the HMI, obviously this doesn't go through the interpreter. Through callback functions?

Can anyone point me to the answer or help me sort this out? Any help would be greatly appreciated!

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

More
01 Apr 2016 22:33 #72534 by jepler
You can investigate this for yourself. Because many of the simulated configurations use shared home switches, it is slightly tricky. Here's one sequence that will illustrate the question you have:
  1. start linuxcnc with sample-configs/sim/axis/lathe.ini
  2. Go to machine on and home all axes
  3. Clear any offsets in effect (there will be none if this is the first time you've used this config)
  4. Go to MDI tab and G0 Z-1 *** Many other target locations will close the simulated shared home switch and you won't be able to home in the next step
  5. Go back to manual tab and home all axes again. *** Unlike some other controls, there is no MDI to run the homing sequence
  6. Go back to MDI tab and G0 Z-2
Since the position after the homing procedure is Z=0, you will see the first motion moves 1" in the negative Z direction to Z-1. After the second homing procedure, you are back at position Z=0 and the second motion moves 2"in the negative Z direction to Z-2.
The following user(s) said Thank You: joshuadickerson

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

More
01 Apr 2016 23:52 - 01 Apr 2016 23:53 #72536 by andypugh
Firstly, it is a bit more complicated than this:
The interpreter converts the G-code to canonical moves. These are sent to the trajectory planner, which (as I understand it) handles accel and decel and path blending, and then _that_ is queued to the real-time trajectory controller that issues the new positions to the motors every servo-period. (1mS)

But, fundamentally, the positions sent to the motors are in machine-coordinates, but the relationship between machine-coordinates and motor positions changes when you re-home.

If you re-home to accurate limits, or to encoder index, or to absolute encoder (like my machine does) then the position between homing actions will be identical to machine limits. If you home to nothing, in immediate mode, then yes, everything will move. Because you "lied" to the machine by telling it was "home" when it was somewhere other than last time you told it that.

[edit] But I can't help feeling that I have misunderstood the question
Last edit: 01 Apr 2016 23:53 by andypugh.
The following user(s) said Thank You: joshuadickerson

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

More
02 Apr 2016 01:47 #72544 by joshuadickerson
If you're confused on what exactly I am asking, I don't blame you. It's exceptionally difficult for me to phrase things.

I am writing my own machine controller from scratch, which I am doing for two reasons:

1. To fill the gap between GRBL/Smoothie/other microcontroller based machine controllers and LinuxCNC. I have a working prototype and I intend to opensource everything when it's fully matured.

You can see the controller and firmware in action here:




2. To better understand how LinuxCNC works in its entirety and become a contributor to the project.

The machines I work with primarily employ non-trivial kinematics, so homing is absolutely essential to get right. Right now my machine can't home to (0,0,0) because if it did, there's a potential for crashing into the build plate. It homes at the top instead (0,0,585)

I have a parser which connects to the interpreter. The interpreter issues canonical commands to a motion controller. The motion controller sends trajectories to a planner (around machine accel/velocity limits) which then issues poly coeffs to the joint interpolators. It's all tied together with floating point numbers and pointers. I first became interested in LinuxCNC when i noticed the striking resemblance to how i'm approaching things and of course its origins at NIST.

I gave the motion controller keys to everything so to speak. To maintain a consistent machine state it's all encapsulated into the motion module, including the current machine position. I'm not sure if LinuxCNC does it his way, but this encapsulation requires that my interpreter keep its own tabs on machine position. Without it, it can't form the parameters for the canonical calls when the user only specifies axis words that changed from the previous command. The problem is that if the motion module executes a change in coordinate systems, offsets, homes or jogs, the interpreter's machine position is no longer synced.

I am hoping I can learn how LinuxCNC approaches things to aid in my own efforts and to better understand LinuxCNC itself. I suspect one would need a callback function that the motion module could use to update the interpreter when sync between the two machine positions are lost. Or a global machine position variable.

Are the axis words 'sticky', or does it only seem that way until a home or jog is done-making it apparent that it just seems sticky and only the current machine position is used?

Is there a document section that clearly details the intercommunication between the different modules?

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

More
02 Apr 2016 02:05 #72545 by andypugh

I am writing my own machine controller from scratch,


You could probably just use the relevant parts of LinuxCNC. Much of it is not just open-source but also public-domain.

The machines I work with primarily employ non-trivial kinematics, so homing is absolutely essential to get right. Right now my machine can't home to (0,0,0) because if it did, there's a potential for crashing into the build plate. It homes at the top instead (0,0,585)


In LinuxCNC you would set up the Z with 0 at the top and -585 at the bottom. Solves the problem.

I have a parser which connects to the interpreter. The interpreter issues canonical commands to a motion controller.

There is a (not well maintained) LinuxCNC module/interface that takes canononical commands directly.

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

More
02 Apr 2016 02:38 #72550 by jepler
It is true that portions of LinuxCNC were derived from code placed in the public domain by NIST (so called "emc1"). However, every subststem has had contributions from authors who only offer those changes under the terms of the GPL. It is extremely inadvisable to use LinuxCNC as a basis for a project that will not be GPL-licensed, and I find it unfortunate that Andy's remarks could be interpreted as encouraging it.
The following user(s) said Thank You: joshuadickerson

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

More
02 Apr 2016 03:27 - 02 Apr 2016 04:07 #72552 by joshuadickerson

It is true that portions of LinuxCNC were derived from code placed in the public domain by NIST (so called "emc1"). However, every subststem has had contributions from authors who only offer those changes under the terms of the GPL. It is extremely inadvisable to use LinuxCNC as a basis for a project that will not be GPL-licensed, and I find it unfortunate that Andy's remarks could be interpreted as encouraging it.


Yes, i want to clarify that I won't be basing this machine controller off the LinuxCNC source. I plan on making direct contributions to the GPL'ed LinuxCNC project separately with what I learn from my own project. I intend to tackle some of the hardest problems with LinuxCNC using my own software as the test bed. I figured writing my own from scratch instead of cutting/pasting the existing code from LinuxCNC would give me the depth of knowledge needed to tackle those problems, among other things.

At the moment, I actively avoiding looking at the source, progressing akin to the chinese wall method.
Last edit: 02 Apr 2016 04:07 by joshuadickerson.

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

Time to create page: 0.131 seconds
Powered by Kunena Forum