Work Coordinate System - Values

Discussion about the arduino based g-code interpreter, grbl
Post Reply
electrosteam
Posts: 17
Joined: Wed Apr 20, 2016 7:42 am

Work Coordinate System - Values

Post by electrosteam » Thu Aug 18, 2016 11:06 am

The WCS is reasonably well described in the literature in general terms, but, there is a lack of examples with specified values.

My experimenting with Grbl 0.9j says that WCS values must be stored as negative (-ve) values to get the job to cut in the positive (+ve) quadrant on the machine.
I think of the WCS values as being the values that the machine must move to retain the work at job code (0,0,0).

Note that the only real machine I have access to uses Machine Home (0,0,0) in the bottom left corner with the platen at Z0.
All cuts use +ve values.
The review and testing is being done at home on an Arduino clone not connected to a machine.

Example:
If the code 'G10 P3 L20 X-20 Y-20 Z-2' is used, a subsequent use of G56 code (WCS P3) results in tool cuts at (20, 20, 2) reference to the Machine Home position of (0,0,0).

But, a Camotics simulation with the same code has the cuts in the -ve quadrant.

My review of LinuxCNC seems to say the reverse, and none of the available references on the Web highlight the negative values.
I think LinuxCNC requires a 'G10 P3 L20 X20 Y20 Z2' for the tool to cut in the positive quadrant.

Which is correct ?
What do I not understand ?
Does this mean that WCS code offsets developed for Grbl will be incorrect on other industry standard machines ?

John

WillAdams
Posts: 8628
Joined: Mon Apr 09, 2012 6:11 pm
Location: Pennsylvania --- south of the Turnpike, East of US-15
Contact:

Re: Work Coordinate System - Values

Post by WillAdams » Thu Aug 18, 2016 12:46 pm

WCS is a way to map to a particular physical area subset on the machine.

W/ Grbl adhering to the industry standard of top right corner being the origin (this behavior can be changed), then yes, offsets are of necessity negative.

These only need to be set up once per particular origin --- usually they correspond to a particular fixture or clamping point.
Shapeoko 3XL #0006 w/ Carbide Compact Router w/0.125″ and ¼″ Carbide 3D precision collets

electrosteam
Posts: 17
Joined: Wed Apr 20, 2016 7:42 am

Re: Work Coordinate System - Values

Post by electrosteam » Thu Aug 18, 2016 10:31 pm

Will,
Thanks for the reply.
I am starting to straighten out the directions.

The stumbling block is that we are operating a router, not a conventional mill.
The mill moves the table, the router moves the head.

Still getting my head around this.
John.

electrosteam
Posts: 17
Joined: Wed Apr 20, 2016 7:42 am

Re: Work Coordinate System - Values

Post by electrosteam » Sat Aug 20, 2016 11:35 am

Well, I have straightened out that using origin coordinates in bottom left corner or top right corner makes no difference to the sign of the WCS offsets.

But, a review of LinuxCNC documentation reveals that there is a difference in the way the machine interprets the 'G10 L2 P...' or 'G10 L20 P...' commands.
The Grbl documentation I reviewed used the L20 example, and this is the code I used to test the WCS.
Originally I used L20 with -ve WCS values to get a good run, but the same job run with L2 and +ve offsets works fine.

I think I am close to understanding the finery and subtleties of the L2/L20 distinction and I am sure a couple more test runs will clear it up for me.

John

electrosteam
Posts: 17
Joined: Wed Apr 20, 2016 7:42 am

Re: Work Coordinate System - Values

Post by electrosteam » Sun Aug 21, 2016 10:29 pm

I have continued my testing using only the L2 variant.
Really quite confused, I cannot get consistent operation on a simple test.

5x5 squares with G54, G55 and G56 at (0,0,0), (10,20,1) and (40,40,5)

I have tried, with various successes:
- remove all comments,
- split program with WCS declarations in one program and cutting code in another,
- WCS declaration in a group at the start,
- each WCS declaration made just before used by cutting code,
- added a return to G54 at end,
- Close/Open comms link,
- soft resets,
- disconnect USB cable,
- etc

I cannot get reliability, sometimes OK, sometimes not.
When not OK, UGS shows Grbl reporting odd errors like F30 is an ID28 - but not consistently.

Simple programs without WCS operate consistently OK.

