Commit 590bbfcb authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

start Trotec

parent 96cde867
......@@ -167,6 +167,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./modules/path/machines/ShopBot'>ShopBot</a><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;laser cutter</i><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./modules/path/machines/laser%20cutter/Epilog'>Epilog</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./modules/path/machines/laser%20cutter/Trotec'>Trotec</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./modules/path/view'>view</a><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processes</i><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cut</i><br>
......@@ -251,6 +252,8 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/machines/ShopBot/mill%202D%20stl'>mill 2D stl</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/machines/ShopBot/mill%202D%20svg'>mill 2D svg</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/machines/ShopBot/mill%202D%20svg%20connect'>mill 2D svg connect</a><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trotec</i><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/machines/Trotec/cut%20png'>cut png</a><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;math</i><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/math/benchmark'>benchmark</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/math/expressions'>expressions</a><br>
......
......@@ -136,6 +136,7 @@ module_menu('            GX-24','modules/path/machines/Roland/vinyl%
module_menu('      ShopBot','modules/path/machines/ShopBot')
module_label('      laser cutter')
module_menu('         Epilog','modules/path/machines/laser%20cutter/Epilog')
module_menu('         Trotec','modules/path/machines/laser%20cutter/Trotec')
module_menu('   view','modules/path/view')
module_label('processes')
module_label('   cut')
......
//
// Trotec laser cutter
//
// Neil Gershenfeld 1/18/20
//
// 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 = 'Trotec laser cutter'
//
// initialization
//
var init = function() {
mod.power.value = 25
mod.velocity.value = 10
mod.frequency.value = 5000
mod.xpos.value = 50
mod.ypos.value = 50
mod.topleft.checked = true
}
//
// inputs
//
var inputs = {
path:{type:'',
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()
}},
settings:{type:'',
event:function(evt){
set_values(evt.detail)
}}}
//
// outputs
//
var outputs = {
file:{type:'',
event:function(str){
obj = {}
obj.type = 'file'
obj.name = mod.name+'.tro'
obj.contents = str
mods.output(mod,'file',obj)
}}}
//
// interface
//
var interface = function(div){
mod.div = div
div.appendChild(document.createTextNode('model:'))
div.appendChild(document.createElement('br'))
var select = document.createElement('select')
select.setAttribute('style', 'width:150px');
var el = document.createElement('option')
el.textContent = 'Speedy 100'
el.value = 'Speedy 100'
select.appendChild(el)
var el = document.createElement('option')
el.textContent = 'Speedy 100 Flexx CO2'
el.value = 'Speedy 100 Flexx CO2'
select.appendChild(el)
var el = document.createElement('option')
el.textContent = 'Speedy 100 Flexx fiber'
el.value = 'Speedy 100 Flexx fiber'
select.appendChild(el)
var el = document.createElement('option')
el.textContent = 'Speedy 400'
el.value = 'Speedy 400'
select.appendChild(el)
div.appendChild(select)
mod.model = select
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('power (%): '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.power = input
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('velocity (mm/s): '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.velocity = input
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('frequency (Hz): '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.frequency = input
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('origin (mm):'))
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('x: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.xpos = input
div.appendChild(document.createTextNode(' y: '))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
div.appendChild(input)
mod.ypos = input
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('alignment:'))
div.appendChild(document.createElement('br'))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'origin'
input.id = mod.div.id+'topleft'
div.appendChild(input)
mod.topleft = input
div.appendChild(document.createTextNode(' left \u00A0\u00A0 top \u00A0\u00A0 right '))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'origin'
input.id = mod.div.id+'topright'
div.appendChild(input)
mod.topright = input
div.appendChild(document.createElement('br'))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'origin'
input.id = mod.div.id+'botleft'
div.appendChild(input)
mod.botleft = input
div.appendChild(document.createTextNode(' left bottom right '))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'origin'
input.id = mod.div.id+'botright'
div.appendChild(input)
mod.botright = input
}
//
// local functions
//
// set_values
//
function set_values(settings) {
for (var s in settings) {
switch(s) {
case 'power (%)':
mod.power.value = settings[s]
break
case 'velocity (mm/s)':
mod.velocity.value = settings[s]
break
case 'frequency (Hz)':
mod.frequency.value = settings[s]
break
}
}
}
//
// make_path
//
function make_path() {
var model = mod.model.value
if (model == "Speedy 100") {
var um_per_inc = 5
var str = "SL0\n" // CO2
}
else if (model == "Speedy 100 Flexx CO2") {
var um_per_inc = 5
var str = "SL0\n" // CO2
}
else if (model == "Speedy 100 Flexx fiber") {
var um_per_inc = 5
var str = "SL4\n" // fiber pulse
}
else if (model == "Speedy 400") {
var um_per_inc = 5.097
var str = "SL0\n" // CO2
}
var dx = 25.4*mod.width/mod.dpi
var dy = 25.4*mod.height/mod.dpi
var nx = mod.width
var ny = mod.height
var power = 100*parseFloat(mod.power.value)
var frequency = parseFloat(mod.frequency.value)
var scale = 1000*(dx/(nx-1))/um_per_inc
var velocity = parseFloat(mod.velocity.value)*1000/um_per_inc
var ox = parseFloat(mod.xpos.value)
var oy = parseFloat(mod.ypos.value)
var xorg = 2600 // Speedy
var yorg = 800 // "
if (mod.botleft.checked) {
var xoffset = xorg+1000*ox/ um_per_inc
var yoffset = yorg+1000*(oy-dy)/um_per_unc
}
else if (mod.botright.checked) {
var xoffset = xorg+1000*(ox-dx)/um_per_inc
var yoffset = yorg+1000*(oy-dy)/um_per_inc
}
else if (mod.topleft.checked) {
var xoffset = xorg+1000*ox/um_per_inc
var yoffset = yorg+1000*oy/um_per_inc
}
else if (mod.topright.checked) {
var xoffset = xorg+1000*(ox-dx)/um_per_inc
var yoffset = yorg+1000*oy/um_per_inc
}
str += "ED3\n" // exhaust on
str += "ED4\n" // air assist on
str += "VS" + velocity.toFixed(0) + "\n" // set velocity
str += "LF" + frequency.toFixed(0) + "\n" // set frequency
str += "LP" + power.toFixed(0) + "\n" // set power
str += "EC\n" // execute
//
// loop over segments
//
for (var seg = 0; seg < mod.path.length; ++seg) {
//
// loop over points
//
x = xoffset + scale * mod.path[seg][0][0]
y = yoffset + scale * (ny - mod.path[seg][0][1])
if (x < 0) x = 0
if (y < 0) y = 0
str += "PA" + x.toFixed(0) + "," + y.toFixed(0) + "\n" // move to start point
str += "PD\n" // laser on
for (var pt = 1; pt < mod.path[seg].length; ++pt) {
x = xoffset + scale * mod.path[seg][pt][0]
y = yoffset + scale * (ny - mod.path[seg][pt][1])
if (x < 0) x = 0
if (y < 0) y = 0
str += "PA" + x.toFixed(0) + "," + y.toFixed(0) + "\n" // move to next point
}
str += "PU\n" // laser off
str += "EC\n" // execute
}
str += "EO3\n" // exhaust off
str += "EO4\n" // air assist off
str += "PA0,0\n" // move home
str += "EC\n" // execute
outputs.file.event(str)
}
//
// return values
//
return ({
mod:mod,
name:name,
init:init,
inputs:inputs,
outputs:outputs,
interface:interface
})
}())
......@@ -19,7 +19,7 @@ var mod = {}
//
// name
//
var name = 'mill raster 3D'
var name = 'mill raster 3D (incomplete)'
//
// initialization
//
......@@ -27,6 +27,7 @@ var init = function() {
mod.dia_in.value = 0.0156
mod.dia_mm.value = 25.4*parseFloat(mod.dia_in.value)
mod.stepover.value = 0.5
mod.error.value = 1
}
//
// inputs
......@@ -36,11 +37,15 @@ var inputs = {
event:function(evt){
mod.width = evt.detail.width
mod.height = evt.detail.height
mod.xmin = evt.detail.xmin
mod.xmax = evt.detail.xmax
mod.ymin = evt.detail.ymin
mod.ymax = evt.detail.ymax
mod.zmin = evt.detail.zmin
mod.zmax = evt.detail.zmax
var ctx = mod.img.getContext("2d")
ctx.canvas.width = mod.width
ctx.canvas.height = mod.height
console.log(mod.width)
console.log(mod.height)
}}}
//
// outputs
......@@ -100,7 +105,6 @@ var interface = function(div){
// tool shape
//
div.appendChild(document.createTextNode('tool shape: '))
div.appendChild(document.createTextNode('flat end'))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'shape'
......@@ -108,12 +112,12 @@ var interface = function(div){
input.checked = true
div.appendChild(input)
mod.flatend= input
div.appendChild(document.createTextNode('flat end'))
div.appendChild(document.createElement('br'))
//
// direction
//
div.appendChild(document.createTextNode('direction: '))
div.appendChild(document.createTextNode('x'))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'direction'
......@@ -121,6 +125,21 @@ var interface = function(div){
input.checked = true
div.appendChild(input)
mod.dirx = input
div.appendChild(document.createTextNode('xz'))
div.appendChild(document.createElement('br'))
//
// fit error
//
div.appendChild(document.createTextNode('vector fit (pixels): '))
//div.appendChild(document.createElement('br'))
var input = document.createElement('input')
input.type = 'text'
input.size = 6
input.addEventListener('change',function(){
vectorize()
})
div.appendChild(input)
mod.error = input
div.appendChild(document.createElement('br'))
//
// calculate
......@@ -137,12 +156,7 @@ var interface = function(div){
btn.addEventListener('click',function(){
mod.label.nodeValue = 'calculating'
mod.labelspan.style.fontWeight = 'bold'
mod.offset = 0.5
mod.offsetCount = 0
mod.path = []
clear_path()
outputs.diameter.event()
outputs.offset.event()
calculate_path()
})
div.appendChild(btn)
div.appendChild(document.createTextNode(' '))
......@@ -197,40 +211,54 @@ var interface = function(div){
//
// local functions
//
// set_values
//
function set_values(settings) {
for (var s in settings) {
switch(s) {
case 'tool diameter (in)':
mod.dia_in.value = settings[s]
mod.dia_mm.value = parseFloat(mod.dia_in.value)*25.4
break
case 'cut depth (in)':
mod.cut_in.value = settings[s]
mod.cut_mm.value = parseFloat(mod.cut_in.value)*25.4
break
case 'max depth (in)':
mod.max_in.value = settings[s]
mod.max_mm.value = parseFloat(mod.max_in.value)*25.4
break
case 'offset number':
mod.number.value = settings[s]
break
}
}
}
// calculate_path
//
// clear_path
//
function clear_path() {
function calculate_path() {
//
// clear SVG
//
var svg = document.getElementById(mod.div.id+'svg')
svg.setAttribute('viewBox',"0 0 "+(mod.img.width-1)+" "+(mod.img.height-1))
svg.setAttribute('viewBox',"0 0 "+(mod.width-1)+" "+(mod.height-1))
var g = document.getElementById(mod.div.id+'g')
svg.removeChild(g)
var g = document.createElementNS('http://www.w3.org/2000/svg','g')
g.setAttribute('id',mod.div.id+'g')
svg.appendChild(g)
//
// line loop
//
var step = 1
var ix = 0
var iy = 0
while (1) {
var x = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
var y = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
console.log(x,y)
ix += step
if (ix == mod.width)
break;
}
var line = document.createElementNS('http://www.w3.org/2000/svg','line')
line.setAttribute('stroke','black')
line.setAttribute('stroke-width',1)
line.setAttribute('stroke-linecap','round')
var x1 = 0
var y1 = 0
var x2 = mod.width
var y2 = mod.height
line.setAttribute('x1',x1)
line.setAttribute('y1',y1)
line.setAttribute('x2',x2)
line.setAttribute('y2',y2)
g.appendChild(line)
mod.label.nodeValue = 'calculate'
mod.labelspan.style.fontWeight = 'normal'
}
//
// clear_path
//
function clear_path() {
}
//
// accumulate_path
......
......@@ -47,6 +47,8 @@ program_menu('      mill 2D png PCB','programs/machines/ShopBot/mill%202D%
program_menu('      mill 2D stl','programs/machines/ShopBot/mill%202D%20stl')
program_menu('      mill 2D svg','programs/machines/ShopBot/mill%202D%20svg')
program_menu('      mill 2D svg connect','programs/machines/ShopBot/mill%202D%20svg%20connect')
program_label('   Trotec')
program_menu('      cut png','programs/machines/Trotec/cut%20png')
program_label('math')
program_menu('   benchmark','programs/math/benchmark')
program_menu('   expressions','programs/math/expressions')
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment