arkypita / LaserGRBL

Laser optimized GUI for GRBL
http://lasergrbl.com
Other
1.26k stars 497 forks source link

Marlin support #338

Open rockman256 opened 6 years ago

rockman256 commented 6 years ago

Hi! Can you make future for you program can marlin firmware support? It need many people, who have 3d printer with laser module (with and without PWM). So your g code (with PWM): G90 G0 X0 Y0 M3 S0 F800 G0 X20.9 Y0.1 S0 G1 X20.1 S100 G0 X17.9 Y0.1 S0 G1 X17.1 S100 G0 X14.7 Y0.1 S0 G1 X14.5 S100 G0 X14.4 Y0.1 S0 G1 X14.2 S100 G0 X14.1 Y0.1 S0 G1 X13.9 S100 G0 X7.5 Y0.1 S0 G1 X6.7 S100 G0 X6.6 Y0.1 S0 G1 X6.4 S100 G0 X3.9 Y0.1 S0 G1 X3.6 S100 G0 X3.5 Y0.1 S0 G1 X3.3 S100 G0 X0.9 Y0.1 S0 G1 X0.6 S100 G0 X0.5 Y0.1 S0 G1 X0.4 S100 G0 X0.5 Y0.2 S0 G1 X1.3 S100 G0 X1.4 Y0.2 S0 G1 X1.7 S100 G0 X3.3 Y0.2 S0 G1 X3.5 S100 X3.6 S101 X4.4 S100 G0 X4.5 Y0.2 S0 G1 X4.9 S100 G0 X6.2 Y0.2 S0 G1 X6.6 S100 X7.3 S101 X7.7 S100 Or without PWM G90 G0 X0 Y0 M5 S255 F800 G0 X0.8 Y0.2 M5 G1 X0.9 M3 X1.3 M3 X1.4 M3 G0 X3.5 Y0.2 M5 G1 X3.6 M3 X4.3 M3 X4.4 M3 G0 X6.4 Y0.2 M5 G1 X6.5 M3 X7.5 M3 X7.6 M3 G0 X10.5 Y0.2 M5 G1 X10.6 M3 X10.7 M3 X10.8 M3 G0 X13.9 Y0.2 M5 G1 X14 M3 X14.7 M3 X14.8 M3 G0 X17 Y0.2 M5 G1 X17.1 M3 X17.9 M3 X18 M3 G0 X20 Y0.2 M5 G1 X20.1 M3 X20.9 M3 X21 M3 G0 X21.5 Y0.3 M5 G1 X21.4 M3 X19.6 M3 X19.5 M3 G0 X18.5 Y0.3 M5 G1 X18.4 M3 X16.6 M3 X16.5 M3 G0 X15.1 Y0.3 M5 G1 X13.6 M3 X13.5 M3 G0 X11.9 Y0.3 M5 G1 X11.8 M3

And same file at another programm (withot PWM) - worked at marlin % G71 G1 F300 (F-Burning speed) M05 G0 Y0.3 X0.95 M03 G1 Y0.3 X1.2 M05 G0 Y0.3 X8.7 M03 G1 Y0.3 X9.4 M05 G0 Y0.3 X17.75 M03 G1 Y0.3 X19.6 M05 G0 Y0.3 X27.25 M03 G1 Y0.3 X27.55 M05 G0 Y0.3 X38 M03 G1 Y0.3 X39.65 M05 G0 Y0.3 X46.75 M03 G1 Y0.3 X48.65 M05 G0 Y0.3 X54.95 M03 G1 Y0.3 X56.8 M05 G0 Y0.35 X0.8 M03 G1 Y0.35 X1.55 M05 G0 Y0.35 X8.6 M03 G1 Y0.35 X9.7 M05 G0 Y0.35 X17.65 M03 G1 Y0.35 X19.75 M05 G0 Y0.35 X27.15 M03 G1 Y0.35 X27.85 M05 G0 Y0.35 X37.9 M03 G1 Y0.35 X39.8 M05 G0 Y0.35 X46.65 M03 G1 Y0.35 X48.8 M05 G0 Y0.35 X54.8 M03 G1 Y0.35 X56.95 M05 G0 Y0.4 X0.75 M03 G1 Y0.4 X1.65 M05 G0 Y0.4 X8.6 M03 G1 Y0.4 X9.85 M05

