Solved -Help customizing Water Jet mygcode file

Discussions around the CAM Add-On of QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Indicate the post processor used.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
seaglass23
Newbie Member
Posts: 5
Joined: Mon Mar 13, 2023 9:19 pm

Solved -Help customizing Water Jet mygcode file

Post by seaglass23 » Mon Mar 13, 2023 10:24 pm

There are not a lot of waterjet resources so I went ahead an tried to modify mygcode.js.

The issue is that plunge rate is entered in the tool and that shows up in the toolpath. The water jet wants to see that number to determine how long it holds in place to pierce the work. It needs it to be displayed as a prefix "S" followed by time in seconds and finally a period. I had been just hard coding a 2 second default time as I only cut glass but recently found some circumstance where I need different vaules. It is also more user friendly to get it to work correctly.

Code: Select all

 	[// variables: Change Plunge Rate prefix from F to S
   	 //                   			 name,                  ID,                     always, prefix, decimals, options
		this.registerVariable("plungeRate",          "FP",                   true, "S", 0);

It needs to show up in the header as M1407 = [FP] which the water jet uses as a default pierce time after forced stop. In this instance it looks like M1407 = S2. This is working in the code currently.

For each remaining toolpath the Waterjet needs a pierce time.
M3
M8
G [FP].
And this is were it falls apart. I have red lined the gcode in a word document highlighting the first few problem instances. The first instance displays the value for Feed Rate and not Plunge Rate.

Code: Select all

	M3
	M8
	G4 S240.  Wrong value, should be as above "S2." but instead it grabbed the feed rate value from toolpath 1 "240"

Thanks.


Version:
3.27.8.0 (3.27.8)
Internet:
QCAD.org
Build Date:
Oct 6 2022
Revision:
dea3962
Qt Version:
5.13.2
Architecture:
x86_64
Compiler:
MSVC++ 14.0 (2015)
Attachments
MyGCode.js
example of my coding effort.
(5.49 KiB) Downloaded 294 times
mini 9 piece.dxf
Test piece
(233.78 KiB) Downloaded 276 times
mini 9 cutall.Gcode.docx
Word version of gcode redlining the mistakes,
(13.37 KiB) Downloaded 294 times
Last edited by seaglass23 on Thu Mar 16, 2023 4:55 pm, edited 1 time in total.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Help customizing Water Jet mygcode file

Post by CVH » Tue Mar 14, 2023 10:25 am

seaglass23,

Normally we would post these questions in the "QCAD/CAM" forum of "QCAD PROFESSIONAL VERSION". :wink:
Maybe a moderator will step in and move whole the topic.

Curious problem.
BTW: In the docx I find 5 times 'G4 S240.' and 9 times 'G4 S100.'
I also noticed that G0's are without spaces and G1's are with spaces while this.rapidMove & this.linearMove are both defined without.

I already have my reservations with the trailing dot.
Why is [FP] and S1 followed by a literal dot?

What I don't understand is that you use this.singleZPassHeader and this.singleZPassFooter.
It seems that your water-jet has no Z movements and I don't suspect that you use several Z passes.
I would integrate this in this.contourHeader and this.contourFooter
Piercing at the start of each contour and a pause afterwards.
Then again, each profile has contours and that has ZPasses so it would work out the same.

I think that it doesn't matter much but there are 3 array declaration that end in a comma.
The comma is the list separator and an array should be [item1, item2, ..., itemN].
It doesn't matter if it is placed on consecutive lines, adding space to align but after the last item there should be no comma.

You have 2 tools: '.9' with plunge rate 3 and 'drill' with plunge rate 2.
Each of the 9 profiles has a plunge rate 2 except the last what is 3.

The plunge rate (a feed in Z) is no longer exported with prefix 'F' as defined in GCodeBase but overruled with prefix 'S'.

For the initial export before any profile it seems to use the 'drill' plunge rate ... M1407 S2.
Up to this point all is fine.
Only later on the value is the Feed in the XY plane and not the defined plunge rate itself ... :shock:

I would report this as a bug on Bugtracker.
https://www.ribbonsoft.com/bugtracker/
You need a separate acount there or start a new one.
I couldn't locate anything about this there nor on the forum. :wink:

Regards,
CVH

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Help customizing Water Jet mygcode file

Post by CVH » Tue Mar 14, 2023 2:52 pm

seaglass23,

Looking further into this ...
A profile Block reference receives a custom property CamPlungeRate, I suspect this defaults to the tool used.
CamEntities don't receive a CamPlungeRate, only a CamFeedRate custom property.

Exporting a toolpath Initializes internal variables for this toolpath:
> this.feedRate = toolpath CamFeedRate or zero when missing
> this.plungeRate = toolpath CamPlungeRate or zero when missing

Exporting a CamEntity Initializes internal variables for this entity:
> this.feedRate = CamEntity CamFeedRate or that of the toolpath when missing
> this.plungeRate = CamEntity CamFeedRate or that of the toolpath when missing

Most obvious is that this.plungeRate = CamFeedRate of the CamEntity when exporting entities.

But maybe there is a way around.
Found in the Woodman.js postprocessor:

Code: Select all

Woodman.prototype.initEntity = function(entity) {
    GCodeBase.prototype.initEntity.call(this, entity);

    // force plunge rate from toolpath:
    this.plungeRate = this.getToolpathOptionFloat("CamPlungeRate", 0.0);

//    ...

};
Meaning that after a CamEntity is initialized as standard, the variable this.plungeRate is still sourced from the current toolpath.

Please give that a try and report back. :wink:
Simply change 'Woodman' into your postprocessor 'MyGCode', both are already based on 'GCodeBase'.

Regards,
CVH

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Help customizing Water Jet mygcode file

Post by CVH » Tue Mar 14, 2023 3:27 pm

seaglass23,

I think that M1413 is intended for information along with M1411 & M1412 ... :wink:
The M1404 code must definitely be in the file footer.

Regards,
CVH

seaglass23
Newbie Member
Posts: 5
Joined: Mon Mar 13, 2023 9:19 pm

Re: Help customizing Water Jet mygcode file

Post by seaglass23 » Tue Mar 14, 2023 3:35 pm

I will move this over as suggested. The period / dot is something the water jet is looking for. The have property software to generate the gcode and it is simplistic at best so tried this program. I think you are correct, originally i only used one tool and stuck it in single zpass, adding the other tool means I need to improve the program and and allow tool paths. Thanks for the help.
CVH wrote:
Tue Mar 14, 2023 10:25 am
seaglass23,

Normally we would post these questions in the "QCAD/CAM" forum of "QCAD PROFESSIONAL VERSION". :wink:
Maybe a moderator will step in and move whole the topic.

Curious problem.
BTW: In the docx I find 5 times 'G4 S240.' and 9 times 'G4 S100.'
I also noticed that G0's are without spaces and G1's are with spaces while this.rapidMove & this.linearMove are both defined without.

I already have my reservations with the trailing dot.
Why is [FP] and S1 followed by a literal dot?

What I don't understand is that you use this.singleZPassHeader and this.singleZPassFooter.
It seems that your water-jet has no Z movements and I don't suspect that you use several Z passes.
I would integrate this in this.contourHeader and this.contourFooter
Piercing at the start of each contour and a pause afterwards.
Then again, each profile has contours and that has ZPasses so it would work out the same.

I think that it doesn't matter much but there are 3 array declaration that end in a comma.
The comma is the list separator and an array should be [item1, item2, ..., itemN].
It doesn't matter if it is placed on consecutive lines, adding space to align but after the last item there should be no comma.

You have 2 tools: '.9' with plunge rate 3 and 'drill' with plunge rate 2.
Each of the 9 profiles has a plunge rate 2 except the last what is 3.

The plunge rate (a feed in Z) is no longer exported with prefix 'F' as defined in GCodeBase but overruled with prefix 'S'.

For the initial export before any profile it seems to use the 'drill' plunge rate ... M1407 S2.
Up to this point all is fine.
Only later on the value is the Feed in the XY plane and not the defined plunge rate itself ... :shock:

I would report this as a bug on Bugtracker.
https://www.ribbonsoft.com/bugtracker/
You need a separate acount there or start a new one.
I couldn't locate anything about this there nor on the forum. :wink:

Regards,
CVH

seaglass23
Newbie Member
Posts: 5
Joined: Mon Mar 13, 2023 9:19 pm

Re: Help customizing Water Jet mygcode file

Post by seaglass23 » Tue Mar 14, 2023 3:38 pm

Thanksfor looking into this, and coming up with a really good suggestion.

CVH wrote:
Tue Mar 14, 2023 2:52 pm
seaglass23,

Looking further into this ...
A profile Block reference receives a custom property CamPlungeRate, I suspect this defaults to the tool used.
CamEntities don't receive a CamPlungeRate, only a CamFeedRate custom property.

Exporting a toolpath Initializes internal variables for this toolpath:
> this.feedRate = toolpath CamFeedRate or zero when missing
> this.plungeRate = toolpath CamPlungeRate or zero when missing

Exporting a CamEntity Initializes internal variables for this entity:
> this.feedRate = CamEntity CamFeedRate or that of the toolpath when missing
> this.plungeRate = CamEntity CamFeedRate or that of the toolpath when missing

Most obvious is that this.plungeRate = CamFeedRate of the CamEntity when exporting entities.

But maybe there is a way around.
Found in the Woodman.js postprocessor:

Code: Select all

Woodman.prototype.initEntity = function(entity) {
    GCodeBase.prototype.initEntity.call(this, entity);

    // force plunge rate from toolpath:
    this.plungeRate = this.getToolpathOptionFloat("CamPlungeRate", 0.0);

//    ...

};
Meaning that after a CamEntity is initialized as standard, the variable this.plungeRate is still sourced from the current toolpath.

Please give that a try and report back. :wink:
Simply change 'Woodman' into your postprocessor 'MyGCode', both are already based on 'GCodeBase'.

Regards,
CVH

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Help customizing Water Jet mygcode file

Post by CVH » Tue Mar 14, 2023 4:16 pm

seaglass23,

Some hints:

One can quote only a part of a post by selecting it. :wink:

If considered solved please prefix the title of your first post with [Solved] by editing it.

Regards,
CVH

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 4935
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Help customizing Water Jet mygcode file

Post by Husky » Tue Mar 14, 2023 7:01 pm

Topic moved to "QCAD Professional Version QCAD/CAM"
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

seaglass23
Newbie Member
Posts: 5
Joined: Mon Mar 13, 2023 9:19 pm

Re: Solved -Help customizing Water Jet mygcode file

Post by seaglass23 » Thu Mar 16, 2023 5:22 pm

It is running, or mostly fixed for now. I will need to make some changes to incorporate some list boxes or other inputs.

I have uploaded the new file, You will see that I commented out all combinations of headers. Simply using contour header resulted in code that did not turn off the pump or abrasive feed. I changed to a singlezpass header and it runs well

The code snippet from Woodsman cleared up 90% of the issues. For testing purposes I changed plunge rate in each toolpath so I could see the changes in the gcode. What I found was the value that was entered for M1407 was taken from first toolpath plungerate, yet down in the gcode when it was needed again it shoed us a null and displayed as G4 .

The purpose of the m1407 is for the machine to have a safe fall back re-pierce time and really has no relation to the toolpaths I have created. I hard coded it for now. Later I need to add a menu item that gets filled out with this value. Ignoring M1407 made everything fall into line.

Thanks, I am sure I will be back as I keep refining this.
Attachments
mini 9 cutall.gcode.txt
output
(3.09 KiB) Downloaded 280 times
MyGCode.js
updated and working code
(2.5 KiB) Downloaded 284 times
mini 9 piece.dxf
the new file showing a wide variety of plunge rate
(233.78 KiB) Downloaded 286 times

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Solved -Help customizing Water Jet mygcode file

Post by CVH » Thu Mar 16, 2023 6:03 pm

seaglass23,

MyGCode.prototype.initEntity() should not be inside function MyGCode(..) {...};
A function starts with '{' and ends in '};'.
The semicolon indicates the end of the instruction line.

Line 26-33 (the Woodman part) should be between:

Code: Select all

MyGCode.prototype = new GCodeBase();
   ### Insert here ###
MyGCode.displayName = "My G-Code [mm]";
Luckily I remarked out the 3 dots that you plain copied in line 32.
These 3 dots simply indicated that Woodman.js does other things we were not interested in.

And an array starts with '[' and ends in '];'.
Again the semicolon indicates the end of the instruction line.
this.header & this.footer still end in a comma and there is no next item ... :wink:
To make it look nice then set the array end aligned under the beginning of the line with the array start.
In QCAD it is common to use spaces and 4 spaces for a tab stop, your code uses a mix of spaces and tabs stops.

Regards,
CVH

seaglass23
Newbie Member
Posts: 5
Joined: Mon Mar 13, 2023 9:19 pm

Re: Solved -Help customizing Water Jet mygcode file

Post by seaglass23 » Thu Mar 16, 2023 6:22 pm

Thanks, I learned to program basic on a TRS-80 and later did some ASM. I do cut and past, clearly not well. I made the changes and posted it.
Attachments
MyGCode.js
(2.41 KiB) Downloaded 389 times

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Solved -Help customizing Water Jet mygcode file

Post by CVH » Thu Mar 16, 2023 6:36 pm

seaglass23,

You have to try it for yourself and if you want that, report back.
I am not a QCAD/CAM subscriber, I only have a licence of QCAD Pro.
I have my personal reasons for that. You could PM me.

But, I know my way around scripting.
QCAM is just an Addon script package. :wink:

BTW, still remarked:

Code: Select all

M3
M8
G4 .
in the output.
Did those toolpaths have a plungeRate set?
Or do they use a tool without a plungeRate?
Not defined would return empty.
Edit the related Toolpath block in the Block List and see the custom properties of the Block itself ... e_geek

Regards,
CVH

Post Reply

Return to “QCAD/CAM”