I can see remnants of previous WCS settings appearing at the start of the cutting run, presumably values in EEPROM.
But, I haven't caught on yet what are the determining factors.

I need to get some guidance as to what is good practice when using WCS.
Some rules like:
- always preset WCS with either Macros in UGS or a separate pre-run program,
- make all WCS declarations in a block at start of code, then pause in some way to allow the EEPROM to settle,
- do not declare any WCS in middle of a cutting program,
- only make WCS declarations just prior to the cutting code,
- reset all WCS back to (0,0,0) at end of cutting code,
- always apply comms Close/Open and soft reset before start,
- and others as appropriate.

John

electrosteam
Posts: 17
Joined: Wed Apr 20, 2016 7:42 am

Re: Work Coordinate System - Values

Post by electrosteam » Mon Aug 22, 2016 7:38 am

Another couple of hours playing with setting the WCS using the G10 L2 variant.

It is obvious, and in the documentation, that WCS settings are persistent through comms Close/Open and power Off/On cycles.

I have determined that, for my Arduino clone operating on a desktop with UGS on a laptop, one cannot declare a WCS in the program code for real cuts.
The WCS must be declared prior to running the cutting code.

Note that jogging to the desired WCS origin point and calling the G10 L20 variant is an entirely different case, not yet explored by me.

My observation is that setting WCS in conjunction with cutting code is risky.
If one has three WCS to be set, running the cutting code often fails after the first WCS set.
Subsequent runs of the same code gets to the 2nd or 3rd set, then fails.
Subsequent runs are Ok, presumably because the EEPROM compares the current WCS with the new setting, and only takes time out to do an actual burn if the new setting is different to the existing.

You can either use the UGS macro facility to set the desired WCS, or run an entirely separate program to set the WCS prior to running the cutting code.

I am currently documenting a set of simple text programs that demonstrate the above (at least on my desktop setup).
The local Men's Shed has a router operating and I will test my programs on that.
Should there be any interest in the subject, I can post the programs.

John.

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: Work Coordinate System - Values

Post by cvoinescu » Mon Aug 22, 2016 10:51 pm

You are right that the typical usage of WCS is outside cutting code. You'd set up a number of WCS, one for each fixture you use. Later, when you had a part to make, you'd select the right WCS for the current job, and start the program.

The difference between L2 and L20 is this:

L2 sets the WCS offsets with regard to the machine zero. The current machine position does not matter when you use G10 L2.

L20 sets the WCS offsets such that the current position becomes what you say in the axis words (X, Y, Z). The offsets depend on the current machine position.

One consequence of this is that the signs of the L2 and L20 axis words work in opposite directions. For L2, the offset is set to the axis word -- if you say G10 P1 L2 X-100, that means the X offset is -100, that is, the X zero is 100 mm to the left of machine zero (assuming G21 mode). For L20, the offset is set to the current machine position less the axis word -- if the machine is at X = -30 and you say G10 P1 L20 X70, that makes the offset -30 - 70 = -100, setting the X zero 100 mm to the left of machine zero -- incidentally exactly the same effect as the L2 example above, but would be different if the machine was elsewhere. This means the current machine position becomes X = 70 in the G54 WCS, or, in other words, the WCS origin is 70 mm to the left of the current position; and this is true no matter what the current machine position is.

Most of the time, you'll probably be using G10 Pn L20 X0 Y0 where you want your part origin to be, and then G10 Pn L20 Zt to set the tool and/or stock height, where t is the known thickness of the item you have between the stock and the endmill (0.1 mm sheet of paper, 3.175 mm endmill shank you're trying to roll under the tip of the tool, touch probe height, etc), or between the table and the endmill, depending on whether you need the Z zero at the top or at the bottom of your part.

Lest I forget, these, and especially the fact that the WCS are persistent, make no sense if you don't have homing enabled, or if you ever move the machine manually, with the motors off, after having homed it. You can use WCS without homing, but the non-persistent G92 makes more sense in that situation. It works much like G10 L20, relative to the current position.

I hope this sheds some light rather than cast even more shadow. :)
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

electrosteam
Posts: 17
Joined: Wed Apr 20, 2016 7:42 am

Re: Work Coordinate System - Values

Post by electrosteam » Tue Aug 23, 2016 5:33 am

cvoinescu,
Thanks for the prompt response and clarifications, very educational.
I can now stop suspecting a slow/faulty clone problem.
John

Post Reply