Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
4d7c55ae
Commit
4d7c55ae
authored
8 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
start G-codes
parent
bfe68a04
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/index.html
+2
-0
2 additions, 0 deletions
modules/index.html
modules/toolpath/formats/G-code
+223
-0
223 additions, 0 deletions
modules/toolpath/formats/G-code
with
225 additions
and
0 deletions
modules/index.html
+
2
−
0
View file @
4d7c55ae
...
@@ -81,6 +81,8 @@
...
@@ -81,6 +81,8 @@
<a
href=
"javascript:handler('modules/string/format')"
>
format
</a><br>
<a
href=
"javascript:handler('modules/string/format')"
>
format
</a><br>
<a
href=
"javascript:handler('modules/string/variables')"
>
variables
</a><br>
<a
href=
"javascript:handler('modules/string/variables')"
>
variables
</a><br>
<i>
toolpath
</i><br>
<i>
toolpath
</i><br>
<i>
formats
</i><br>
<a
href=
"javascript:handler('modules/toolpath/formats/G-code')"
>
G-code
</a><br>
<i>
machines
</i><br>
<i>
machines
</i><br>
<i>
Roland
</i><br>
<i>
Roland
</i><br>
<i>
milling
</i><br>
<i>
milling
</i><br>
...
...
This diff is collapsed.
Click to expand it.
modules/toolpath/formats/G-code
0 → 100644
+
223
−
0
View file @
4d7c55ae
//
// G-code
//
// Neil Gershenfeld
// (c) Massachusetts Institute of Technology 2017
//
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
// project. Copyright is retained and must be preserved. The work is
// provided as is; no warranty is provided, and users accept all
// liability.
//
// closure
//
(function(){
//
// module globals
//
var mod = {}
//
// name
//
var name = 'G-code'
//
// initialization
//
var init = function() {
mod.cutspeed.value = 20
mod.plungespeed.value = 20
mod.jogspeed.value = 75
mod.jogheight.value = 5
mod.spindlespeed.value = 10000
mod.unitsin.checked = true
}
//
// inputs
//
var inputs = {
toolpath:{type:'object',
event:function(evt){
mod.name = evt.detail.name
mod.path = evt.detail.path
mod.dpi = evt.detail.dpi
mod.width = evt.detail.width
mod.height = evt.detail.height
make_path()
}}}
//
// outputs
//
var outputs = {
file:{type:'object',
event:function(str){
obj = {}
obj.name = mod.name+".sbp"
obj.contents = str
mods.output(mod,'file',obj)
}}}
//
// interface
//
var interface = function(div){
mod.div = div
//
// cut speed
//
div.appendChild(document.createTextNode('cut speed: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.cutspeed = input
div.appendChild(document.createTextNode(' (mm/s)'))
div.appendChild(document.createElement('br'))
//
// plunge speed
//
div.appendChild(document.createTextNode('plunge speed: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.plungespeed = input
div.appendChild(document.createTextNode(' (mm/s)'))
div.appendChild(document.createElement('br'))
//
// jog speed
//
div.appendChild(document.createTextNode('jog speed: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.jogspeed = input
div.appendChild(document.createTextNode(' (mm/s)'))
div.appendChild(document.createElement('br'))
//
// jog height
//
div.appendChild(document.createTextNode('jog height: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.jogheight = input
div.appendChild(document.createTextNode(' (mm)'))
div.appendChild(document.createElement('br'))
//
// spindle speed
//
div.appendChild(document.createTextNode('spindle speed: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.spindlespeed = input
div.appendChild(document.createTextNode(' (RPM)'))
div.appendChild(document.createElement('br'))
//
// file units
//
div.appendChild(document.createTextNode('file units:'))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'units'
input.id = mod.div.id+'unitsin'
div.appendChild(input)
mod.unitsin = input
div.appendChild(document.createTextNode('in'))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'units'
input.id = mod.div.id+'unitsmm'
div.appendChild(input)
mod.unitsmm = input
div.appendChild(document.createTextNode('mm'))
}
//
// local functions
//
function make_path() {
var dx = units*mod.width/mod.dpi
var nx = mod.width
var scale = dx/(nx-1)
var jog_speed = parseFloat(mod.jogspeed.value)/25.4
var cut_speed = parseFloat(mod.cutspeed.value)/25.4
var plunge_speed = parseFloat(mod.plungespeed.value)/25.4
var jog_height = parseFloat(mod.jogheight.value)/25.4
var spindle_speed = parseFloat(mod.spindlespeed.value)
var tool = parseInt(mod.tool.value)
str = "%\n" // tape start
// xy plane, inch mode, cancel diameter compensation, cancel length offset
// coordinate system 1, cancel motion, non-incremental motion, feed/minute mode
str += "G17\n"
str += "G20\n"
str += "G40\n"
str += "G49\n"
str += "G54\n"
str += "G80\n"
str += "G90\n"
str += "G94\n"
str += "T"+tool+"M06\n" // tool selection, tool change
str += "F"+cut_speed.toFixed(4)+"\n" // feed rate
str += "S"+spindle_speed+"\n" // spindle speed
if (mod.coolant.checked)
str += "M08\n" // coolant on
str += "G00Z"+jog_height.toFixed(4)+"\n" // move up before starting spindle
str += "M03\n" // spindle on clockwise
str += "G04 P1\n" // give spindle 1 second to spin up
//
// follow segments
//
for (var seg = 0; seg < mod.path.length; ++seg) {
//
// move up to starting point
//
x = scale*mod.path[seg][0][0]
y = scale*mod.path[seg][0][1]
str += "Z"+jog_height.toFixed(4)+"\n"
str += "G00X"+x.toFixed(4)+"Y"+y.toFixed(4)+"Z"+jog_height.toFixed(4)+"\n"
//
// move down
//
z = scale*mod.path[seg][0][2]
str += "G01Z"+z.toFixed(4)+" F"+plunge_speed.toFixed(4)+"\n"
str += "F"+cut_speed.toFixed(4)+"\n" //restore xy feed rate
for (var pt = 1; pt < mod.path[seg].length; ++pt) {
//
// move to next point
//
x = scale*mod.path[seg][pt][0]
y = scale*mod.path[seg][pt][1]
z = scale*mod.path[seg][pt][2]
str += "G01X"+x.toFixed(4)+"Y"+y.toFixed(4)+"Z"+z.toFixed(4)+"\n"
}
}
//
// finish
//
str += "G00Z"+jog_height.toFixed(4)+"\n" // move up before stopping spindle
str += "M05\n" // spindle stop
if (mod.coolant.checked)
str += "M09\n" // coolant off
str += "M30\n" // program end and reset
str += "%\n" // tape end
//
// output file
//
str += "MZ,"+jog_height.toFixed(4)+"\r\n"
outputs.file.event(str)
}
//
// return values
//
return ({
name:name,
init:init,
inputs:inputs,
outputs:outputs,
interface:interface
})
}())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment