Skip to content
Snippets Groups Projects
Select Git revision
  • 2b6c86f4be24a4e2ade167d09afdf8e438e5ddf4
  • master default
  • neil
  • hpgl
  • sw-shawn-liu
  • ppa
  • fran
  • trotec-port
  • fs-hotfix
  • jake
  • ml-mods
  • fabmo-app
12 results

deviceserver.js

Blame
  • terminalMachine.js 1.74 KiB
    // a run file: the machine in one js scratchpad
    
    // motors,
    var xMotor = createStepper()
    xMotor.route = [0,0] // apa route to hardware
    
    var ylMotor = createStepper()
    ylMotor.route = [0,1]
    
    var yrMotor = createStepper()
    yrMotor.route = [0,2]
    
    var zMotor = createStepper()
    zMotor.route = [0,3]
    
    var spindle = createBLDC()
    spindle.route = [0,4]
    
    
    // a lookahead planner, eats movement instructions and makes smooth trapezoids, tracks motors and their state
    var planner = createPlanner()
    // will listen for these move axis enumerators, motion planning done with pt arrays in this order in cartesian space
    planner.axisConfig = ['X', 'Y', 'Z']
    // will output to these actuators, should be able to write expressions here for kinematics: corexy, h-bot etc
    planner.actuatorConfig = {
    	X: X * 200,
    	YL: Y * 300,
    	YR: -Y * 300,
    	Z: Z * 200
    }
    // would have defaults, but
    planner.accelRate = 250 // units/s
    planner.jd = 0.5 // units for radius of imaginary junction
    
    
    // an input
    var terminal = createTerminal()
    terminal.charWidth = 120
    terminal.linesTall = 64
    
    // to parse gcode - hella stateful!
    var gcodeParser = createGcodeParser()
    
    
    // now we hook up:
    
    // terminal puts characters into the gcode parser, which writes move commands 
    
    terminal.outputs.newline.attach(gcodeParser.inputs.parse)
    gcodeParser.outputs.newmove.attach(planner.inputs.newMove)
    
    // motors and planner intimately connected
    planner.outputs.X.attach(xMotor.inputs.command)
    xMotor.outputs.updates.attach(planner.inputs.X)
    
    planner.outputs.YL.attach(ylMotor.inputs.command)
    ylMotor.outputs.updates.attach(planner.inputs.YL)
    
    planner.outputs.YR.attach(yrMotor.inputs.command)
    yrMotor.outputs.updates.attach(planner.inputs.YR)
    
    planner.outputs.Z.attach(zMotor.inputs.command)
    zMotor.outputs.updates.attach(planner.inputs.Z)