arkypita commented 6 years ago

Hi @rockman256

LaserGRBL "raster import" is strongly written using grbl gcode syntax and standards, producing optimized code that reduce the number of lines and gcodes to be sent. Just as example all modal commands like are simply skipped 'cause they are redundant.

By your example is difficult to understand what changes is needed to have my gcode compatible with merlin. So: if you want to guide me in writing compatible gcode you should explain me "step by step" what kind of gcode is not compatible and what changes are needed, but please, do not copy and paste a long list of gcodes without comment: they are totally useless.

FREEKER commented 5 years ago

Hello. Marlin not support: G0 X16.7 Y1.4 S10 Need: G0 X16.7 Y1.4 M3 S10 And not support like this: X16.75 S23 Need: G01 X16.75 M3 S23 Speed Port for connecting 250000 M3 S255 - On Laser with PWM M4 - Off Laser

arkypita commented 5 years ago

Thank you.

I think this will require virtualizing my gcode generation routines (that are more than one, because i use my own routine for line2line and third parties ones for SVG and vectorization). This will be a huge work and not my priority to make LaserGRBL multi-firmware compatible. Sorry for that.

iKap commented 5 years ago

Guys, looks like it is just need to modify a source and build the program gcodeRelated.cs:49 private static bool gcodeCompress = true; => change to false it should give full context G-code that will suit Marlin firmware

@arkypita, what will you say?

LinoBarreca commented 5 years ago

well... Marlin nowadays runs on 90% of printers/engravers (unlike GRBL firmware) If LaserGRBL doesn't adapt to marlin I'm sure other softwares will since Marlin is the de-facto standard. Moreover, the flexibility of Marlin (runs on everything, it's fully configurable, doesn't require a custom hardware, like a smoothieboard, but can be configured to run on it) makes Marlin the "Android of printers". Also Marlin GCODE is well documented here http://marlinfw.org/meta/gcode/ it won't take too much for someone to fork this project and make it compatible with it making LaserGRBL becoming obsolete (for the very small number of devices it can be run on)

iffiX commented 4 years ago

Actually it is quite easy to modify marlin and let it read the output of laserGRBL. I am using RAMPS1.4 board, Bascially you will have to do three modifications: In file Marlin/src/gcode/control/M3-M5.cpp

/**
 * M3, M4 - Cutter ON
 */
void GcodeSuite::M3_M4(const bool is_M4) {
  /// I am using D9 fan port to control laser, so same as M106
  uint16_t s = parser.ushortval('S', 255);
  NOMORE(s, 255U);
  thermalManager.set_fan_speed(0, s);
}
/**
 * M5 - Cutter OFF
 */
void GcodeSuite::M5() {
  thermalManager.set_fan_speed(0, 0);
}

In file Marlin/src/gcode/motion/G0-G1.cpp

/**
 * G0, G1: Coordinated movement of X Y Z E axes
 */
void GcodeSuite::G0_G1(
  #if IS_SCARA || defined(G0_FEEDRATE)
    const bool fast_move/*=false*/
  #endif
) {
  ...
  /// Insert following code anywhere you feel comfortable with
  uint16_t s = parser.ushortval('S', 65535);
  if (s != 65535) {
    NOMORE(s, 255U);
    thermalManager.set_fan_speed(0, s);
  }
  ...
}

Finally, enable #define GCODE_MOTION_MODES (So raw X, Y, Z, F commands can be parsed) and #define LASER_FEATURE (So M3, M4 M5 commands will be enabled) in your Configuration_adv.h.

I have tested gcode generated from SVG files, typical image files like png, works like a charm.

nflis commented 3 years ago

Hi! I make some change and to me work great with Marlin 3D printer. https://github.com/arkypita/LaserGRBL/discussions/1372

bunnitech commented 2 years ago

When implementing tthe fix from @iffiX above, don't forget to include temperature.h in the edited .cpp files or thermalManager will be undefined. #include "../../module/temperature.h" Big thanks to you @iffiX I was just about to implement this myself and found your post.